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 {}