fix: remove dead code, add ZodError handling, fix NaN pagination, add like routes, fix schemesCount sync

This commit is contained in:
2026-05-14 11:45:19 +08:00
parent 68f74bbc8c
commit ea4e0f6e07
7 changed files with 224 additions and 175 deletions

View File

@@ -15,7 +15,9 @@ const TARGET_TYPES = ['SCHEME', 'SCHEME_AOB', 'FILTER'] as const;
router.get('/', async (req: Request, res: Response) => {
try {
const { type, page = 1, limit = 20 } = req.query;
const skip = (Number(page) - 1) * Number(limit);
const pageNum = Math.max(1, parseInt(String(page)) || 1);
const limitNum = Math.min(100, Math.max(1, parseInt(String(limit)) || 20));
const skip = (pageNum - 1) * limitNum;
const where: any = { userId: req.user!.userId };
if (type && TARGET_TYPES.includes(type as any)) {