u
This commit is contained in:
@@ -58,14 +58,6 @@ INNER JOIN categoryarticle ca ON ca.article_id = a.id
|
||||
WHERE a.sku = @sku
|
||||
`;
|
||||
|
||||
export const GET_BY_SKU = `
|
||||
SELECT
|
||||
${ARTICLE_LIST_COLUMNS}
|
||||
FROM article a
|
||||
${ARTICLE_LIST_JOINS}
|
||||
WHERE a.sku = @sku
|
||||
`;
|
||||
|
||||
export const CREATE = `
|
||||
INSERT INTO article (sku, unit_id, unitamount, weight)
|
||||
OUTPUT INSERTED.id
|
||||
|
||||
93
src/sql/articleDetail.js
Normal file
93
src/sql/articleDetail.js
Normal file
@@ -0,0 +1,93 @@
|
||||
export const ARTICLE_DETAIL_COLUMNS = `
|
||||
a.id,
|
||||
a.sku,
|
||||
at.name,
|
||||
at.slug,
|
||||
a.unitamount,
|
||||
a.weight,
|
||||
u.si AS unitSi,
|
||||
b.name AS brandName,
|
||||
brand_pic.thumbw AS brandThumbW,
|
||||
brand_pic.thumbh AS brandThumbH,
|
||||
brand_pic.thumbhash AS brandThumbHash,
|
||||
CASE
|
||||
WHEN a.optionslist_id IS NOT NULL THEN (
|
||||
SELECT COUNT(*)
|
||||
FROM optionslistarticle ola
|
||||
WHERE ola.optionslist_id = a.optionslist_id
|
||||
)
|
||||
ELSE 0
|
||||
END AS optionsCount,
|
||||
CASE
|
||||
WHEN a.articlelist_id IS NOT NULL THEN (
|
||||
SELECT COUNT(*)
|
||||
FROM articlelistarticle ala
|
||||
WHERE ala.articlelist_id = a.articlelist_id
|
||||
)
|
||||
ELSE 0
|
||||
END AS articleListCount,
|
||||
(
|
||||
SELECT COUNT(*)
|
||||
FROM article child
|
||||
WHERE child.fatherarticle_id = a.id
|
||||
) AS childCount,
|
||||
a.fatherarticle_id AS fatherArticleId,
|
||||
father.sku AS fatherSku
|
||||
`;
|
||||
|
||||
export const GET_DETAIL_BY_SKU = `
|
||||
SELECT
|
||||
${ARTICLE_DETAIL_COLUMNS}
|
||||
FROM article a
|
||||
LEFT JOIN articletext at
|
||||
ON at.article_id = a.id AND at.language_id = @languageId
|
||||
LEFT JOIN unit u ON u.id = a.unit_id
|
||||
LEFT JOIN brand b ON b.id = a.brand_id
|
||||
OUTER APPLY (
|
||||
SELECT TOP 1 bp.pic_id
|
||||
FROM brandpic bp
|
||||
WHERE bp.brand_id = b.id
|
||||
ORDER BY bp.sort ASC, bp.id ASC
|
||||
) first_brand_pic
|
||||
LEFT JOIN pic brand_pic ON brand_pic.id = first_brand_pic.pic_id
|
||||
LEFT JOIN article father ON father.id = a.fatherarticle_id
|
||||
WHERE a.sku = @sku
|
||||
`;
|
||||
|
||||
export const GET_CATEGORY_IDS_BY_ARTICLE_ID = `
|
||||
SELECT ca.category_id AS categoryId
|
||||
FROM categoryarticle ca
|
||||
WHERE ca.article_id = @articleId
|
||||
ORDER BY ca.category_id
|
||||
`;
|
||||
|
||||
export const GET_PHOTOS_BY_ARTICLE_ID = `
|
||||
SELECT
|
||||
ap.sort,
|
||||
p.thumbw AS thumbW,
|
||||
p.thumbh AS thumbH,
|
||||
p.thumbhash AS thumbHash
|
||||
FROM articlepic ap
|
||||
INNER JOIN pic p ON p.id = ap.pic_id
|
||||
WHERE ap.article_id = @articleId
|
||||
ORDER BY ap.sort ASC, ap.id ASC
|
||||
`;
|
||||
|
||||
export const GET_EANS_BY_ARTICLE_ID = `
|
||||
SELECT ae.ean
|
||||
FROM articleean ae
|
||||
WHERE ae.article_id = @articleId
|
||||
ORDER BY ae.ean
|
||||
`;
|
||||
|
||||
export const GET_PRICES_BY_ARTICLE_ID = `
|
||||
SELECT
|
||||
pr.minmultiplier AS minmultiplier,
|
||||
pr.net,
|
||||
t.rate AS taxRate,
|
||||
pr.customergroup_id AS customergroupId
|
||||
FROM price pr
|
||||
INNER JOIN tax t ON t.id = pr.tax_id
|
||||
WHERE pr.article_id = @articleId
|
||||
ORDER BY pr.customergroup_id, pr.minmultiplier
|
||||
`;
|
||||
Reference in New Issue
Block a user