This commit is contained in:
seb
2026-10-11 17:26:11 +02:00
parent 7ffb21aabb
commit 7f4092971d
17 changed files with 3076 additions and 2616 deletions

View File

@@ -0,0 +1,23 @@
export const GET_NEXT_SORT = `
SELECT ISNULL(MAX(sort), -1) + 1 AS sort
FROM attributevaluepic
WHERE attributevalue_id = @attributeValueId
`;
export const ADD = `
INSERT INTO attributevaluepic (attributevalue_id, pic_id, sort)
VALUES (@attributeValueId, @picId, @sort)
`;
export const DELETE_BY_ATTRIBUTE_VALUE = `
DELETE FROM attributevaluepic
WHERE attributevalue_id = @attributeValueId
`;
export const GET_FIRST_PIC_BY_ATTRIBUTE_VALUE = `
SELECT TOP 1 p.id AS picId, p.thumbw AS thumbW, p.thumbh AS thumbH, p.thumbhash AS thumbHash
FROM attributevaluepic avp
INNER JOIN pic p ON p.id = avp.pic_id
WHERE avp.attributevalue_id = @attributeValueId
ORDER BY avp.sort ASC, avp.id ASC
`;

View File

@@ -45,6 +45,16 @@ FROM (
INNER JOIN brand b ON b.id = bp.brand_id
INNER JOIN company c ON c.id = b.company_id
WHERE p.hash = @hash
UNION
SELECT c.root_category_id AS categoryId
FROM pic p
INNER JOIN attributevaluepic avp ON avp.pic_id = p.id
INNER JOIN attributevalue av ON av.id = avp.attributevalue_id
INNER JOIN attributename an ON an.id = av.attribute_id
INNER JOIN company c ON c.id = an.company_id
WHERE p.hash = @hash
) AS combined
WHERE categoryId IS NOT NULL
`;