diff --git a/dictation_server/src/api/odms/openapi.json b/dictation_server/src/api/odms/openapi.json index 4c8b812..df4a888 100644 --- a/dictation_server/src/api/odms/openapi.json +++ b/dictation_server/src/api/odms/openapi.json @@ -651,6 +651,59 @@ "security": [{ "bearer": [] }] } }, + "/accounts/typist-groups/{typistGroupId}/delete": { + "post": { + "operationId": "deleteTypistGroup", + "summary": "", + "description": "ログインしているユーザーのアカウント配下でIDで指定されたタイピストグループを削除します", + "parameters": [ + { + "name": "typistGroupId", + "required": true, + "in": "path", + "schema": { "type": "number" } + } + ], + "responses": { + "200": { + "description": "成功時のレスポンス", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeleteTypistGroupResponse" + } + } + } + }, + "400": { + "description": "ルーティングルールに設定されている / タスクの割り当て候補に設定されている / 削除済み", + "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/partner": { "post": { "operationId": "createPartnerAccount", @@ -3823,6 +3876,7 @@ }, "required": ["typistGroupName", "typistIds"] }, + "DeleteTypistGroupResponse": { "type": "object", "properties": {} }, "CreatePartnerAccountRequest": { "type": "object", "properties": { diff --git a/dictation_server/src/features/accounts/accounts.controller.ts b/dictation_server/src/features/accounts/accounts.controller.ts index e8a8ecd..7ab72b5 100644 --- a/dictation_server/src/features/accounts/accounts.controller.ts +++ b/dictation_server/src/features/accounts/accounts.controller.ts @@ -71,6 +71,8 @@ import { DeleteWorktypeResponse, GetCompanyNameRequest, GetCompanyNameResponse, + DeleteTypistGroupRequestParam, + DeleteTypistGroupResponse, } from './types/types'; import { USER_ROLES, ADMIN_ROLES, TIERS } from '../../constants'; import { AuthGuard } from '../../common/guards/auth/authguards'; @@ -755,6 +757,86 @@ export class AccountsController { return {}; } + @ApiResponse({ + status: HttpStatus.OK, + type: DeleteTypistGroupResponse, + description: '成功時のレスポンス', + }) + @ApiResponse({ + status: HttpStatus.BAD_REQUEST, + description: + 'ルーティングルールに設定されている / タスクの割り当て候補に設定されている / 削除済み', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.UNAUTHORIZED, + description: '認証エラー', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.INTERNAL_SERVER_ERROR, + description: '想定外のサーバーエラー', + type: ErrorResponse, + }) + @ApiOperation({ + operationId: 'deleteTypistGroup', + description: + 'ログインしているユーザーのアカウント配下でIDで指定されたタイピストグループを削除します', + }) + @ApiBearerAuth() + @UseGuards(AuthGuard) + @UseGuards( + RoleGuard.requireds({ roles: [ADMIN_ROLES.ADMIN], delegation: true }), + ) + @Post('typist-groups/:typistGroupId/delete') + async deleteTypistGroup( + @Req() req: Request, + @Param() param: DeleteTypistGroupRequestParam, + ): Promise { + const { typistGroupId } = param; + + // アクセストークン取得 + + const accessToken = retrieveAuthorizationToken(req); + if (!accessToken) { + throw new HttpException( + makeErrorResponse('E000107'), + HttpStatus.UNAUTHORIZED, + ); + } + + const ip = retrieveIp(req); + if (!ip) { + throw new HttpException( + makeErrorResponse('E000401'), + HttpStatus.UNAUTHORIZED, + ); + } + + const requestId = retrieveRequestId(req); + if (!requestId) { + throw new HttpException( + makeErrorResponse('E000501'), + HttpStatus.INTERNAL_SERVER_ERROR, + ); + } + const decodedAccessToken = jwt.decode(accessToken, { json: true }); + if (!decodedAccessToken) { + throw new HttpException( + makeErrorResponse('E000101'), + HttpStatus.UNAUTHORIZED, + ); + } + const { userId } = decodedAccessToken as AccessToken; + + const context = makeContext(userId, requestId); + this.logger.log(`[${context.getTrackingId()}] ip : ${ip}`); + + // TODO: 削除処理 + + return {}; + } + @Post('partner') @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 2648785..d604419 100644 --- a/dictation_server/src/features/accounts/types/types.ts +++ b/dictation_server/src/features/accounts/types/types.ts @@ -120,6 +120,14 @@ export class UpdateTypistGroupRequestParam { @Min(1) typistGroupId: number; } +export class DeleteTypistGroupRequestParam { + @ApiProperty() + @Type(() => Number) + @IsInt() + @Min(1) + typistGroupId: number; +} + export class CreatePartnerAccountRequest { @ApiProperty() @MaxLength(255) @@ -481,6 +489,8 @@ export class CreateTypistGroupResponse {} export class UpdateTypistGroupResponse {} +export class DeleteTypistGroupResponse {} + export class CreatePartnerAccountResponse {} export class PartnerLicenseInfo {