u
This commit is contained in:
@@ -440,11 +440,44 @@ SELECT
|
||||
FROM optionslistarticle ola
|
||||
WHERE ola.optionslist_id = a.optionslist_id
|
||||
) AS optionsCount,
|
||||
a.optionslist_id AS optionslistId,
|
||||
(
|
||||
SELECT
|
||||
ola.id,
|
||||
ola.article_id AS articleId,
|
||||
a_opt.sku,
|
||||
at_opt.name,
|
||||
ola.count,
|
||||
ola.sort,
|
||||
ola.mandated
|
||||
FROM optionslistarticle ola
|
||||
INNER JOIN article a_opt ON a_opt.id = ola.article_id
|
||||
LEFT JOIN articletext at_opt ON at_opt.article_id = a_opt.id AND at_opt.language_id = auth.languageId
|
||||
WHERE ola.optionslist_id = a.optionslist_id
|
||||
ORDER BY ola.sort ASC, ola.id ASC
|
||||
FOR JSON PATH
|
||||
) AS optionslistItemsJson,
|
||||
(
|
||||
SELECT COUNT(*)
|
||||
FROM articlelistarticle ala
|
||||
WHERE ala.articlelist_id = a.articlelist_id
|
||||
) AS articleListCount,
|
||||
a.articlelist_id AS articlelistId,
|
||||
(
|
||||
SELECT
|
||||
ala.id,
|
||||
ala.article_id AS articleId,
|
||||
a_item.sku,
|
||||
at_item.name,
|
||||
ala.count,
|
||||
ala.sort
|
||||
FROM articlelistarticle ala
|
||||
INNER JOIN article a_item ON a_item.id = ala.article_id
|
||||
LEFT JOIN articletext at_item ON at_item.article_id = a_item.id AND at_item.language_id = auth.languageId
|
||||
WHERE ala.articlelist_id = a.articlelist_id
|
||||
ORDER BY ala.sort ASC, ala.id ASC
|
||||
FOR JSON PATH
|
||||
) AS articlelistItemsJson,
|
||||
(
|
||||
SELECT COUNT(*)
|
||||
FROM article child
|
||||
|
||||
41
src/providers/mssql/queries/articlelist.js
Normal file
41
src/providers/mssql/queries/articlelist.js
Normal file
@@ -0,0 +1,41 @@
|
||||
export const CREATE_ARTICLELIST = `
|
||||
INSERT INTO articlelist OUTPUT INSERTED.id DEFAULT VALUES;
|
||||
`;
|
||||
|
||||
export const SET_ARTICLE_ARTICLELIST_ID = `
|
||||
UPDATE article
|
||||
SET articlelist_id = @articlelistId
|
||||
WHERE id = @articleId;
|
||||
`;
|
||||
|
||||
export const GET_ARTICLELIST_ITEMS = `
|
||||
SELECT
|
||||
ala.id,
|
||||
ala.articlelist_id AS articlelistId,
|
||||
ala.article_id AS articleId,
|
||||
a.sku,
|
||||
at.name,
|
||||
ala.count,
|
||||
ala.sort
|
||||
FROM articlelistarticle ala
|
||||
INNER JOIN article a ON a.id = ala.article_id
|
||||
LEFT JOIN articletext at ON at.article_id = a.id AND at.language_id = @languageId
|
||||
WHERE ala.articlelist_id = @articlelistId
|
||||
ORDER BY ala.sort ASC, ala.id ASC;
|
||||
`;
|
||||
|
||||
export const INSERT_ARTICLELIST_ARTICLE = `
|
||||
INSERT INTO articlelistarticle (articlelist_id, article_id, count, sort)
|
||||
OUTPUT INSERTED.id, INSERTED.articlelist_id AS articlelistId, INSERTED.article_id AS articleId, INSERTED.count, INSERTED.sort
|
||||
VALUES (@articlelistId, @articleId, @count, @sort);
|
||||
`;
|
||||
|
||||
export const DELETE_ARTICLELIST_ARTICLES = `
|
||||
DELETE FROM articlelistarticle
|
||||
WHERE articlelist_id = @articlelistId;
|
||||
`;
|
||||
|
||||
export const DELETE_ARTICLELIST = `
|
||||
DELETE FROM articlelist
|
||||
WHERE id = @id;
|
||||
`;
|
||||
42
src/providers/mssql/queries/optionslist.js
Normal file
42
src/providers/mssql/queries/optionslist.js
Normal file
@@ -0,0 +1,42 @@
|
||||
export const CREATE_OPTIONSLIST = `
|
||||
INSERT INTO optionslist OUTPUT INSERTED.id DEFAULT VALUES;
|
||||
`;
|
||||
|
||||
export const SET_ARTICLE_OPTIONSLIST_ID = `
|
||||
UPDATE article
|
||||
SET optionslist_id = @optionslistId
|
||||
WHERE id = @articleId;
|
||||
`;
|
||||
|
||||
export const GET_OPTIONSLIST_ITEMS = `
|
||||
SELECT
|
||||
ola.id,
|
||||
ola.optionslist_id AS optionslistId,
|
||||
ola.article_id AS articleId,
|
||||
a.sku,
|
||||
at.name,
|
||||
ola.count,
|
||||
ola.sort,
|
||||
ola.mandated
|
||||
FROM optionslistarticle ola
|
||||
INNER JOIN article a ON a.id = ola.article_id
|
||||
LEFT JOIN articletext at ON at.article_id = a.id AND at.language_id = @languageId
|
||||
WHERE ola.optionslist_id = @optionslistId
|
||||
ORDER BY ola.sort ASC, ola.id ASC;
|
||||
`;
|
||||
|
||||
export const INSERT_OPTIONSLIST_ARTICLE = `
|
||||
INSERT INTO optionslistarticle (optionslist_id, article_id, count, sort, mandated)
|
||||
OUTPUT INSERTED.id, INSERTED.optionslist_id AS optionslistId, INSERTED.article_id AS articleId, INSERTED.count, INSERTED.sort, INSERTED.mandated
|
||||
VALUES (@optionslistId, @articleId, @count, @sort, @mandated);
|
||||
`;
|
||||
|
||||
export const DELETE_OPTIONSLIST_ARTICLES = `
|
||||
DELETE FROM optionslistarticle
|
||||
WHERE optionslist_id = @optionslistId;
|
||||
`;
|
||||
|
||||
export const DELETE_OPTIONSLIST = `
|
||||
DELETE FROM optionslist
|
||||
WHERE id = @id;
|
||||
`;
|
||||
Reference in New Issue
Block a user