u
This commit is contained in:
23
src/providers/mssql/queries/attributevaluepic.js
Normal file
23
src/providers/mssql/queries/attributevaluepic.js
Normal 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
|
||||
`;
|
||||
@@ -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
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user