From 9f7de83ae7a3a8eb9ff7c949701b574b3ac8cbff Mon Sep 17 00:00:00 2001 From: "oura.a" Date: Tue, 12 Sep 2023 06:27:27 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20401:=20API-IF=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task2600: API-IF実装](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2600) アカウント設定APIのIFを実装しました。 ## レビューポイント なし ## UIの変更 なし ## 動作確認状況 ローカルのswaggerUIで確認済み ## 補足 なし --- dictation_server/src/api/odms/openapi.json | 81 +++++++++++++++++++ .../features/accounts/accounts.controller.ts | 58 +++++++++++++ .../src/features/accounts/types/types.ts | 15 ++++ 3 files changed, 154 insertions(+) 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 {}