new api
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
const Router = require('koa-router')
|
||||
const { query } = require('../config/database')
|
||||
|
||||
const router = new Router()
|
||||
|
||||
router.get('/:userId', async (ctx) => {
|
||||
const userId = parseInt(ctx.params.userId)
|
||||
|
||||
if (!userId) {
|
||||
ctx.body = { code: 400, message: '请指定用户ID' }
|
||||
return
|
||||
}
|
||||
|
||||
const logs = await query(
|
||||
'SELECT * FROM points_logs WHERE user_id = ? ORDER BY created_at DESC',
|
||||
[userId]
|
||||
)
|
||||
|
||||
ctx.body = {
|
||||
code: 200,
|
||||
data: logs
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = router.routes()
|
||||
Reference in New Issue
Block a user