diff --git a/dictation_server/src/api/odms/openapi.json b/dictation_server/src/api/odms/openapi.json index 9c048cc..2ce696b 100644 --- a/dictation_server/src/api/odms/openapi.json +++ b/dictation_server/src/api/odms/openapi.json @@ -696,6 +696,58 @@ "tags": ["accounts"] } }, + "/accounts/issue/cancel": { + "post": { + "operationId": "cancelIssue", + "summary": "", + "description": "ライセンス発行をキャンセルします", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/CancelIssueRequest" } + } + } + }, + "responses": { + "200": { + "description": "成功時のレスポンス", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/CancelIssueResponse" } + } + } + }, + "400": { + "description": "対象注文のステータスが発行済以外/発行日から15日以降/ライセンスをユーザに割り当てている", + "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": ["accounts"], + "security": [{ "bearer": [] }] + } + }, "/users/confirm": { "post": { "operationId": "confirmUser", @@ -2138,6 +2190,7 @@ "post": { "operationId": "cancelOrder", "summary": "", + "description": "ライセンス注文をキャンセルします", "parameters": [], "requestBody": { "required": true, @@ -2572,6 +2625,18 @@ }, "required": ["dealers"] }, + "CancelIssueRequest": { + "type": "object", + "properties": { + "orderedAccountId": { + "type": "number", + "description": "注文元アカウントID" + }, + "poNumber": { "type": "string", "description": "POナンバー" } + }, + "required": ["orderedAccountId", "poNumber"] + }, + "CancelIssueResponse": { "type": "object", "properties": {} }, "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 a16086e..b74c9a3 100644 --- a/dictation_server/src/features/accounts/accounts.controller.ts +++ b/dictation_server/src/features/accounts/accounts.controller.ts @@ -40,6 +40,8 @@ import { GetTypistGroupRequest, UpdateTypistGroupRequest, UpdateTypistGroupRequestParam, + CancelIssueRequest, + CancelIssueResponse, } from './types/types'; import { USER_ROLES, ADMIN_ROLES, TIERS } from '../../constants'; import { AuthGuard } from '../../common/guards/auth/authguards'; @@ -568,4 +570,56 @@ export class AccountsController { async getDealers(): Promise { return await this.accountService.getDealers(); } + + @Post('/issue/cancel') + @ApiResponse({ + status: HttpStatus.OK, + type: CancelIssueResponse, + description: '成功時のレスポンス', + }) + @ApiResponse({ + status: HttpStatus.BAD_REQUEST, + description: + '対象注文のステータスが発行済以外/発行日から15日以降/ライセンスをユーザに割り当てている', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.UNAUTHORIZED, + description: '認証エラー', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.INTERNAL_SERVER_ERROR, + description: '想定外のサーバーエラー', + type: ErrorResponse, + }) + @ApiOperation({ + operationId: 'cancelIssue', + description: 'ライセンス発行をキャンセルします', + }) + @ApiBearerAuth() + @UseGuards(AuthGuard) + @UseGuards( + RoleGuard.requireds({ + roles: [ADMIN_ROLES.ADMIN], + tiers: [TIERS.TIER1, TIERS.TIER2], + }), + ) + async cancelIssue( + @Req() req: Request, + @Body() body: CancelIssueRequest, + ): Promise { + const token = retrieveAuthorizationToken(req); + const payload = jwt.decode(token, { json: true }) as AccessToken; + + const context = makeContext(payload.userId); + + // TODO: 発行キャンセル処理(仮)。API実装のタスク(2498)で本実装 + // await this.accountService.cancelIssue( + // context, + // body.poNumber, + // body.orderedAccountId, + // ); + return {}; + } } diff --git a/dictation_server/src/features/accounts/types/types.ts b/dictation_server/src/features/accounts/types/types.ts index f87ec15..98d0b6d 100644 --- a/dictation_server/src/features/accounts/types/types.ts +++ b/dictation_server/src/features/accounts/types/types.ts @@ -320,3 +320,14 @@ export class GetDealersResponse { @ApiProperty({ type: [Dealer] }) dealers: Dealer[]; } + +export class CancelIssueRequest { + @ApiProperty({ description: '注文元アカウントID' }) + orderedAccountId: number; + + @ApiProperty({ description: 'POナンバー' }) + @Matches(/^[A-Z0-9]+$/) + poNumber: string; +} + +export class CancelIssueResponse {}