Merged PR 359: API IF実装

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

ライセンス注文キャンセルAPIのIFを実装しました。
※同ファイル内に未使用のGetAllocatableLicensesRequestのインポートが残っていたので、ついでに削除しています。本APIとは無関係です。

## レビューポイント
なし

## UIの変更
なし

## 動作確認状況
Swagger UIで確認済み

## 補足
なし
This commit is contained in:
oura.a 2023-08-25 05:19:34 +00:00
parent c10c8e8e8e
commit 9f2f163141
3 changed files with 117 additions and 1 deletions

View File

@ -2020,6 +2020,57 @@
"security": [{ "bearer": [] }]
}
},
"/licenses/orders/cancel": {
"post": {
"operationId": "cancelOrder",
"summary": "",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/CancelOrderRequest" }
}
}
},
"responses": {
"200": {
"description": "成功時のレスポンス",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/CancelOrderResponse" }
}
}
},
"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",
@ -2929,6 +2980,12 @@
},
"required": ["allocatableLicenses"]
},
"CancelOrderRequest": {
"type": "object",
"properties": { "poNumber": { "type": "string" } },
"required": ["poNumber"]
},
"CancelOrderResponse": { "type": "object", "properties": {} },
"RegisterRequest": {
"type": "object",
"properties": {

View File

@ -23,7 +23,8 @@ import {
ActivateCardLicensesResponse,
ActivateCardLicensesRequest,
GetAllocatableLicensesResponse,
GetAllocatableLicensesRequest,
CancelOrderRequest,
CancelOrderResponse,
} from './types/types';
import { Request } from 'express';
import { retrieveAuthorizationToken } from '../../common/http/helper';
@ -216,4 +217,54 @@ export class LicensesController {
return allocatableLicenses;
}
@ApiResponse({
status: HttpStatus.OK,
type: CancelOrderResponse,
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: 'cancelOrder',
description: 'ライセンス注文をキャンセルします',
})
@ApiBearerAuth()
@UseGuards(AuthGuard)
@UseGuards(
RoleGuard.requireds({
roles: [ADMIN_ROLES.ADMIN],
tiers: [TIERS.TIER2, TIERS.TIER3, TIERS.TIER4, TIERS.TIER5],
}),
)
@Post('/orders/cancel')
async cancelOrder(
@Req() req: Request,
@Body() body: CancelOrderRequest,
): Promise<CancelOrderResponse> {
const token = retrieveAuthorizationToken(req);
const payload = jwt.decode(token, { json: true }) as AccessToken;
const context = makeContext(payload.userId);
// 注文キャンセル処理(仮)
// await this.licensesService.cancelOrder(
// context,
// body.poNumber,
// );
return {};
}
}

View File

@ -55,6 +55,14 @@ export class GetAllocatableLicensesResponse {
allocatableLicenses: AllocatableLicenseInfo[];
}
export class CancelOrderRequest {
@ApiProperty()
@Matches(/^[A-Z0-9]+$/)
poNumber: string;
}
export class CancelOrderResponse {}
// ライセンス算出用に、その日の始まりの時刻0:00:00.000)の日付を取得する
export class DateWithZeroTime extends Date {
constructor(...args: any[]) {