fix: 修复埋点查询 LIMIT/OFFSET 参数类型错误

- mysql2 execute 对 LIMIT/OFFSET 参数类型要求严格
- 改为直接嵌入 SQL 字符串(pSize 和 offset 已是安全的数字)
This commit is contained in:
2026-06-08 15:56:16 +08:00
parent 50c41d8759
commit 6ef44805f5

View File

@@ -157,14 +157,15 @@ router.get('/track/list', requireAdmin, async (req, res) => {
) )
const total = (countResult as any[])[0].total const total = (countResult as any[])[0].total
// LIMIT/OFFSET 直接嵌入 SQLmysql2 execute 对这些参数类型要求严格)
const [rows] = await pool.execute( const [rows] = await pool.execute(
`SELECT t.*, u.nickname `SELECT t.*, u.nickname
FROM track_events t FROM track_events t
LEFT JOIN users u ON t.user_id = u.id LEFT JOIN users u ON t.user_id = u.id
WHERE ${where} WHERE ${where}
ORDER BY t.created_at DESC ORDER BY t.created_at DESC
LIMIT ? OFFSET ?`, LIMIT ${pSize} OFFSET ${offset}`,
[...params, pSize, offset] params
) )
res.json({ res.json({