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

@@ -24,6 +24,11 @@ LEFT JOIN pic ON pic.id = (
SELECT ap.pic_id FROM articlepic ap
WHERE ap.article_id = a.id ORDER BY ap.sort, ap.id LIMIT 1
)
LEFT JOIN brand b ON b.id = a.brand_id
LEFT JOIN pic brand_pic ON brand_pic.id = (
SELECT bp.pic_id FROM brandpic bp
WHERE bp.brand_id = b.id ORDER BY bp.sort, bp.id LIMIT 1
)
LEFT JOIN article father ON father.id = a.fatherarticle_id
`;
@@ -119,7 +124,9 @@ SELECT auth.*,
'unitamount', a.unitamount, 'weight', a.weight,
'unitSi', u.si, 'unitBasesi', u.basesi,
'unitBasesifactor', u.basesifactor, 'unitSymbol', ut.symbol,
'unitName', ut.name, 'brandName', b.name,
'unitName', ut.name,
'brandId', b.id, 'brandName', b.name,
'brandFullHash', bp.hash,
'brandThumbW', bp.thumbw, 'brandThumbH', bp.thumbh,
'brandThumbHash', bp.thumbhash,
'optionsCount', (SELECT COUNT(*) FROM optionslistarticle WHERE optionslist_id = a.optionslist_id),

View File

@@ -3,6 +3,59 @@ import { translateQueries } from './translate.js';
const queries = translateQueries(source, 'brand');
export const {
CREATE, DELETE_BY_COMPANY_AND_ID, GET_BY_COMPANY_AND_NAME,
LIST_BY_COMPANY, UPDATE_BY_ID,
} = queries;
CREATE, DELETE_BY_COMPANY_AND_ID, UPDATE_BY_ID, GET_BY_ID_AND_COMPANY,
} = queries;
export const LIST_BY_COMPANY = `
SELECT
b.id,
b.name,
b.gsprpinfo,
(
SELECT COALESCE(json_group_array(json_object(
'id', id,
'sort', sort,
'fullHash', hash,
'thumbW', thumbw,
'thumbH', thumbh,
'thumbHash', thumbhash
)), '[]')
FROM (
SELECT bp.id, bp.sort, p.hash, p.thumbw, p.thumbh, p.thumbhash
FROM brandpic bp
INNER JOIN pic p ON p.id = bp.pic_id
WHERE bp.brand_id = b.id
ORDER BY bp.sort, bp.id
)
) AS picsJson
FROM brand b
WHERE b.company_id = @companyId
ORDER BY b.name
`;
export const GET_BY_COMPANY_AND_NAME = `
SELECT
b.id,
b.name,
b.gsprpinfo,
(
SELECT COALESCE(json_group_array(json_object(
'id', id,
'sort', sort,
'fullHash', hash,
'thumbW', thumbw,
'thumbH', thumbh,
'thumbHash', thumbhash
)), '[]')
FROM (
SELECT bp.id, bp.sort, p.hash, p.thumbw, p.thumbh, p.thumbhash
FROM brandpic bp
INNER JOIN pic p ON p.id = bp.pic_id
WHERE bp.brand_id = b.id
ORDER BY bp.sort, bp.id
)
) AS picsJson
FROM brand b
WHERE b.company_id = @companyId
AND b.name = @name
`;

View File

@@ -0,0 +1,5 @@
import * as source from '../../mssql/queries/brandpic.js';
import { translateQueries } from './translate.js';
const queries = translateQueries(source, 'brandpic');
export const { ADD, DELETE_BY_BRAND, GET_FIRST_PIC_BY_BRAND, GET_NEXT_SORT } = queries;