diff --git a/server/src/index.ts b/server/src/index.ts index 210f954..1722705 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -671,7 +671,7 @@ app.post('/api/admin/banners', async (req: Request, res: Response) => { // 管理后台: 修改 Banner app.put('/api/admin/banners/:id', async (req: Request, res: Response) => { try { - const bannerId = req.params.id; + const bannerId = String(req.params.id); const { title, subtitle, tag, badge, badgeType, bg, image, link, sortOrder, status } = req.body; if (title) { @@ -707,7 +707,7 @@ app.put('/api/admin/banners/:id', async (req: Request, res: Response) => { // 管理后台: 切换 Banner 上架/下线状态 app.post('/api/admin/banners/:id/status', async (req: Request, res: Response) => { try { - const bannerId = req.params.id; + const bannerId = String(req.params.id); const { status } = req.body; if (status === undefined || (status !== 0 && status !== 1)) { return res.status(400).json({ code: 40000, message: '状态参数必须为 0 或 1' }); @@ -727,7 +727,7 @@ app.post('/api/admin/banners/:id/status', async (req: Request, res: Response) => // 管理后台: 删除 Banner app.delete('/api/admin/banners/:id', async (req: Request, res: Response) => { try { - const bannerId = req.params.id; + const bannerId = String(req.params.id); const ok = await repo.deleteBanner(bannerId); if (!ok) { return res.status(404).json({ code: 40400, message: '轮播图不存在或已被删除' });