From c19adde702712ff2f50d6bc836bc76ee64457969 Mon Sep 17 00:00:00 2001 From: "maruyama.t" Date: Tue, 11 Jul 2023 02:29:08 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20221:=20API=20IF=E5=AE=9F=E8=A3=85?= =?UTF-8?q?(=E3=83=91=E3=83=BC=E3=83=88=E3=83=8A=E3=83=BC=E3=82=A2?= =?UTF-8?q?=E3=82=AB=E3=82=A6=E3=83=B3=E3=83=88=E8=BF=BD=E5=8A=A0API?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task2153: API IF実装](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2153) - 元PBI or タスクへのリンク(内容・目的などはそちらにあるはず) - 何をどう変更したか、追加したライブラリなど パートナーアカウント追加APIのIFを追加しました ## レビューポイント 特になし ## UIの変更 無し ## 動作確認状況 ローカルで確認済 ## 補足 - 相談、参考資料などがあれば --- dictation_server/src/api/odms/openapi.json | 71 +++++++++++++++++++ .../features/accounts/accounts.controller.ts | 45 ++++++++++++ .../src/features/accounts/types/types.ts | 18 +++++ 3 files changed, 134 insertions(+) diff --git a/dictation_server/src/api/odms/openapi.json b/dictation_server/src/api/odms/openapi.json index 8ed0a96..ba26e83 100644 --- a/dictation_server/src/api/odms/openapi.json +++ b/dictation_server/src/api/odms/openapi.json @@ -300,6 +300,61 @@ "security": [{ "bearer": [] }] } }, + "/accounts/partner": { + "post": { + "operationId": "createPartnerAccount", + "summary": "", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreatePartnerAccountRequest" + } + } + } + }, + "responses": { + "200": { + "description": "成功時のレスポンス", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreatePartnerAccountResponse" + } + } + } + }, + "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": [] }] + } + }, "/users/confirm": { "post": { "operationId": "confirmUser", @@ -1743,6 +1798,22 @@ }, "required": ["typistGroups"] }, + "CreatePartnerAccountRequest": { + "type": "object", + "properties": { + "companyName": { "type": "string" }, + "country": { + "type": "string", + "description": "国名(ISO 3166-1 alpha-2)", + "minLength": 2, + "maxLength": 2 + }, + "adminName": { "type": "string" }, + "eMail": { "type": "string" } + }, + "required": ["companyName", "country", "adminName", "eMail"] + }, + "CreatePartnerAccountResponse": { "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 9a1ce1d..5cf5a22 100644 --- a/dictation_server/src/features/accounts/accounts.controller.ts +++ b/dictation_server/src/features/accounts/accounts.controller.ts @@ -25,6 +25,8 @@ import { GetMyAccountResponse, GetTypistGroupsResponse, GetTypistsResponse, + CreatePartnerAccountRequest, + CreatePartnerAccountResponse, } from './types/types'; import { USER_ROLES, ADMIN_ROLES } from '../../constants'; import { AuthGuard } from '../../common/guards/auth/authguards'; @@ -237,4 +239,47 @@ export class AccountsController { return { typistGroups }; } + + @Post('partner') + @ApiResponse({ + status: HttpStatus.OK, + type: CreatePartnerAccountResponse, + description: '成功時のレスポンス', + }) + @ApiResponse({ + status: HttpStatus.UNAUTHORIZED, + description: '認証エラー', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.BAD_REQUEST, + description: '登録済みユーザーからの登録など', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.INTERNAL_SERVER_ERROR, + description: '想定外のサーバーエラー', + type: ErrorResponse, + }) + @ApiOperation({ operationId: 'createPartnerAccount' }) + @ApiBearerAuth() + @UseGuards(AuthGuard) + @UseGuards(RoleGuard.requireds({ roles: [ADMIN_ROLES.ADMIN] })) + async createPartnerAccount( + @Req() req: Request, + @Body() body: CreatePartnerAccountRequest, + ): Promise { + console.log(req.header('Authorization')); + console.log(body); + const { companyName, country, eMail, adminName } = body; + + /*await this.accountService.createPartnerAccount( + companyName, + country, + eMail, + adminName, + );*/ + + return {}; + } } diff --git a/dictation_server/src/features/accounts/types/types.ts b/dictation_server/src/features/accounts/types/types.ts index f7dd877..416d73a 100644 --- a/dictation_server/src/features/accounts/types/types.ts +++ b/dictation_server/src/features/accounts/types/types.ts @@ -117,3 +117,21 @@ export class GetTypistGroupsResponse { @ApiProperty({ type: [TypistGroup] }) typistGroups: TypistGroup[]; } + +export class CreatePartnerAccountRequest { + @ApiProperty() + companyName: string; + @ApiProperty({ + description: '国名(ISO 3166-1 alpha-2)', + minLength: 2, + maxLength: 2, + }) + country: string; + @ApiProperty() + adminName: string; + @ApiProperty() + @IsEmail() + eMail: string; +} + +export class CreatePartnerAccountResponse {} \ No newline at end of file