diff --git a/dictation_server/src/app.module.ts b/dictation_server/src/app.module.ts index b2b6929..36e33c8 100644 --- a/dictation_server/src/app.module.ts +++ b/dictation_server/src/app.module.ts @@ -28,6 +28,7 @@ import { FilesService } from './features/files/files.service'; import { TasksService } from './features/tasks/tasks.service'; import { TasksController } from './features/tasks/tasks.controller'; import { TasksModule } from './features/tasks/tasks.module'; +import { LicensesModule } from './features/licenses/licenses.module'; @Module({ imports: [ @@ -65,6 +66,7 @@ import { TasksModule } from './features/tasks/tasks.module'; }), NotificationModule, NotificationhubModule, + LicensesModule, ], controllers: [ HealthController, diff --git a/dictation_server/src/features/licenses/licenses.controller.spec.ts b/dictation_server/src/features/licenses/licenses.controller.spec.ts new file mode 100644 index 0000000..520fa20 --- /dev/null +++ b/dictation_server/src/features/licenses/licenses.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { LicensesController } from './licenses.controller'; + +describe('LicensesController', () => { + let controller: LicensesController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [LicensesController], + }).compile(); + + controller = module.get(LicensesController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/dictation_server/src/features/licenses/licenses.controller.ts b/dictation_server/src/features/licenses/licenses.controller.ts new file mode 100644 index 0000000..05f5084 --- /dev/null +++ b/dictation_server/src/features/licenses/licenses.controller.ts @@ -0,0 +1,49 @@ +import { Body, Controller, HttpStatus, Post, Req } from '@nestjs/common'; +import { + ApiResponse, + ApiTags, + ApiOperation, + ApiBearerAuth, +} from '@nestjs/swagger'; +import { ErrorResponse } from '../../common/error/types/types'; +import { LicensesService } from './licenses.service'; +import { CreateOrdersResponse, CreateOrdersRequest } from './types/types'; +import { Request } from 'express'; + +@ApiTags('licenses') +@Controller('licenses') +export class LicensesController { + constructor(private readonly licensesService: LicensesService) {} + + @ApiResponse({ + status: HttpStatus.OK, + type: CreateOrdersResponse, + description: '成功時のレスポンス', + }) + @ApiResponse({ + status: HttpStatus.BAD_REQUEST, + description: '同一PONumberの注文がすでに存在する場合など', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.UNAUTHORIZED, + description: '認証エラー', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.INTERNAL_SERVER_ERROR, + description: '想定外のサーバーエラー', + type: ErrorResponse, + }) + @ApiOperation({ operationId: 'signup' }) + @ApiBearerAuth() + @Post('/orders') + async createOrders( + @Req() req: Request, + @Body() body: CreateOrdersRequest, + ): Promise { + console.log(req.header('Authorization')); + console.log(body); + return {}; + } +} diff --git a/dictation_server/src/features/licenses/licenses.module.ts b/dictation_server/src/features/licenses/licenses.module.ts new file mode 100644 index 0000000..a223cf9 --- /dev/null +++ b/dictation_server/src/features/licenses/licenses.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { LicensesController } from './licenses.controller'; +import { LicensesService } from './licenses.service'; + +@Module({ + controllers: [LicensesController], + providers: [LicensesService], +}) +export class LicensesModule {} diff --git a/dictation_server/src/features/licenses/licenses.service.spec.ts b/dictation_server/src/features/licenses/licenses.service.spec.ts new file mode 100644 index 0000000..7288d3d --- /dev/null +++ b/dictation_server/src/features/licenses/licenses.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { LicensesService } from './licenses.service'; + +describe('LicensesService', () => { + let service: LicensesService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [LicensesService], + }).compile(); + + service = module.get(LicensesService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/dictation_server/src/features/licenses/licenses.service.ts b/dictation_server/src/features/licenses/licenses.service.ts new file mode 100644 index 0000000..4677a8f --- /dev/null +++ b/dictation_server/src/features/licenses/licenses.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class LicensesService {} diff --git a/dictation_server/src/features/licenses/types/types.ts b/dictation_server/src/features/licenses/types/types.ts new file mode 100644 index 0000000..c34f0d1 --- /dev/null +++ b/dictation_server/src/features/licenses/types/types.ts @@ -0,0 +1,11 @@ +import { ApiProperty } from '@nestjs/swagger'; + +export class CreateOrdersRequest { + @ApiProperty() + poNumber: string; + + @ApiProperty() + orderCount: number; +} + +export class CreateOrdersResponse {}