From 2263412120242a005f271d80fc0aa555dc03bc9d Mon Sep 17 00:00:00 2001 From: "oura.a" Date: Wed, 5 Jul 2023 02:36:27 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20195:=20API=20IF=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task2094: API IF実装](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2094) -カードライセンス取り込みAPIのIFを実装。 ## レビューポイント - なし ## UIの変更 - なし ## 動作確認状況 - ローカルでビルドエラーが出ないことを確認 ## 補足 - なし --- dictation_server/src/api/odms/openapi.json | 61 +++++++++++++++++++ .../features/licenses/licenses.controller.ts | 38 ++++++++++++ .../src/features/licenses/types/types.ts | 11 +++- 3 files changed, 109 insertions(+), 1 deletion(-) diff --git a/dictation_server/src/api/odms/openapi.json b/dictation_server/src/api/odms/openapi.json index 4e8baa2..845329c 100644 --- a/dictation_server/src/api/odms/openapi.json +++ b/dictation_server/src/api/odms/openapi.json @@ -1479,6 +1479,61 @@ "security": [{ "bearer": [] }] } }, + "/licenses/cards/activate": { + "post": { + "operationId": "activateCardLicenses", + "summary": "", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ActivateCardLicensesRequest" + } + } + } + }, + "responses": { + "200": { + "description": "成功時のレスポンス", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ActivateCardLicensesResponse" + } + } + } + }, + "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": ["licenses"], + "security": [{ "bearer": [] }] + } + }, "/notification/register": { "post": { "operationId": "register", @@ -2152,6 +2207,12 @@ }, "required": ["cardLicenseKeys"] }, + "ActivateCardLicensesRequest": { + "type": "object", + "properties": { "cardLicenseKey": { "type": "string" } }, + "required": ["cardLicenseKey"] + }, + "ActivateCardLicensesResponse": { "type": "object", "properties": {} }, "RegisterRequest": { "type": "object", "properties": { diff --git a/dictation_server/src/features/licenses/licenses.controller.ts b/dictation_server/src/features/licenses/licenses.controller.ts index 9a79486..2a70711 100644 --- a/dictation_server/src/features/licenses/licenses.controller.ts +++ b/dictation_server/src/features/licenses/licenses.controller.ts @@ -20,6 +20,8 @@ import { CreateOrdersRequest, IssueCardLicensesResponse, IssueCardLicensesRequest, + ActivateCardLicensesResponse, + ActivateCardLicensesRequest, } from './types/types'; import { Request } from 'express'; import { retrieveAuthorizationToken } from '../../common/http/helper'; @@ -123,4 +125,40 @@ export class LicensesController { return cardLicenseKeys; } + + @ApiResponse({ + status: HttpStatus.OK, + type: ActivateCardLicensesResponse, + 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: 'activateCardLicenses' }) + @ApiBearerAuth() + @UseGuards(AuthGuard) + @UseGuards(RoleGuard.requireds({ roles: [ADMIN_ROLES.ADMIN] })) + @Post('/cards/activate') + async activateCardLicenses( + @Req() req: Request, + @Body() body: ActivateCardLicensesRequest, + ): Promise { + console.log(req.header('Authorization')); + console.log(body); + + return {}; + } } diff --git a/dictation_server/src/features/licenses/types/types.ts b/dictation_server/src/features/licenses/types/types.ts index 78e7734..92de038 100644 --- a/dictation_server/src/features/licenses/types/types.ts +++ b/dictation_server/src/features/licenses/types/types.ts @@ -1,5 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; -import { IsInt, Matches, Max, Min } from 'class-validator'; +import { IsInt, Matches, Max, Min, Length } from 'class-validator'; export class CreateOrdersRequest { @ApiProperty() @@ -27,3 +27,12 @@ export class IssueCardLicensesResponse { @ApiProperty() cardLicenseKeys: string[]; } + +export class ActivateCardLicensesRequest { + @ApiProperty() + @Matches(/^[A-Z0-9]+$/) + @Length(20, 20) + cardLicenseKey: string; +} + +export class ActivateCardLicensesResponse {}