From a9d5d926bab965c2b9f149c2c6113a94c89482fc Mon Sep 17 00:00:00 2001 From: "makabe.t" Date: Wed, 30 Aug 2023 06:53:58 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20369:=20API=20IF=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task2504: API IF実装](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2504) - ワークタイプ一覧取得APIのIFを実装し、openapi.jsonを更新しました ## レビューポイント - パスは適切か - プロパティに不足はないか - 返却値にidを追加しています ## UIの変更 - なし ## 動作確認状況 - ローカルで確認 --- dictation_server/src/api/odms/openapi.json | 56 +++++++++++++++++++ .../features/accounts/accounts.controller.ts | 35 ++++++++++++ .../src/features/accounts/types/types.ts | 14 +++++ 3 files changed, 105 insertions(+) diff --git a/dictation_server/src/api/odms/openapi.json b/dictation_server/src/api/odms/openapi.json index b8e5b6c..03e67a3 100644 --- a/dictation_server/src/api/odms/openapi.json +++ b/dictation_server/src/api/odms/openapi.json @@ -748,6 +748,43 @@ "security": [{ "bearer": [] }] } }, + "/accounts/worktypes": { + "get": { + "operationId": "getWorktypes", + "summary": "", + "parameters": [], + "responses": { + "200": { + "description": "成功時のレスポンス", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetWorkTypesResponse" + } + } + } + }, + "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": { "post": { "operationId": "confirmUser", @@ -2645,6 +2682,25 @@ "required": ["orderedAccountId", "poNumber"] }, "CancelIssueResponse": { "type": "object", "properties": {} }, + "WorkType": { + "type": "object", + "properties": { + "id": { "type": "number", "description": "WorkTypeのID" }, + "workTypeId": { "type": "string", "description": "WorkTypeID" }, + "description": { "type": "string", "description": "WorkTypeの説明" } + }, + "required": ["id", "workTypeId"] + }, + "GetWorkTypesResponse": { + "type": "object", + "properties": { + "workTypes": { + "type": "array", + "items": { "$ref": "#/components/schemas/WorkType" } + } + }, + "required": ["workTypes"] + }, "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 390fc48..037eb12 100644 --- a/dictation_server/src/features/accounts/accounts.controller.ts +++ b/dictation_server/src/features/accounts/accounts.controller.ts @@ -42,6 +42,7 @@ import { UpdateTypistGroupRequestParam, CancelIssueRequest, CancelIssueResponse, + GetWorkTypesResponse, } from './types/types'; import { USER_ROLES, ADMIN_ROLES, TIERS } from '../../constants'; import { AuthGuard } from '../../common/guards/auth/authguards'; @@ -638,4 +639,38 @@ export class AccountsController { // ); return {}; } + + @Get('/worktypes') + @ApiResponse({ + status: HttpStatus.OK, + type: GetWorkTypesResponse, + description: '成功時のレスポンス', + }) + @ApiResponse({ + status: HttpStatus.UNAUTHORIZED, + description: '認証エラー', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.INTERNAL_SERVER_ERROR, + description: '想定外のサーバーエラー', + type: ErrorResponse, + }) + @ApiOperation({ operationId: 'getWorktypes' }) + @ApiBearerAuth() + @UseGuards(AuthGuard) + @UseGuards(RoleGuard.requireds({ roles: [ADMIN_ROLES.ADMIN] })) + async getWorktypes(@Req() req: Request): Promise { + const token = retrieveAuthorizationToken(req); + const { userId } = jwt.decode(token, { json: true }) as AccessToken; + + const context = makeContext(userId); + console.log(context.trackingId); + + return { + workTypes: [ + { id: 1, workTypeId: 'workTypeId', description: 'description' }, + ], + }; + } } diff --git a/dictation_server/src/features/accounts/types/types.ts b/dictation_server/src/features/accounts/types/types.ts index 0b1074d..df60fcb 100644 --- a/dictation_server/src/features/accounts/types/types.ts +++ b/dictation_server/src/features/accounts/types/types.ts @@ -332,3 +332,17 @@ export class CancelIssueRequest { } export class CancelIssueResponse {} + +export class WorkType { + @ApiProperty({ description: 'WorkTypeのID' }) + id: number; + @ApiProperty({ description: 'WorkTypeID' }) + workTypeId: string; + @ApiProperty({ description: 'WorkTypeの説明', required: false }) + description?: string; +} + +export class GetWorkTypesResponse { + @ApiProperty({ type: [WorkType] }) + workTypes: WorkType[]; +}