From 01a653015bfd6a5cd1dc16e562e31383c141a32d Mon Sep 17 00:00:00 2001 From: masaaki Date: Mon, 26 Jun 2023 06:00:25 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20180:=20API=20IF=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task1989: API IF実装](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/1989) - カードライセンス発行APIのIFを追加しました ## レビューポイント - 特になし ## UIの変更 - 無し ## 動作確認状況 - ローカルで確認済 ## 補足 - 相談、参考資料などがあれば --- dictation_server/src/api/odms/openapi.json | 59 +++++++++++++++++++ .../features/licenses/licenses.controller.ts | 43 +++++++++++++- .../src/features/licenses/types/types.ts | 13 ++++ 3 files changed, 114 insertions(+), 1 deletion(-) diff --git a/dictation_server/src/api/odms/openapi.json b/dictation_server/src/api/odms/openapi.json index 17762a1..d20932f 100644 --- a/dictation_server/src/api/odms/openapi.json +++ b/dictation_server/src/api/odms/openapi.json @@ -1431,6 +1431,53 @@ "security": [{ "bearer": [] }] } }, + "/licenses/cards": { + "post": { + "operationId": "issueCardLicenses", + "summary": "", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IssueCardLicensesRequest" + } + } + } + }, + "responses": { + "200": { + "description": "成功時のレスポンス", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IssueCardLicensesResponse" + } + } + } + }, + "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", @@ -2092,6 +2139,18 @@ "required": ["poNumber", "orderCount"] }, "CreateOrdersResponse": { "type": "object", "properties": {} }, + "IssueCardLicensesRequest": { + "type": "object", + "properties": { "createCount": { "type": "number" } }, + "required": ["createCount"] + }, + "IssueCardLicensesResponse": { + "type": "object", + "properties": { + "cardLicenseKeys": { "type": "array", "items": { "type": "string" } } + }, + "required": ["cardLicenseKeys"] + }, "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 9f7018e..6c6f507 100644 --- a/dictation_server/src/features/licenses/licenses.controller.ts +++ b/dictation_server/src/features/licenses/licenses.controller.ts @@ -14,7 +14,12 @@ import { } from '@nestjs/swagger'; import { ErrorResponse } from '../../common/error/types/types'; import { LicensesService } from './licenses.service'; -import { CreateOrdersResponse, CreateOrdersRequest } from './types/types'; +import { + CreateOrdersResponse, + CreateOrdersRequest, + IssueCardLicensesResponse, + IssueCardLicensesRequest, +} from './types/types'; import { Request } from 'express'; import { retrieveAuthorizationToken } from '../../common/http/helper'; import { AccessToken } from '../../common/token'; @@ -71,4 +76,40 @@ export class LicensesController { ); return {}; } + + @ApiResponse({ + status: HttpStatus.OK, + type: IssueCardLicensesResponse, + description: '成功時のレスポンス', + }) + @ApiResponse({ + status: HttpStatus.UNAUTHORIZED, + description: '認証エラー', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.INTERNAL_SERVER_ERROR, + description: '想定外のサーバーエラー', + type: ErrorResponse, + }) + @ApiOperation({ operationId: 'issueCardLicenses' }) + @ApiBearerAuth() + @UseGuards(AuthGuard) + @Post('/cards') + async issueCardLicenses( + @Req() req: Request, + @Body() body: IssueCardLicensesRequest, + ): Promise { + console.log(req.header('Authorization')); + console.log(body); + + // レスポンス値のサンプル + const cardLicenseKeys: string[] = [ + '3S5F9P7L4X1J6G2M8Q0Y', + '9R7K2U1H5V3B6M0D8W4C', + '2L0X5Y9P6U7Q1G4C3W8N', + ]; + + return { cardLicenseKeys }; + } } diff --git a/dictation_server/src/features/licenses/types/types.ts b/dictation_server/src/features/licenses/types/types.ts index 8fe94aa..78e7734 100644 --- a/dictation_server/src/features/licenses/types/types.ts +++ b/dictation_server/src/features/licenses/types/types.ts @@ -14,3 +14,16 @@ export class CreateOrdersRequest { } export class CreateOrdersResponse {} + +export class IssueCardLicensesRequest { + @ApiProperty() + @IsInt() + @Min(1) + @Max(9999) + createCount: number; +} + +export class IssueCardLicensesResponse { + @ApiProperty() + cardLicenseKeys: string[]; +}