From 4a68653c696c0222fa17314ebd39e4f1d2b2d673 Mon Sep 17 00:00:00 2001 From: "maruyama.t" Date: Wed, 20 Sep 2023 05:35:55 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20423:=20API=20IF=E5=AE=9F=E8=A3=85?= =?UTF-8?q?(=E3=82=A2=E3=82=AB=E3=82=A6=E3=83=B3=E3=83=88=E5=89=8A?= =?UTF-8?q?=E9=99=A4API)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task2668: API IF実装](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2668) - 元PBI or タスクへのリンク(内容・目的などはそちらにあるはず) - 何をどう変更したか、追加したライブラリなど - このPull Requestでの対象/対象外 - 影響範囲(他の機能にも影響があるか) 特になし ## レビューポイント メソッド名が適切か。 ## UIの変更 なし ## 動作確認状況 - ローカルで確認 ## 補足 - 相談、参考資料などがあれば --- dictation_server/src/api/odms/openapi.json | 54 ++++++++++++++++++- .../features/accounts/accounts.controller.ts | 46 +++++++++++++++- .../src/features/accounts/types/types.ts | 7 +++ 3 files changed, 105 insertions(+), 2 deletions(-) diff --git a/dictation_server/src/api/odms/openapi.json b/dictation_server/src/api/odms/openapi.json index 52874b9..d91cfc5 100644 --- a/dictation_server/src/api/odms/openapi.json +++ b/dictation_server/src/api/odms/openapi.json @@ -226,7 +226,7 @@ "security": [{ "bearer": [] }] }, "post": { - "operationId": "me", + "operationId": "updateAccountInfo", "summary": "", "parameters": [], "requestBody": { @@ -1181,6 +1181,51 @@ "security": [{ "bearer": [] }] } }, + "/accounts/delete": { + "post": { + "operationId": "deleteAccount", + "summary": "", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/DeleteAccountRequest" } + } + } + }, + "responses": { + "200": { + "description": "成功時のレスポンス", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateAccountInfoResponse" + } + } + } + }, + "401": { + "description": "認証エラー", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ErrorResponse" } + } + } + }, + "500": { + "description": "DBアクセスに失敗しログインできる状態で処理が終了した場合", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ErrorResponse" } + } + } + } + }, + "tags": ["accounts"], + "security": [{ "bearer": [] }] + } + }, "/users/confirm": { "post": { "operationId": "confirmUser", @@ -3399,6 +3444,13 @@ "required": ["delegationPermission", "primaryAdminUserId"] }, "UpdateAccountInfoResponse": { "type": "object", "properties": {} }, + "DeleteAccountRequest": { + "type": "object", + "properties": { + "accountId": { "type": "number", "description": "アカウントID" } + }, + "required": ["accountId"] + }, "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 bda8d6d..c33085d 100644 --- a/dictation_server/src/features/accounts/accounts.controller.ts +++ b/dictation_server/src/features/accounts/accounts.controller.ts @@ -60,6 +60,8 @@ import { PostActiveWorktypeResponse, UpdateAccountInfoRequest, UpdateAccountInfoResponse, + DeleteAccountRequest, + DeleteAccountResponse, } from './types/types'; import { USER_ROLES, ADMIN_ROLES, TIERS } from '../../constants'; import { AuthGuard } from '../../common/guards/auth/authguards'; @@ -983,7 +985,7 @@ export class AccountsController { description: '想定外のサーバーエラー', type: ErrorResponse, }) - @ApiOperation({ operationId: 'me' }) + @ApiOperation({ operationId: 'updateAccountInfo' }) @ApiBearerAuth() @UseGuards(AuthGuard) @UseGuards( @@ -1017,4 +1019,46 @@ export class AccountsController { return; } + + @Post('/delete') + @ApiResponse({ + status: HttpStatus.OK, + type: UpdateAccountInfoResponse, + description: '成功時のレスポンス', + }) + @ApiResponse({ + status: HttpStatus.UNAUTHORIZED, + description: '認証エラー', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.INTERNAL_SERVER_ERROR, + description: 'DBアクセスに失敗しログインできる状態で処理が終了した場合', + type: ErrorResponse, + }) + @ApiOperation({ operationId: 'deleteAccount' }) + @ApiBearerAuth() + @UseGuards(AuthGuard) + @UseGuards( + RoleGuard.requireds({ + roles: [ADMIN_ROLES.ADMIN], + }), + ) + async deleteAccount( + @Req() req: Request, + @Body() body: DeleteAccountRequest, + ): Promise { + const { accountId } = body; + const token = retrieveAuthorizationToken(req); + const { userId } = jwt.decode(token, { json: true }) as AccessToken; + const context = makeContext(userId); + + /* TODO 仮実装、別タスクで実装する + await this.accountService.deleteAccount( + context, + accountId + ); + */ + return; + } } diff --git a/dictation_server/src/features/accounts/types/types.ts b/dictation_server/src/features/accounts/types/types.ts index 16d2ed8..62b45a7 100644 --- a/dictation_server/src/features/accounts/types/types.ts +++ b/dictation_server/src/features/accounts/types/types.ts @@ -558,3 +558,10 @@ export class UpdateAccountInfoRequest { } export class UpdateAccountInfoResponse {} + +export class DeleteAccountRequest { + @ApiProperty({ description: 'アカウントID' }) + accountId: number; +} + +export class DeleteAccountResponse {}