diff --git a/dictation_server/src/api/odms/openapi.json b/dictation_server/src/api/odms/openapi.json index 03e67a3..7a7f262 100644 --- a/dictation_server/src/api/odms/openapi.json +++ b/dictation_server/src/api/odms/openapi.json @@ -783,6 +783,59 @@ }, "tags": ["accounts"], "security": [{ "bearer": [] }] + }, + "post": { + "operationId": "createWorktype", + "summary": "", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateWorktypesRequest" + } + } + } + }, + "responses": { + "200": { + "description": "成功時のレスポンス", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateWorktypeResponse" + } + } + } + }, + "400": { + "description": "WorktypeIDが重複 / WorktypeIDが空 / WorktypeIDが20件登録済み", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ErrorResponse" } + } + } + }, + "401": { + "description": "認証エラー", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ErrorResponse" } + } + } + }, + "500": { + "description": "想定外のサーバーエラー", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ErrorResponse" } + } + } + } + }, + "tags": ["accounts"], + "security": [{ "bearer": [] }] } }, "/users/confirm": { @@ -2701,6 +2754,19 @@ }, "required": ["workTypes"] }, + "CreateWorktypesRequest": { + "type": "object", + "properties": { + "worktypeId": { + "type": "string", + "minLength": 1, + "description": "WorktypeID" + }, + "description": { "type": "string", "description": "Worktypeの説明" } + }, + "required": ["worktypeId"] + }, + "CreateWorktypeResponse": { "type": "object", "properties": {} }, "ConfirmRequest": { "type": "object", "properties": { "token": { "type": "string" } }, diff --git a/dictation_server/src/features/accounts/accounts.controller.ts b/dictation_server/src/features/accounts/accounts.controller.ts index 037eb12..41929c8 100644 --- a/dictation_server/src/features/accounts/accounts.controller.ts +++ b/dictation_server/src/features/accounts/accounts.controller.ts @@ -43,6 +43,8 @@ import { CancelIssueRequest, CancelIssueResponse, GetWorkTypesResponse, + CreateWorktypeResponse, + CreateWorktypesRequest, } from './types/types'; import { USER_ROLES, ADMIN_ROLES, TIERS } from '../../constants'; import { AuthGuard } from '../../common/guards/auth/authguards'; @@ -673,4 +675,45 @@ export class AccountsController { ], }; } + + @Post('/worktypes') + @ApiResponse({ + status: HttpStatus.OK, + type: CreateWorktypeResponse, + description: '成功時のレスポンス', + }) + @ApiResponse({ + status: HttpStatus.BAD_REQUEST, + description: 'WorktypeIDが重複 / WorktypeIDが空 / WorktypeIDが20件登録済み', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.UNAUTHORIZED, + description: '認証エラー', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.INTERNAL_SERVER_ERROR, + description: '想定外のサーバーエラー', + type: ErrorResponse, + }) + @ApiOperation({ operationId: 'createWorktype' }) + @ApiBearerAuth() + @UseGuards(AuthGuard) + @UseGuards(RoleGuard.requireds({ roles: [ADMIN_ROLES.ADMIN] })) + async createWorktype( + @Req() req: Request, + @Body() body: CreateWorktypesRequest, + ): Promise { + const { worktypeId, description } = body; + const token = retrieveAuthorizationToken(req); + const { userId } = jwt.decode(token, { json: true }) as AccessToken; + + const context = makeContext(userId); + console.log(context.trackingId); + console.log(worktypeId); + console.log(description); + + return {}; + } } diff --git a/dictation_server/src/features/accounts/types/types.ts b/dictation_server/src/features/accounts/types/types.ts index df60fcb..3d58765 100644 --- a/dictation_server/src/features/accounts/types/types.ts +++ b/dictation_server/src/features/accounts/types/types.ts @@ -346,3 +346,13 @@ export class GetWorkTypesResponse { @ApiProperty({ type: [WorkType] }) workTypes: WorkType[]; } + +export class CreateWorktypesRequest { + @ApiProperty({ minLength: 1, description: 'WorktypeID' }) + @MinLength(1) + worktypeId: string; + @ApiProperty({ description: 'Worktypeの説明', required: false }) + description?: string; +} + +export class CreateWorktypeResponse {}