diff --git a/dictation_server/src/api/odms/openapi.json b/dictation_server/src/api/odms/openapi.json index ae10150..96bc1c7 100644 --- a/dictation_server/src/api/odms/openapi.json +++ b/dictation_server/src/api/odms/openapi.json @@ -224,6 +224,59 @@ }, "tags": ["accounts"], "security": [{ "bearer": [] }] + }, + "post": { + "operationId": "me", + "summary": "", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateAccountInfoRequest" + } + } + } + }, + "responses": { + "200": { + "description": "成功時のレスポンス", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateAccountInfoResponse" + } + } + } + }, + "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/typists": { @@ -3108,6 +3161,34 @@ }, "required": ["total", "partners"] }, + "UpdateAccountInfoRequest": { + "type": "object", + "properties": { + "parentAccountId": { + "type": "number", + "description": "親アカウントのID" + }, + "delegationPermission": { + "type": "number", + "description": "代行操作許可" + }, + "primaryAdminUserId": { + "type": "number", + "description": "プライマリ管理者ID" + }, + "secondryAdminUserId": { + "type": "number", + "description": "セカンダリ管理者ID" + } + }, + "required": [ + "parentAccountId", + "delegationPermission", + "primaryAdminUserId", + "secondryAdminUserId" + ] + }, + "UpdateAccountInfoResponse": { "type": "object", "properties": {} }, "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 f386fcf..da94293 100644 --- a/dictation_server/src/features/accounts/accounts.controller.ts +++ b/dictation_server/src/features/accounts/accounts.controller.ts @@ -56,6 +56,8 @@ import { UpdateOptionItemsResponse, UpdateOptionItemsRequestParam, UpdateOptionItemsRequest, + UpdateAccountInfoRequest, + UpdateAccountInfoResponse, } from './types/types'; import { USER_ROLES, @@ -916,4 +918,60 @@ export class AccountsController { return response; } + + @Post('/me') + @ApiResponse({ + status: HttpStatus.OK, + type: UpdateAccountInfoResponse, + 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: 'me' }) + @ApiBearerAuth() + @UseGuards(AuthGuard) + @UseGuards( + RoleGuard.requireds({ + roles: [ADMIN_ROLES.ADMIN], + }), + ) + async updateAccountInfo( + @Req() req: Request, + @Body() body: UpdateAccountInfoRequest, + ): Promise { + const { + parentAccountId, + delegationPermission, + primaryAdminUserId, + secondryAdminUserId, + } = body; + const token = retrieveAuthorizationToken(req); + const { userId } = jwt.decode(token, { json: true }) as AccessToken; + + const context = makeContext(userId); + // 仮。API実装で本実装 + // await this.accountService.updateAccountInfo( + // context, + // userId, + // parentAccountId, + // delegationPermission, + // primaryAdminUserId, + // secondryAdminUserId, + // ); + + return; + } } diff --git a/dictation_server/src/features/accounts/types/types.ts b/dictation_server/src/features/accounts/types/types.ts index d907538..4a01470 100644 --- a/dictation_server/src/features/accounts/types/types.ts +++ b/dictation_server/src/features/accounts/types/types.ts @@ -495,3 +495,18 @@ export type PartnerInfoFromDb = { primaryAccountExternalId: string; dealerManagement: boolean; }; + +export class UpdateAccountInfoRequest { + @ApiProperty({ description: '親アカウントのID' }) + parentAccountId: number; + @ApiProperty({ description: '代行操作許可' }) + delegationPermission: boolean; + @ApiProperty({ description: 'プライマリ管理者ID' }) + @IsOptional() + primaryAdminUserId?: number; + @ApiProperty({ description: 'セカンダリ管理者ID' }) + @IsOptional() + secondryAdminUserId?: number; +} + +export class UpdateAccountInfoResponse {}