Merged PR 180: API IF実装

## 概要
[Task1989: API IF実装](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/1989)

- カードライセンス発行APIのIFを追加しました

## レビューポイント
- 特になし

## UIの変更
- 無し

## 動作確認状況
- ローカルで確認済

## 補足
- 相談、参考資料などがあれば
This commit is contained in:
masaaki 2023-06-26 06:00:25 +00:00
parent 4fb982bf8c
commit 01a653015b
3 changed files with 114 additions and 1 deletions

View File

@ -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": {

View File

@ -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<IssueCardLicensesResponse> {
console.log(req.header('Authorization'));
console.log(body);
// レスポンス値のサンプル
const cardLicenseKeys: string[] = [
'3S5F9P7L4X1J6G2M8Q0Y',
'9R7K2U1H5V3B6M0D8W4C',
'2L0X5Y9P6U7Q1G4C3W8N',
];
return { cardLicenseKeys };
}
}

View File

@ -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[];
}