Merged PR 267: API-IF実装(注文履歴)
## 概要 [Task2274: API-IF実装(注文履歴)](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2274) - 元PBI or タスクへのリンク(内容・目的などはそちらにあるはず) - 何をどう変更したか、追加したライブラリなど 注文履歴取得のAPI-IF実装とopenapi.jsonの生成 - このPull Requestでの対象/対象外 controller以下の処理については [タスク 2261: API実装(注文履歴取得API)](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/OMDSDictation/_sprints/taskboard/OMDSDictation%20%E3%83%81%E3%83%BC%E3%83%A0/OMDSDictation/%E3%82%B9%E3%83%97%E3%83%AA%E3%83%B3%E3%83%88%2013-2?workitem=2261) で実装のため対象外 - 影響範囲(他の機能にも影響があるか) 新規機能のため影響なし ## レビューポイント - エラーレスポンスに過不足ないか ## UIの変更 なし ## 動作確認状況 - ローカルで確認(Postmanでcontrollerの処理が呼べることを確認) ## 補足 - 相談、参考資料などがあれば
This commit is contained in:
parent
080e05975e
commit
42db870af0
@ -402,6 +402,53 @@
|
||||
"security": [{ "bearer": [] }]
|
||||
}
|
||||
},
|
||||
"/accounts/order-histories": {
|
||||
"post": {
|
||||
"operationId": "getOrderHistories",
|
||||
"summary": "",
|
||||
"parameters": [],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/GetOrderHistoriesRequest"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "成功時のレスポンス",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/GetPartnerLicensesResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"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",
|
||||
@ -1917,6 +1964,15 @@
|
||||
},
|
||||
"required": ["total", "ownPartnerLicense", "childrenPartnerLicenses"]
|
||||
},
|
||||
"GetOrderHistoriesRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"limit": { "type": "number" },
|
||||
"offset": { "type": "number" },
|
||||
"accountId": { "type": "number" }
|
||||
},
|
||||
"required": ["limit", "offset", "accountId"]
|
||||
},
|
||||
"ConfirmRequest": {
|
||||
"type": "object",
|
||||
"properties": { "token": { "type": "string" } },
|
||||
|
||||
@ -28,6 +28,9 @@ import {
|
||||
CreatePartnerAccountResponse,
|
||||
GetPartnerLicensesRequest,
|
||||
GetPartnerLicensesResponse,
|
||||
GetOrderHistoriesRequest,
|
||||
GetOrderHistoriesResponce,
|
||||
LicenseOrder,
|
||||
} from './types/types';
|
||||
import { USER_ROLES, ADMIN_ROLES, TIERS } from '../../constants';
|
||||
import { AuthGuard } from '../../common/guards/auth/authguards';
|
||||
@ -35,6 +38,7 @@ import { RoleGuard } from '../../common/guards/role/roleguards';
|
||||
import { retrieveAuthorizationToken } from '../../common/http/helper';
|
||||
import { AccessToken } from '../../common/token';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { LicenseHistory } from '../../repositories/licenses/entity/license.entity';
|
||||
|
||||
@ApiTags('accounts')
|
||||
@Controller('accounts')
|
||||
@ -325,4 +329,58 @@ export class AccountsController {
|
||||
|
||||
return getPartnerLicensesResponse;
|
||||
}
|
||||
|
||||
@Post('order-histories')
|
||||
@ApiResponse({
|
||||
status: HttpStatus.OK,
|
||||
type: GetPartnerLicensesResponse,
|
||||
description: '成功時のレスポンス',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: HttpStatus.UNAUTHORIZED,
|
||||
description: '認証エラー',
|
||||
type: ErrorResponse,
|
||||
})
|
||||
@ApiResponse({
|
||||
status: HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
description: '想定外のサーバーエラー',
|
||||
type: ErrorResponse,
|
||||
})
|
||||
@ApiOperation({ operationId: 'getOrderHistories' })
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(AuthGuard)
|
||||
@UseGuards(
|
||||
RoleGuard.requireds({
|
||||
roles: [ADMIN_ROLES.ADMIN],
|
||||
}),
|
||||
)
|
||||
async getOrderHistories(
|
||||
@Req() req: Request,
|
||||
@Body() body: GetOrderHistoriesRequest,
|
||||
): Promise<GetOrderHistoriesResponce> {
|
||||
const { limit, offset, accountId } = body;
|
||||
|
||||
// XXX Task2261で本実装する
|
||||
const currentDate = new Date();
|
||||
const orderHistories: LicenseOrder[] = [];
|
||||
const orderHistory: LicenseOrder = {
|
||||
orderDate: currentDate,
|
||||
issueDate: currentDate,
|
||||
numberOfOrder: 50,
|
||||
poNumber: 'PO001',
|
||||
status: 'Issue Requesting',
|
||||
};
|
||||
orderHistories.push(orderHistory);
|
||||
const getOrderHistoriesResponce = new GetOrderHistoriesResponce();
|
||||
getOrderHistoriesResponce.total = 1;
|
||||
getOrderHistoriesResponce.orderHistories = orderHistories;
|
||||
/* =
|
||||
await this.accountService.getOrderHistoriesResponce(
|
||||
limit,
|
||||
offset,
|
||||
accountId,
|
||||
);
|
||||
*/
|
||||
return getOrderHistoriesResponce;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsEmail, IsInt, IsOptional } from 'class-validator';
|
||||
import { IsEmail, IsInt, IsOptional, Min } from 'class-validator';
|
||||
|
||||
export class CreateAccountRequest {
|
||||
@ApiProperty()
|
||||
@ -192,3 +192,35 @@ export type PartnerLicenseInfoForRepository = Omit<
|
||||
PartnerLicenseInfo,
|
||||
'shortage'
|
||||
>;
|
||||
|
||||
export class GetOrderHistoriesRequest {
|
||||
@ApiProperty({ description: '取得件数' })
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
limit: number;
|
||||
@ApiProperty({ description: '開始位置' })
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
offset: number;
|
||||
@ApiProperty({ description: 'アカウントID' })
|
||||
accountId: number;
|
||||
}
|
||||
|
||||
export class LicenseOrder {
|
||||
@ApiProperty({ description: '注文日付' })
|
||||
orderDate: Date;
|
||||
@ApiProperty({ description: '発行日付' })
|
||||
issueDate: Date;
|
||||
@ApiProperty({ description: '注文数' })
|
||||
numberOfOrder: number;
|
||||
@ApiProperty({ description: 'POナンバー' })
|
||||
poNumber: String;
|
||||
@ApiProperty({ description: '注文状態' })
|
||||
status: String;
|
||||
}
|
||||
export class GetOrderHistoriesResponce {
|
||||
@ApiProperty({ description: '合計件数' })
|
||||
total: number;
|
||||
@ApiProperty({ type: [LicenseOrder] })
|
||||
orderHistories: LicenseOrder[];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user