diff --git a/src/routes/articles/controllers/list.ts b/src/routes/articles/controllers/list.ts index 6ec1699..f6b9ae5 100644 --- a/src/routes/articles/controllers/list.ts +++ b/src/routes/articles/controllers/list.ts @@ -16,10 +16,14 @@ export async function listArticles(req: Request, res: Response) { const catId = Number(req.query.categoryId); const citId = Number(req.query.cityId); + const authorId = req.query.userId ? String(req.query.userId) : undefined; // Приводим к строке - это UUID + const isAdmin = Boolean(req.query.isAdmin); + const where: Prisma.ArticleWhereInput = { ...(Number.isInteger(catId) && catId > 0 ? { categoryId: catId } : {}), ...(Number.isInteger(citId) && citId > 0 ? { cityId: citId } : {}), ...(isActiveParam === "true" ? { isActive: false } : isActiveParam === "false" ? {} : { isActive: true }), + ...(authorId && !isAdmin ? { authorId } : {}), // Добавляем authorId в фильтр }; // Рассчитываем пропуск записей