From f126b0976ebee36d48f94d2e8fb73a3782f026ce Mon Sep 17 00:00:00 2001 From: masaaki Date: Fri, 9 Jun 2023 07:34:49 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20146:=20API=20IF=E5=AE=9F=E8=A3=85?= =?UTF-8?q?=EF=BC=88accounts/me=E5=BE=A9=E6=B4=BB=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task1953: API IF実装(accounts/me復活)](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/1953) - accounts/meのIFを追加しました  ※別タスク「タスク 1837: API I/F実装」でレビューまでしてもらったものの、階層をアクセストークンに含める方針としたため削除としたものを復活させています。 - prettierがエラーを出力するようになっていたので、以下URLを参考にsettings.jsonを更新しています https://qiita.com/TellMin/items/a634149730b777e2e6d0 - このPull Requestでの対象外  ・openapi.jsonのL952とL2094については本PBI対象外になります ## レビューポイント - 特にありません ## UIの変更 - 無し ## 動作確認状況 - ローカルで確認 ## 補足 - 相談、参考資料などがあれば --- dictation_server/.vscode/settings.json | 3 +- dictation_server/src/api/odms/openapi.json | 80 ++++++++++++++++++- .../features/accounts/accounts.controller.ts | 39 +++++++++ .../src/features/accounts/types/types.ts | 10 +++ 4 files changed, 128 insertions(+), 4 deletions(-) diff --git a/dictation_server/.vscode/settings.json b/dictation_server/.vscode/settings.json index 802da8c..a3c8e93 100644 --- a/dictation_server/.vscode/settings.json +++ b/dictation_server/.vscode/settings.json @@ -17,5 +17,6 @@ "editor.formatOnType": true, "editor.renderWhitespace": "all", "editor.insertSpaces": false, - "editor.renderLineHighlight": "all" + "editor.renderLineHighlight": "all", + "prettier.prettierPath": "./node_modules/prettier" } \ No newline at end of file diff --git a/dictation_server/src/api/odms/openapi.json b/dictation_server/src/api/odms/openapi.json index 96d5315..69a0544 100644 --- a/dictation_server/src/api/odms/openapi.json +++ b/dictation_server/src/api/odms/openapi.json @@ -216,6 +216,62 @@ ] } }, + "/accounts/me": { + "get": { + "operationId": "getMyAccount", + "summary": "", + "description": "ログインしているユーザーのアカウント情報を取得します", + "parameters": [], + "responses": { + "200": { + "description": "成功時のレスポンス", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetMyAccountResponse" + } + } + } + }, + "400": { + "description": "該当アカウントがDBに存在しない場合", + "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": { "post": { "operationId": "confirmUser", @@ -893,7 +949,7 @@ "name": "paramName", "required": false, "in": "query", - "description": "JOB_NUMBER/STATUS/ENCRYPTION/AUTHOR_ID/FILE_NAME/FILE_LENGTH/FILE_SIZE/RECORDING_STARTED_DATE/RECORDING_FINISHED_DATE/UPLOAD_DATE/TRANSCRIPTION_STARTED_DATE/TRANSCRIPTION_FINISHED_DATE", + "description": "JOB_NUMBER/STATUS/ENCRYPTION/AUTHOR_ID/WORK_TYPE/FILE_NAME/FILE_LENGTH/FILE_SIZE/RECORDING_STARTED_DATE/RECORDING_FINISHED_DATE/UPLOAD_DATE/TRANSCRIPTION_STARTED_DATE/TRANSCRIPTION_FINISHED_DATE", "schema": { "type": "string" } @@ -1783,6 +1839,24 @@ }, "required": ["licenseSummaryInfo"] }, + "Account": { + "type": "object", + "properties": { + "accountId": { + "type": "number" + } + }, + "required": ["accountId"] + }, + "GetMyAccountResponse": { + "type": "object", + "properties": { + "account": { + "$ref": "#/components/schemas/Account" + } + }, + "required": ["account"] + }, "ConfirmRequest": { "type": "object", "properties": { @@ -1999,7 +2073,7 @@ }, "paramName": { "type": "string", - "description": "JOB_NUMBER/STATUS/ENCRYPTION/AUTHOR_ID/FILE_NAME/FILE_LENGTH/FILE_SIZE/RECORDING_STARTED_DATE/RECORDING_FINISHED_DATE/UPLOAD_DATE/TRANSCRIPTION_STARTED_DATE/TRANSCRIPTION_FINISHED_DATE" + "description": "JOB_NUMBER/STATUS/ENCRYPTION/AUTHOR_ID/WORK_TYPE/FILE_NAME/FILE_LENGTH/FILE_SIZE/RECORDING_STARTED_DATE/RECORDING_FINISHED_DATE/UPLOAD_DATE/TRANSCRIPTION_STARTED_DATE/TRANSCRIPTION_FINISHED_DATE" } }, "required": ["direction", "paramName"] @@ -2017,7 +2091,7 @@ }, "paramName": { "type": "string", - "description": "JOB_NUMBER/STATUS/ENCRYPTION/AUTHOR_ID/FILE_NAME/FILE_LENGTH/FILE_SIZE/RECORDING_STARTED_DATE/RECORDING_FINISHED_DATE/UPLOAD_DATE/TRANSCRIPTION_STARTED_DATE/TRANSCRIPTION_FINISHED_DATE" + "description": "JOB_NUMBER/STATUS/ENCRYPTION/AUTHOR_ID/WORK_TYPE/FILE_NAME/FILE_LENGTH/FILE_SIZE/RECORDING_STARTED_DATE/RECORDING_FINISHED_DATE/UPLOAD_DATE/TRANSCRIPTION_STARTED_DATE/TRANSCRIPTION_FINISHED_DATE" } }, "required": ["direction", "paramName"] diff --git a/dictation_server/src/features/accounts/accounts.controller.ts b/dictation_server/src/features/accounts/accounts.controller.ts index 9ca5acb..0e27f68 100644 --- a/dictation_server/src/features/accounts/accounts.controller.ts +++ b/dictation_server/src/features/accounts/accounts.controller.ts @@ -3,6 +3,7 @@ import { Controller, HttpStatus, Post, + Get, Req, UseGuards, } from '@nestjs/common'; @@ -20,6 +21,7 @@ import { CreateAccountResponse, GetLicenseSummaryRequest, GetLicenseSummaryResponse, + GetMyAccountResponse, } from './types/types'; import { USER_ROLES, ADMIN_ROLES } from '../../constants'; import { AuthGuard } from '../../common/guards/auth/authguards'; @@ -120,4 +122,41 @@ export class AccountsController { }, }; } + + @ApiResponse({ + status: HttpStatus.OK, + type: GetMyAccountResponse, + description: '成功時のレスポンス', + }) + @ApiResponse({ + status: HttpStatus.BAD_REQUEST, + description: '該当アカウントがDBに存在しない場合', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.UNAUTHORIZED, + description: '認証エラー', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.INTERNAL_SERVER_ERROR, + description: '想定外のサーバーエラー', + type: ErrorResponse, + }) + @ApiOperation({ + operationId: 'getMyAccount', + description: 'ログインしているユーザーのアカウント情報を取得します', + }) + @ApiBearerAuth() + @UseGuards(AuthGuard) + @UseGuards(RoleGuard.requireds({ roles: [ADMIN_ROLES.ADMIN] })) + @Get('me') + async getMyAccount(@Req() req: Request): Promise { + console.log(req.header('Authorization')); + return { + account: { + accountId: 1, + }, + }; + } } diff --git a/dictation_server/src/features/accounts/types/types.ts b/dictation_server/src/features/accounts/types/types.ts index 2a4089d..416af83 100644 --- a/dictation_server/src/features/accounts/types/types.ts +++ b/dictation_server/src/features/accounts/types/types.ts @@ -72,3 +72,13 @@ export class GetLicenseSummaryResponse { @ApiProperty({ type: LicenseSummaryInfo }) licenseSummaryInfo: LicenseSummaryInfo; } + +export class Account { + @ApiProperty() + accountId: number; +} + +export class GetMyAccountResponse { + @ApiProperty({ type: Account }) + account: Account; +}