From e74be47b54813613aea5ccc8f98122e98395ffa7 Mon Sep 17 00:00:00 2001 From: raipen Date: Fri, 24 Nov 2023 10:10:42 +0900 Subject: [PATCH] feat: set default option true at seed --- seeding/testSeed.ts | 51 +++++++++++++++++++++++++++++++++++++++++ src/api/routes/store.ts | 1 - 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/seeding/testSeed.ts b/seeding/testSeed.ts index 6cfa3f0..68f9921 100644 --- a/seeding/testSeed.ts +++ b/seeding/testSeed.ts @@ -198,6 +198,50 @@ export default async (prisma: PrismaClient, storeId: number) => { storeId } }); + + await prisma.option.createMany({ + data: [ + { + optionName: 'ice', + optionPrice: 0, + optionCategory: '온도', + }, + { + optionName: 'hot', + optionPrice: 0, + optionCategory: '온도', + }, + { + optionName: '원두1', + optionPrice: 0, + optionCategory: '원두', + }, + { + optionName: '원두2', + optionPrice: 300, + optionCategory: '원두', + }, + { + optionName: '1샷 추가', + optionPrice: 500, + optionCategory: '샷', + }, + { + optionName: '샷 빼기', + optionPrice: 0, + optionCategory: '샷', + }, + ].map((option) => ({ + ...option, + storeId, + })), + }); + const options = await prisma.option.findMany({ + where: { + storeId + } + }); + await prisma.menu.createMany({ data: menuDataWithMaterials.map((menu,index) => ({ name: menu.name, @@ -214,6 +258,13 @@ export default async (prisma: PrismaClient, storeId: number) => { } }); + await prisma.optionMenu.createMany({ + data: menus.flatMap((menu) => options.map((option) => ({ + menuId: menu.id, + optionId: option.id + }))) + }); + await prisma.recipe.createMany({ data: menuDataWithMaterials.flatMap((menu) => menu.materials.map((material) => ({ coldRegularAmount: material.coldRegularAmount, diff --git a/src/api/routes/store.ts b/src/api/routes/store.ts index 92f638f..02b7758 100644 --- a/src/api/routes/store.ts +++ b/src/api/routes/store.ts @@ -43,7 +43,6 @@ const api: FastifyPluginAsync = async (server: FastifyInstance) => { }, async (request, reply) => { const result = await storeService.newStore(request.body); - await storeService.registDefaultOption(result); await storeService.seeding(result); reply.code(200).send(result); }