Add category image add/delete with categorypic SQL layer

This commit is contained in:
seb
2026-08-03 07:38:14 +02:00
parent f8e52549d6
commit 6128fc59fd
6 changed files with 139 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ SELECT
t.sort,
ct.name,
ct.slug,
p.hash AS fullHash,
p.thumbw AS thumbW,
p.thumbh AS thumbH,
p.thumbhash AS thumbHash

23
src/sql/categorypic.js Normal file
View File

@@ -0,0 +1,23 @@
export const GET_NEXT_SORT = `
SELECT ISNULL(MAX(sort), -1) + 1 AS sort
FROM categorypic
WHERE category_id = @categoryId
`;
export const ADD = `
INSERT INTO categorypic (category_id, pic_id, sort)
VALUES (@categoryId, @picId, @sort)
`;
export const DELETE_BY_CATEGORY = `
DELETE FROM categorypic
WHERE category_id = @categoryId
`;
export const GET_FIRST_PIC_BY_CATEGORY = `
SELECT TOP 1 p.id AS picId, p.thumbw AS thumbW, p.thumbh AS thumbH, p.thumbhash AS thumbHash
FROM categorypic cp
INNER JOIN pic p ON p.id = cp.pic_id
WHERE cp.category_id = @categoryId
ORDER BY cp.sort ASC, cp.id ASC
`;