Add category image add/delete with categorypic SQL layer
This commit is contained in:
@@ -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
23
src/sql/categorypic.js
Normal 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
|
||||
`;
|
||||
Reference in New Issue
Block a user