商品模板功能上传
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { DEFAULT_PRODUCT_DETAIL_TEMPLATES } from './seeds/product-detail-templates.default';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
for (const tpl of DEFAULT_PRODUCT_DETAIL_TEMPLATES) {
|
||||
await prisma.commonProductDetailTemplate.upsert({
|
||||
where: { code: tpl.code },
|
||||
create: {
|
||||
code: tpl.code,
|
||||
name: tpl.name,
|
||||
description: tpl.description,
|
||||
aromaType: tpl.aromaType as 'QINGXIANG' | 'JIANGXIANG' | 'NONGXIANG' | null,
|
||||
storyTitle: tpl.storyTitle,
|
||||
storyText: tpl.storyText,
|
||||
features: tpl.features,
|
||||
detailImageUrls: [],
|
||||
suggestedDetailImageCount: tpl.suggestedDetailImageCount,
|
||||
sortOrder: tpl.sortOrder,
|
||||
status: 'ACTIVE',
|
||||
},
|
||||
update: {
|
||||
name: tpl.name,
|
||||
description: tpl.description,
|
||||
aromaType: tpl.aromaType as 'QINGXIANG' | 'JIANGXIANG' | 'NONGXIANG' | null,
|
||||
storyTitle: tpl.storyTitle,
|
||||
storyText: tpl.storyText,
|
||||
features: tpl.features,
|
||||
detailImageUrls: [],
|
||||
suggestedDetailImageCount: tpl.suggestedDetailImageCount,
|
||||
sortOrder: tpl.sortOrder,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log(`Upserted ${DEFAULT_PRODUCT_DETAIL_TEMPLATES.length} product detail templates`);
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
Reference in New Issue
Block a user