Фильтр списка статей по пользователю, если оне не админ.
This commit is contained in:
parent
766e13c014
commit
76b7ef5892
@ -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 в фильтр
|
||||
};
|
||||
|
||||
// Рассчитываем пропуск записей
|
||||
|
Loading…
x
Reference in New Issue
Block a user