feat(store): add two-level store categories for admin and partner open-store
CI / verify (pull_request) Has been cancelled
CI / verify (pull_request) Has been cancelled
Admin CRUD under stores menu; partner picks leaf category on create. Default sync only inserts missing rows and never updates existing ones. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -266,13 +266,36 @@ async function main() {
|
||||
|
||||
|
||||
|
||||
const categories = await Promise.all([
|
||||
|
||||
prisma.commonStoreCategory.create({ data: { code: 'HOTPOT', name: '火锅', sort: 1 } }),
|
||||
|
||||
prisma.commonStoreCategory.create({ data: { code: 'LOCAL', name: '地方菜', sort: 2 } }),
|
||||
|
||||
]);
|
||||
const { DEFAULT_STORE_CATEGORY_TREE } = await import('../src/modules/store/store-category.defaults');
|
||||
const categoryByCode = new Map<string, { id: bigint }>();
|
||||
for (const root of DEFAULT_STORE_CATEGORY_TREE) {
|
||||
const parent = await prisma.commonStoreCategory.create({
|
||||
data: {
|
||||
code: root.code,
|
||||
name: root.name,
|
||||
sort: root.sort,
|
||||
parentId: null,
|
||||
status: 'ACTIVE',
|
||||
},
|
||||
});
|
||||
categoryByCode.set(root.code, parent);
|
||||
for (const child of root.children) {
|
||||
const row = await prisma.commonStoreCategory.create({
|
||||
data: {
|
||||
code: child.code,
|
||||
name: child.name,
|
||||
sort: child.sort,
|
||||
parentId: parent.id,
|
||||
status: 'ACTIVE',
|
||||
},
|
||||
});
|
||||
categoryByCode.set(child.code, row);
|
||||
}
|
||||
}
|
||||
const categories = [
|
||||
categoryByCode.get('HOTPOT')!,
|
||||
categoryByCode.get('LOCAL')!,
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user