This commit is contained in:
seb
2026-10-09 18:10:51 +02:00
parent 4ae3439289
commit 07c4f0bff9
8 changed files with 130 additions and 43 deletions

View File

@@ -5,8 +5,6 @@ SELECT
b.gsprpinfo,
(
SELECT
bp.id,
bp.sort,
p.hash AS fullHash,
p.thumbw AS thumbW,
p.thumbh AS thumbH,
@@ -22,6 +20,35 @@ WHERE b.company_id = @companyId
ORDER BY b.name
`;
export const COUNT_BY_COMPANY = `
SELECT COUNT(*) AS total
FROM brand b
WHERE b.company_id = @companyId
`;
export const LIST_BY_COMPANY_PAGED = `
SELECT
b.id,
b.name,
b.gsprpinfo,
(
SELECT
p.hash AS fullHash,
p.thumbw AS thumbW,
p.thumbh AS thumbH,
p.thumbhash AS thumbHash
FROM brandpic bp
INNER JOIN pic p ON p.id = bp.pic_id
WHERE bp.brand_id = b.id
ORDER BY bp.sort ASC, bp.id ASC
FOR JSON PATH
) AS picsJson
FROM brand b
WHERE b.company_id = @companyId
ORDER BY b.name
OFFSET @offset ROWS FETCH NEXT @limit ROWS ONLY
`;
export const GET_BY_COMPANY_AND_NAME = `
SELECT
b.id,
@@ -29,8 +56,6 @@ SELECT
b.gsprpinfo,
(
SELECT
bp.id,
bp.sort,
p.hash AS fullHash,
p.thumbw AS thumbW,
p.thumbh AS thumbH,