This commit is contained in:
seb
2026-09-27 16:19:45 +02:00
parent e7f92ebef8
commit cd57f21af8
25 changed files with 412 additions and 49 deletions

View File

@@ -1,21 +1,49 @@
export const LIST_BY_COMPANY = `
SELECT
id,
name,
gsprpinfo
FROM brand
WHERE company_id = @companyId
ORDER BY name
b.id,
b.name,
b.gsprpinfo,
(
SELECT
bp.id,
bp.sort,
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
`;
export const GET_BY_COMPANY_AND_NAME = `
SELECT
id,
name,
gsprpinfo
FROM brand
WHERE company_id = @companyId
AND name = @name
b.id,
b.name,
b.gsprpinfo,
(
SELECT
bp.id,
bp.sort,
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
AND b.name = @name
`;
export const CREATE = `
@@ -34,3 +62,13 @@ export const DELETE_BY_COMPANY_AND_ID = `
DELETE FROM brand
WHERE id = @id AND company_id = @companyId
`;
export const GET_BY_ID_AND_COMPANY = `
SELECT
b.id,
b.company_id,
b.name,
b.gsprpinfo
FROM brand b
WHERE b.id = @id AND b.company_id = @companyId
`;