From 45350d0ab84dd100df54b5f74d25d5b469013416 Mon Sep 17 00:00:00 2001 From: "makabe.t" Date: Mon, 16 Oct 2023 02:14:22 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20485:=20API=20IF=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task2610: API IF実装](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2610) - WorkTypeID削除API IFを実装し、OpenAPI定義を更新しました。 ## レビューポイント - パスは適切か - レスポンスは想定通りか ## UIの変更 - なし ## 動作確認状況 - ローカルで確認 --- dictation_server/src/api/odms/openapi.json | 54 +++++++++++++++++++ .../features/accounts/accounts.controller.ts | 43 +++++++++++++++ .../src/features/accounts/types/types.ts | 10 ++++ 3 files changed, 107 insertions(+) diff --git a/dictation_server/src/api/odms/openapi.json b/dictation_server/src/api/odms/openapi.json index 0fd0b8c..3887c30 100644 --- a/dictation_server/src/api/odms/openapi.json +++ b/dictation_server/src/api/odms/openapi.json @@ -990,6 +990,59 @@ "security": [{ "bearer": [] }] } }, + "/accounts/worktypes/{id}/delete": { + "post": { + "operationId": "deleteWorktype", + "summary": "", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "description": "Worktypeの内部ID", + "schema": { "type": "number" } + } + ], + "responses": { + "200": { + "description": "成功時のレスポンス", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeleteWorktypeResponse" + } + } + } + }, + "400": { + "description": "指定WorktypeIDが削除済み / 指定WorktypeIDがWorkflowで使用中", + "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": [] }] + } + }, "/accounts/worktypes/{id}/option-items": { "get": { "operationId": "getOptionItems", @@ -3706,6 +3759,7 @@ "required": ["worktypeId"] }, "UpdateWorktypeResponse": { "type": "object", "properties": {} }, + "DeleteWorktypeResponse": { "type": "object", "properties": {} }, "GetWorktypeOptionItem": { "type": "object", "properties": { diff --git a/dictation_server/src/features/accounts/accounts.controller.ts b/dictation_server/src/features/accounts/accounts.controller.ts index bb98487..dc33c56 100644 --- a/dictation_server/src/features/accounts/accounts.controller.ts +++ b/dictation_server/src/features/accounts/accounts.controller.ts @@ -66,6 +66,8 @@ import { GetAuthorsResponse, GetAccountInfoMinimalAccessRequest, GetAccountInfoMinimalAccessResponse, + DeleteWorktypeRequestParam, + DeleteWorktypeResponse, } from './types/types'; import { USER_ROLES, ADMIN_ROLES, TIERS } from '../../constants'; import { AuthGuard } from '../../common/guards/auth/authguards'; @@ -828,6 +830,47 @@ export class AccountsController { return {}; } + @Post('/worktypes/:id/delete') + @ApiResponse({ + status: HttpStatus.OK, + type: DeleteWorktypeResponse, + description: '成功時のレスポンス', + }) + @ApiResponse({ + status: HttpStatus.BAD_REQUEST, + description: '指定WorktypeIDが削除済み / 指定WorktypeIDがWorkflowで使用中', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.UNAUTHORIZED, + description: '認証エラー', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.INTERNAL_SERVER_ERROR, + description: '想定外のサーバーエラー', + type: ErrorResponse, + }) + @ApiOperation({ operationId: 'deleteWorktype' }) + @ApiBearerAuth() + @UseGuards(AuthGuard) + @UseGuards(RoleGuard.requireds({ roles: [ADMIN_ROLES.ADMIN] })) + async deleteWorktype( + @Req() req: Request, + @Param() param: DeleteWorktypeRequestParam, + ): Promise { + const { id } = param; + const token = retrieveAuthorizationToken(req); + const { userId } = jwt.decode(token, { json: true }) as AccessToken; + + const context = makeContext(userId); + + console.log(context.trackingId); + console.log(`worktypeId: ${id}`); + + return {}; + } + @Get('/worktypes/:id/option-items') @ApiResponse({ status: HttpStatus.OK, diff --git a/dictation_server/src/features/accounts/types/types.ts b/dictation_server/src/features/accounts/types/types.ts index 47f6536..b3ebbb5 100644 --- a/dictation_server/src/features/accounts/types/types.ts +++ b/dictation_server/src/features/accounts/types/types.ts @@ -497,6 +497,16 @@ export class UpdateWorktypeRequestParam { id: number; } +export class DeleteWorktypeRequestParam { + @ApiProperty({ description: 'Worktypeの内部ID' }) + @Type(() => Number) + @IsInt() + @Min(0) + id: number; +} + +export class DeleteWorktypeResponse {} + export class PostActiveWorktypeRequest { @ApiProperty({ required: false,