diff --git a/dictation_server/src/api/odms/openapi.json b/dictation_server/src/api/odms/openapi.json index 1f5fa4c..31aaed9 100644 --- a/dictation_server/src/api/odms/openapi.json +++ b/dictation_server/src/api/odms/openapi.json @@ -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" } }, diff --git a/dictation_server/src/features/accounts/accounts.controller.ts b/dictation_server/src/features/accounts/accounts.controller.ts index ca4089e..0f4aade 100644 --- a/dictation_server/src/features/accounts/accounts.controller.ts +++ b/dictation_server/src/features/accounts/accounts.controller.ts @@ -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 { + 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; + } } diff --git a/dictation_server/src/features/accounts/types/types.ts b/dictation_server/src/features/accounts/types/types.ts index d7082b6..8aa6179 100644 --- a/dictation_server/src/features/accounts/types/types.ts +++ b/dictation_server/src/features/accounts/types/types.ts @@ -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[]; +}