u
This commit is contained in:
41
src/providers/mssql/queries/articleattributevalue.js
Normal file
41
src/providers/mssql/queries/articleattributevalue.js
Normal file
@@ -0,0 +1,41 @@
|
||||
export const LIST_BY_ARTICLE_ID = `
|
||||
SELECT
|
||||
aav.id,
|
||||
aav.article_id AS articleId,
|
||||
an.id AS attributeId,
|
||||
an.name AS attributeName,
|
||||
an.exclusive,
|
||||
av.id AS attributeValueId,
|
||||
av.value,
|
||||
aav.sort
|
||||
FROM articleattributevalue aav
|
||||
INNER JOIN attributevalue av ON av.id = aav.attributevalue_id
|
||||
INNER JOIN attributename an ON an.id = av.attribute_id
|
||||
WHERE aav.article_id = @articleId
|
||||
ORDER BY an.sort ASC, an.id ASC, aav.sort ASC, aav.id ASC
|
||||
`;
|
||||
|
||||
export const DELETE_BY_ARTICLE_ID = `
|
||||
DELETE FROM articleattributevalue
|
||||
WHERE article_id = @articleId
|
||||
`;
|
||||
|
||||
export const INSERT_ROW = `
|
||||
INSERT INTO articleattributevalue (article_id, attributevalue_id, sort)
|
||||
OUTPUT INSERTED.id, INSERTED.article_id AS articleId, INSERTED.attributevalue_id AS attributeValueId, INSERTED.sort
|
||||
VALUES (@articleId, @attributeValueId, @sort)
|
||||
`;
|
||||
|
||||
export const GET_VALUE_DETAIL = `
|
||||
SELECT
|
||||
av.id AS attributeValueId,
|
||||
av.value,
|
||||
av.sort,
|
||||
an.id AS attributeId,
|
||||
an.name AS attributeName,
|
||||
an.exclusive,
|
||||
an.company_id AS companyId
|
||||
FROM attributevalue av
|
||||
INNER JOIN attributename an ON an.id = av.attribute_id
|
||||
WHERE av.id = @attributeValueId
|
||||
`;
|
||||
29
src/providers/mssql/queries/articleproperty.js
Normal file
29
src/providers/mssql/queries/articleproperty.js
Normal file
@@ -0,0 +1,29 @@
|
||||
export const LIST_BY_ARTICLE_ID = `
|
||||
SELECT
|
||||
ap.id,
|
||||
ap.article_id AS articleId,
|
||||
ap.property_id AS propertyId,
|
||||
pn.name AS name,
|
||||
ap.value,
|
||||
ap.sort
|
||||
FROM articleproperty ap
|
||||
INNER JOIN propertyname pn ON pn.id = ap.property_id
|
||||
WHERE ap.article_id = @articleId
|
||||
ORDER BY ap.sort ASC, ap.id ASC
|
||||
`;
|
||||
|
||||
export const DELETE_BY_ARTICLE_ID = `
|
||||
DELETE FROM articleproperty
|
||||
WHERE article_id = @articleId
|
||||
`;
|
||||
|
||||
export const DELETE_BY_ARTICLE_AND_PROPERTY_ID = `
|
||||
DELETE FROM articleproperty
|
||||
WHERE article_id = @articleId AND property_id = @propertyId
|
||||
`;
|
||||
|
||||
export const INSERT_ROW = `
|
||||
INSERT INTO articleproperty (article_id, property_id, value, sort)
|
||||
OUTPUT INSERTED.id, INSERTED.article_id AS articleId, INSERTED.property_id AS propertyId, INSERTED.value, INSERTED.sort
|
||||
VALUES (@articleId, @propertyId, @value, @sort)
|
||||
`;
|
||||
88
src/providers/mssql/queries/attributename.js
Normal file
88
src/providers/mssql/queries/attributename.js
Normal file
@@ -0,0 +1,88 @@
|
||||
export const LIST_BY_COMPANY = `
|
||||
SELECT
|
||||
an.id,
|
||||
an.name,
|
||||
an.sort,
|
||||
an.exclusive,
|
||||
(
|
||||
SELECT
|
||||
av.id,
|
||||
av.value,
|
||||
av.sort
|
||||
FROM attributevalue av
|
||||
WHERE av.attribute_id = an.id
|
||||
ORDER BY av.sort ASC, av.id ASC
|
||||
FOR JSON PATH
|
||||
) AS valuesJson
|
||||
FROM attributename an
|
||||
WHERE an.company_id = @companyId
|
||||
ORDER BY an.sort ASC, an.id ASC
|
||||
`;
|
||||
|
||||
export const LIST_IDS_BY_COMPANY = `
|
||||
SELECT id
|
||||
FROM attributename
|
||||
WHERE company_id = @companyId
|
||||
ORDER BY sort ASC, id ASC
|
||||
`;
|
||||
|
||||
export const GET_BY_COMPANY_AND_ID = `
|
||||
SELECT
|
||||
an.id,
|
||||
an.company_id,
|
||||
an.name,
|
||||
an.sort,
|
||||
an.exclusive,
|
||||
(
|
||||
SELECT
|
||||
av.id,
|
||||
av.value,
|
||||
av.sort
|
||||
FROM attributevalue av
|
||||
WHERE av.attribute_id = an.id
|
||||
ORDER BY av.sort ASC, av.id ASC
|
||||
FOR JSON PATH
|
||||
) AS valuesJson
|
||||
FROM attributename an
|
||||
WHERE an.id = @id AND an.company_id = @companyId
|
||||
`;
|
||||
|
||||
export const GET_BY_COMPANY_AND_NAME = `
|
||||
SELECT
|
||||
id,
|
||||
company_id,
|
||||
name,
|
||||
sort,
|
||||
exclusive
|
||||
FROM attributename
|
||||
WHERE name = @name AND company_id = @companyId
|
||||
`;
|
||||
|
||||
export const GET_NEXT_SORT = `
|
||||
SELECT ISNULL(MAX(sort), -1) + 1 AS sort
|
||||
FROM attributename
|
||||
WHERE company_id = @companyId
|
||||
`;
|
||||
|
||||
export const CREATE = `
|
||||
INSERT INTO attributename (company_id, name, sort, exclusive)
|
||||
OUTPUT INSERTED.id, INSERTED.name, INSERTED.sort, INSERTED.exclusive
|
||||
VALUES (@companyId, @name, @sort, @exclusive)
|
||||
`;
|
||||
|
||||
export const UPDATE_BY_ID = `
|
||||
UPDATE attributename
|
||||
SET name = @name, sort = @sort, exclusive = @exclusive
|
||||
WHERE id = @id AND company_id = @companyId
|
||||
`;
|
||||
|
||||
export const UPDATE_SORT = `
|
||||
UPDATE attributename
|
||||
SET sort = @sort
|
||||
WHERE id = @id AND company_id = @companyId
|
||||
`;
|
||||
|
||||
export const DELETE_BY_COMPANY_AND_ID = `
|
||||
DELETE FROM attributename
|
||||
WHERE id = @id AND company_id = @companyId
|
||||
`;
|
||||
70
src/providers/mssql/queries/attributevalue.js
Normal file
70
src/providers/mssql/queries/attributevalue.js
Normal file
@@ -0,0 +1,70 @@
|
||||
export const LIST_BY_ATTRIBUTE_ID = `
|
||||
SELECT
|
||||
av.id,
|
||||
av.attribute_id AS attributeId,
|
||||
av.value,
|
||||
av.sort
|
||||
FROM attributevalue av
|
||||
INNER JOIN attributename an ON an.id = av.attribute_id
|
||||
WHERE av.attribute_id = @attributeId AND an.company_id = @companyId
|
||||
ORDER BY av.sort ASC, av.id ASC
|
||||
`;
|
||||
|
||||
export const LIST_IDS_BY_ATTRIBUTE_ID = `
|
||||
SELECT av.id
|
||||
FROM attributevalue av
|
||||
INNER JOIN attributename an ON an.id = av.attribute_id
|
||||
WHERE av.attribute_id = @attributeId AND an.company_id = @companyId
|
||||
ORDER BY av.sort ASC, av.id ASC
|
||||
`;
|
||||
|
||||
export const GET_BY_ID_AND_COMPANY = `
|
||||
SELECT
|
||||
av.id,
|
||||
av.attribute_id AS attributeId,
|
||||
av.value,
|
||||
av.sort,
|
||||
an.company_id AS companyId
|
||||
FROM attributevalue av
|
||||
INNER JOIN attributename an ON an.id = av.attribute_id
|
||||
WHERE av.id = @id AND an.company_id = @companyId
|
||||
`;
|
||||
|
||||
export const GET_BY_ATTRIBUTE_AND_VALUE = `
|
||||
SELECT
|
||||
av.id,
|
||||
av.attribute_id AS attributeId,
|
||||
av.value,
|
||||
av.sort
|
||||
FROM attributevalue av
|
||||
WHERE av.attribute_id = @attributeId AND av.value = @value
|
||||
`;
|
||||
|
||||
export const GET_NEXT_SORT = `
|
||||
SELECT ISNULL(MAX(sort), -1) + 1 AS sort
|
||||
FROM attributevalue
|
||||
WHERE attribute_id = @attributeId
|
||||
`;
|
||||
|
||||
export const CREATE = `
|
||||
INSERT INTO attributevalue (attribute_id, value, sort)
|
||||
OUTPUT INSERTED.id, INSERTED.attribute_id AS attributeId, INSERTED.value, INSERTED.sort
|
||||
VALUES (@attributeId, @value, @sort)
|
||||
`;
|
||||
|
||||
export const UPDATE_BY_ID = `
|
||||
UPDATE attributevalue
|
||||
SET value = @value, sort = @sort
|
||||
WHERE id = @id
|
||||
`;
|
||||
|
||||
export const UPDATE_SORT = `
|
||||
UPDATE attributevalue
|
||||
SET sort = @sort
|
||||
WHERE id = @id
|
||||
`;
|
||||
|
||||
export const DELETE_BY_ID = `
|
||||
DELETE FROM attributevalue
|
||||
WHERE id = @id
|
||||
`;
|
||||
65
src/providers/mssql/queries/propertyname.js
Normal file
65
src/providers/mssql/queries/propertyname.js
Normal file
@@ -0,0 +1,65 @@
|
||||
export const LIST_BY_COMPANY = `
|
||||
SELECT
|
||||
id,
|
||||
name,
|
||||
sort
|
||||
FROM propertyname
|
||||
WHERE company_id = @companyId
|
||||
ORDER BY sort ASC, id ASC
|
||||
`;
|
||||
|
||||
export const LIST_IDS_BY_COMPANY = `
|
||||
SELECT id
|
||||
FROM propertyname
|
||||
WHERE company_id = @companyId
|
||||
ORDER BY sort ASC, id ASC
|
||||
`;
|
||||
|
||||
export const GET_BY_COMPANY_AND_ID = `
|
||||
SELECT
|
||||
id,
|
||||
company_id,
|
||||
name,
|
||||
sort
|
||||
FROM propertyname
|
||||
WHERE id = @id AND company_id = @companyId
|
||||
`;
|
||||
|
||||
export const GET_BY_COMPANY_AND_NAME = `
|
||||
SELECT
|
||||
id,
|
||||
company_id,
|
||||
name,
|
||||
sort
|
||||
FROM propertyname
|
||||
WHERE name = @name AND company_id = @companyId
|
||||
`;
|
||||
|
||||
export const GET_NEXT_SORT = `
|
||||
SELECT ISNULL(MAX(sort), -1) + 1 AS sort
|
||||
FROM propertyname
|
||||
WHERE company_id = @companyId
|
||||
`;
|
||||
|
||||
export const CREATE = `
|
||||
INSERT INTO propertyname (company_id, name, sort)
|
||||
OUTPUT INSERTED.id, INSERTED.name, INSERTED.sort
|
||||
VALUES (@companyId, @name, @sort)
|
||||
`;
|
||||
|
||||
export const UPDATE_BY_ID = `
|
||||
UPDATE propertyname
|
||||
SET name = @name, sort = @sort
|
||||
WHERE id = @id AND company_id = @companyId
|
||||
`;
|
||||
|
||||
export const UPDATE_SORT = `
|
||||
UPDATE propertyname
|
||||
SET sort = @sort
|
||||
WHERE id = @id AND company_id = @companyId
|
||||
`;
|
||||
|
||||
export const DELETE_BY_COMPANY_AND_ID = `
|
||||
DELETE FROM propertyname
|
||||
WHERE id = @id AND company_id = @companyId
|
||||
`;
|
||||
Reference in New Issue
Block a user