30 lines
929 B
TypeScript
30 lines
929 B
TypeScript
|
|
import express from 'express';
|
||
|
|
import { getConnection, query } from '../utils/db.util';
|
||
|
|
|
||
|
|
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: '获取充值列表失败' });
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
export default router;
|