This commit is contained in:
seb
2026-10-24 06:19:37 +02:00
parent 1da82e2eb9
commit 62d0643b99
7 changed files with 365 additions and 0 deletions

View File

@@ -178,3 +178,31 @@ export const DELETE = `
DELETE FROM category
WHERE id = @id
`;
export const LIST_CHILD_CATEGORIES = `
SELECT id
FROM category
WHERE parent_id = @parentId
ORDER BY sort ASC, id ASC
`;
export const GET_CATEGORY_ARTICLE_PICS = `
SELECT
a.id AS articleId,
p.id AS picId,
p.hash,
p.fullbinary AS buffer
FROM categoryarticle ca
INNER JOIN article a ON a.id = ca.article_id
OUTER APPLY (
SELECT TOP 1 ap.pic_id
FROM articlepic ap
WHERE ap.article_id = a.id
ORDER BY ap.sort ASC, ap.id ASC
) first_pic
INNER JOIN pic p ON p.id = first_pic.pic_id
WHERE ca.category_id = @categoryId
AND a.parentarticle_id IS NULL
ORDER BY a.id ASC
`;