2025-04-24 12:03:19 +08:00
|
|
|
const express = require('express');
|
|
|
|
|
const { getConnection, query } = require('../utils/db.util');
|
2025-04-24 11:59:10 +08:00
|
|
|
|
|
|
|
|
const router = express.Router();
|
|
|
|
|
|
|
|
|
|
// 获取角色列表
|
|
|
|
|
router.get('/roles', async (req, res) => {
|
|
|
|
|
try {
|
|
|
|
|
const connection = await getConnection();
|
|
|
|
|
const results = await query('SELECT * FROM role', [], connection);
|
|
|
|
|
res.json(results);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取角色数据失败:', error);
|
|
|
|
|
res.status(500).json({ error: '获取角色数据失败' });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 获取充值列表
|
|
|
|
|
router.get('/recharges', async (req, res) => {
|
|
|
|
|
try {
|
|
|
|
|
const connection = await getConnection();
|
|
|
|
|
const results = await query('SELECT * FROM recharge', [], connection);
|
|
|
|
|
res.json(results);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取充值列表失败:', error);
|
|
|
|
|
res.status(500).json({ error: '获取充值列表失败' });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2025-04-24 12:03:19 +08:00
|
|
|
module.exports = router;
|