Skip to content

Commit

Permalink
Feat: mixed stock apis (#60)
Browse files Browse the repository at this point in the history
* feat: implement stock apis

* feat: test stock Service

* feat: test menu apis

* fix: preOrder list default date
  • Loading branch information
raipen authored Oct 19, 2023
1 parent 327f902 commit 7007e73
Show file tree
Hide file tree
Showing 15 changed files with 1,231 additions and 233 deletions.
2 changes: 0 additions & 2 deletions prisma/menuSeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export default async (prisma: PrismaClient, storeId: number) => {
create: material.materials.map((material) => ({
amount: parseInt(material.amount),
stockId: material.stockId,
storeId
}))
}
}
Expand Down Expand Up @@ -145,7 +144,6 @@ export default async (prisma: PrismaClient, storeId: number) => {
hotRegularAmount: material.hotRegularAmount,
hotSizeUpAmount: material.hotSizeUpAmount,
stockId: material.stockId,
storeId
}))
}
}
Expand Down
21 changes: 21 additions & 0 deletions prisma/migrations/20231018133609_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Warnings:
- You are about to drop the column `storeId` on the `Mixing` table. All the data in the column will be lost.
- You are about to drop the column `storeId` on the `Recipe` table. All the data in the column will be lost.
*/
-- DropForeignKey
ALTER TABLE `Mixing` DROP FOREIGN KEY `Mixing_storeId_fkey`;

-- DropForeignKey
ALTER TABLE `Recipe` DROP FOREIGN KEY `Recipe_storeId_fkey`;

-- AlterTable
ALTER TABLE `Mixing` DROP COLUMN `storeId`;

-- AlterTable
ALTER TABLE `Recipe` DROP COLUMN `storeId`;

-- AlterTable
ALTER TABLE `Stock` ADD COLUMN `currentAmount` INTEGER NOT NULL DEFAULT 0;
92 changes: 0 additions & 92 deletions src/DTO/menu.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,101 +275,9 @@ export const updateMenuSchema = {
},
} as const;

export const createStockSchema = {
tags: ['menu'],
summary: '재료 생성',
headers: StoreAuthorizationHeader,
body: {
type: 'object',
required: ['name'],
properties: {
name: { type: 'string' },
amount: { type: 'number', nullable: true },
unit: { type: 'string', nullable: true },
price: { type: 'number', nullable: true },
},
},
response: {
201: {
type: 'object',
description: 'success response',
required: ['stockId'],
properties: {
stockId: { type: 'number' },
},
},
...errorSchema(E.NotFoundError, E.UserAuthorizationError, E.StoreAuthorizationError, E.NoAuthorizationInHeaderError)
},
} as const;

export const updateStockSchema = {
tags: ['menu'],
summary: '재료 수정',
headers: StoreAuthorizationHeader,
body: {
type: 'object',
required: ['id', 'name'],
properties: {
id: { type: 'number' },
name: { type: 'string' },
amount: { type: 'number', nullable: true },
unit: { type: 'string', nullable: true },
price: { type: 'number', nullable: true },
},
},
response: {
201: {
type: 'object',
description: 'success response',
required: ['stockId'],
properties: {
stockId: { type: 'number' },
},
},
...errorSchema(E.NotFoundError, E.UserAuthorizationError, E.StoreAuthorizationError, E.NoAuthorizationInHeaderError)
},
} as const;

export const searchStockSchema = {
tags: ['menu'],
summary: '재료 검색',
headers: StoreAuthorizationHeader,
querystring: {
type: 'object',
required: ['name'],
properties: {
name: { type: 'string' },
},
},
response: {
200: {
type: 'object',
description: 'success response',
required: ['stocks'],
properties: {
stocks: {
type: 'array',
items: {
type: 'object',
required: ['id', 'name'],
properties: {
id: { type: 'number' },
name: { type: 'string' }
},
},
},
},
},
...errorSchema(E.NotFoundError, E.UserAuthorizationError, E.StoreAuthorizationError, E.NoAuthorizationInHeaderError)
},
} as const;

export type getMenuListInterface = SchemaToInterface<typeof getMenuListSchema>&{Body: {storeId: number, userId: number}};
export type getMenuInterface = SchemaToInterface<typeof getMenuSchema>&{Body: {storeId: number, userId: number}};
export type getOptionListInterface = SchemaToInterface<typeof getOptionListSchema>&{Body: {storeId: number, userId: number}};
export type createCategoryInterface = SchemaToInterface<typeof createCategorySchema>&{Body: {storeId: number, userId: number}};
export type createMenuInterface = SchemaToInterface<typeof createMenuSchema>&{Body: {storeId: number, userId: number}};
export type updateMenuInterface = SchemaToInterface<typeof updateMenuSchema>&{Body: {storeId: number, userId: number}};
export type createStockInterface = SchemaToInterface<typeof createStockSchema>&{Body: {storeId: number, userId: number}};
export type updateStockInterface = SchemaToInterface<typeof updateStockSchema>&{Body: {storeId: number, userId: number}};
export type searchStockInterface = SchemaToInterface<typeof searchStockSchema>&{Body: {storeId: number, userId: number}};
3 changes: 1 addition & 2 deletions src/DTO/preOrder.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,13 @@ export const getPreOrderListSchema = {
headers: StoreAuthorizationHeader,
querystring: {
type: 'object',
required: ['page', 'count', 'date'],
required: ['page', 'count'],
properties: {
page: { type: 'number', default: 1 },
count: { type: 'number', default: 10 },
date: {
type: 'string',
format: 'date-time',
default: new Date().toISOString(),
},
},
},
Expand Down
Loading

0 comments on commit 7007e73

Please sign in to comment.