This commit is contained in:
seb
2026-10-04 21:22:05 +02:00
parent 0268583ae3
commit 4718cb5726
48 changed files with 758 additions and 758 deletions

View File

@@ -434,9 +434,9 @@ export class BetterSqlite3Provider extends BetterSqlite3Executor {
`ALTER TABLE article ADD COLUMN track_stock INTEGER NOT NULL DEFAULT 1`,
);
}
if (articleCols.length > 0 && !articleCols.includes('fatherattributename_id')) {
if (articleCols.length > 0 && !articleCols.includes('parentattributename_id')) {
this.db.exec(
`ALTER TABLE article ADD COLUMN fatherattributename_id INTEGER REFERENCES attributename(id) ON DELETE NO ACTION`,
`ALTER TABLE article ADD COLUMN parentattributename_id INTEGER REFERENCES attributename(id) ON DELETE NO ACTION`,
);
}

View File

@@ -7,9 +7,9 @@ export const {
DELETE_CATEGORIES_BY_ARTICLE, DELETE_EANS_BY_ARTICLE, EAN_EXISTS,
GET_BRAND_BY_COMPANY_AND_ID,
GET_CATEGORY_ID_BY_SKU, GET_CATEGORY_TREE_FLAT, GET_ID_BY_SKU,
LIST_CHILDREN_BY_FATHER_ID,
SET_FATHER_SORT,
SET_IS_FATHER, TOGGLE_FATHER, UNLINK_CHILD, UPDATE_BRAND, UPDATE_FATHER_BY_SKU, UPDATE_TRACK_STOCK, UPDATE_UNIT,
LIST_CHILDREN_BY_PARENT_ID,
SET_PARENT_SORT,
SET_IS_PARENT, TOGGLE_PARENT, UNLINK_CHILD, UPDATE_BRAND, UPDATE_PARENT_BY_SKU, UPDATE_TRACK_STOCK, UPDATE_UNIT,
UPDATE_UNITAMOUNT, UPDATE_UNIT_AND_AMOUNT, UPDATE_WEIGHT,
} = queries;
@@ -30,7 +30,7 @@ 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
LEFT JOIN article parent ON parent.id = a.parentarticle_id
`;
export const RESOLVE_ARTICLE_ACCESS_BY_SKU = `
@@ -160,16 +160,16 @@ SELECT auth.*,
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)),
'childCount', (SELECT COUNT(*) FROM article WHERE fatherarticle_id = a.id),
'isFather', a.is_father,
'fatherAttributeNameId', a.fatherattributename_id,
'fatherAttributeName', fan.name,
'fatherAttributeExclusive', fan.exclusive,
'fatherArticleId', a.fatherarticle_id, 'fatherSku', father.sku,
'childCount', (SELECT COUNT(*) FROM article WHERE parentarticle_id = a.id),
'isParent', a.is_parent,
'parentAttributeNameId', a.parentattributename_id,
'parentAttributeName', fan.name,
'parentAttributeExclusive', fan.exclusive,
'parentArticleId', a.parentarticle_id, 'parentSku', parent.sku,
'childrenJson', json((SELECT COALESCE(json_group_array(json_object(
'id', child.id,
'sku', child.sku,
'fathersort', child.fathersort,
'parentsort', child.parentsort,
'name', at_child.name,
'attributeValueId', av.id,
'attributeValue', av.value
@@ -177,10 +177,10 @@ SELECT auth.*,
LEFT JOIN articletext at_child ON at_child.article_id = child.id AND at_child.language_id = auth.languageId
LEFT JOIN (
articleattributevalue aav
INNER JOIN attributevalue av ON av.id = aav.attributevalue_id AND av.attribute_id = a.fatherattributename_id
INNER JOIN attributevalue av ON av.id = aav.attributevalue_id AND av.attribute_id = a.parentattributename_id
) ON aav.article_id = child.id
WHERE child.fatherarticle_id = a.id
ORDER BY child.fathersort ASC, child.id ASC)),
WHERE child.parentarticle_id = a.id
ORDER BY child.parentsort ASC, child.id ASC)),
'categoryIdsJson', json(${JSON_CATEGORIES}),
'photosJson', json((SELECT COALESCE(json_group_array(json_object(
'sort', sort, 'fullHash', hash, 'fullW', w, 'fullH', h,
@@ -270,6 +270,6 @@ LEFT JOIN brand b ON b.id = a.brand_id
LEFT JOIN pic bp ON bp.id = (
SELECT pic_id FROM brandpic WHERE brand_id = b.id ORDER BY sort, id LIMIT 1
)
LEFT JOIN article father ON father.id = a.fatherarticle_id
LEFT JOIN attributename fan ON fan.id = a.fatherattributename_id
LEFT JOIN article parent ON parent.id = a.parentarticle_id
LEFT JOIN attributename fan ON fan.id = a.parentattributename_id
`;

View File

@@ -19,7 +19,7 @@ LEFT JOIN pic brand_pic ON brand_pic.id = (
WHERE bp.brand_id = b.id
ORDER BY bp.sort, bp.id LIMIT 1
)
LEFT JOIN article father ON father.id = a.fatherarticle_id
LEFT JOIN article parent ON parent.id = a.parentarticle_id
`;
export const GET_DETAIL_BY_SKU = `

View File

@@ -65,7 +65,7 @@ FROM categoryarticle ca
INNER JOIN article a ON a.id = ca.article_id
${ARTICLE_LIST_JOINS}
WHERE ca.category_id = @categoryId
AND a.fatherarticle_id IS NULL
AND a.parentarticle_id IS NULL
ORDER BY a.id
`;

View File

@@ -3,7 +3,7 @@ import { translateQueries } from './translate.js';
const queries = translateQueries(source, 'manifestDoc');
export const {
CHECK_ARTICLE_IS_FATHER, CREATE_LINE, CREATE_MANIFEST, DELETE_LINES_BY_MANIFEST,
CHECK_ARTICLE_IS_PARENT, CREATE_LINE, CREATE_MANIFEST, DELETE_LINES_BY_MANIFEST,
DELETE_MANIFEST, GET_MANIFEST_HEADER, GET_MANIFEST_LINES, LIST_MANIFESTS,
ORDER_TYPE, QUOTE_TYPE, UPDATE_MANIFEST,
} = queries;

View File

@@ -78,7 +78,7 @@ SELECT
SELECT p2.hash
FROM articlepic ap2
INNER JOIN pic p2 ON p2.id = ap2.pic_id
WHERE a.fatherarticle_id IS NOT NULL AND ap2.article_id = a.fatherarticle_id
WHERE a.parentarticle_id IS NOT NULL AND ap2.article_id = a.parentarticle_id
ORDER BY ap2.sort ASC, ap2.id ASC
LIMIT 1
)
@@ -90,15 +90,15 @@ SELECT
ORDER BY ae.id ASC
LIMIT 1
) AS barcode,
a.is_father AS isParent,
a.fatherarticle_id AS parentArticleId,
a.is_parent AS isParent,
a.parentarticle_id AS parentArticleId,
(
SELECT fan.name || '|' || av.value || '|' || fan.sort || '|' || a.fathersort
SELECT fan.name || '|' || av.value || '|' || fan.sort || '|' || a.parentsort
FROM article fa
INNER JOIN attributename fan ON fan.id = fa.fatherattributename_id
INNER JOIN attributename fan ON fan.id = fa.parentattributename_id
INNER JOIN articleattributevalue aav ON aav.article_id = a.id
INNER JOIN attributevalue av ON av.id = aav.attributevalue_id AND av.attribute_id = fan.id
WHERE a.fatherarticle_id IS NOT NULL AND fa.id = a.fatherarticle_id
WHERE a.parentarticle_id IS NOT NULL AND fa.id = a.parentarticle_id
LIMIT 1
) AS variantName,
CASE

View File

@@ -222,10 +222,10 @@ CREATE TABLE IF NOT EXISTS article (
brand_id INTEGER,
articlelist_id INTEGER,
optionslist_id INTEGER,
is_father INTEGER NOT NULL DEFAULT 0,
fatherarticle_id INTEGER,
fathersort INTEGER NOT NULL DEFAULT 0,
fatherattributename_id INTEGER,
is_parent INTEGER NOT NULL DEFAULT 0,
parentarticle_id INTEGER,
parentsort INTEGER NOT NULL DEFAULT 0,
parentattributename_id INTEGER,
created_at TEXT NOT NULL DEFAULT (${UTC_NOW}),
updated_at TEXT NOT NULL DEFAULT (${UTC_NOW}),
UNIQUE (company_id, sku),
@@ -234,12 +234,12 @@ CREATE TABLE IF NOT EXISTS article (
FOREIGN KEY (brand_id) REFERENCES brand(id) ON DELETE SET NULL,
FOREIGN KEY (articlelist_id) REFERENCES articlelist(id) ON DELETE SET NULL,
FOREIGN KEY (optionslist_id) REFERENCES optionslist(id) ON DELETE SET NULL,
FOREIGN KEY (fatherarticle_id) REFERENCES article(id) ON DELETE NO ACTION,
FOREIGN KEY (fatherattributename_id) REFERENCES attributename(id) ON DELETE NO ACTION
FOREIGN KEY (parentarticle_id) REFERENCES article(id) ON DELETE NO ACTION,
FOREIGN KEY (parentattributename_id) REFERENCES attributename(id) ON DELETE NO ACTION
);
CREATE UNIQUE INDEX IF NOT EXISTS UQ_article_fatherarticle_fathersort
ON article(fatherarticle_id, fathersort)
WHERE fatherarticle_id IS NOT NULL;
CREATE UNIQUE INDEX IF NOT EXISTS UQ_article_parentarticle_parentsort
ON article(parentarticle_id, parentsort)
WHERE parentarticle_id IS NOT NULL;
`;
export const INIT_ARTICLEEAN = `