Merged PR 369: API IF実装

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

- ワークタイプ一覧取得APIのIFを実装し、openapi.jsonを更新しました

## レビューポイント
- パスは適切か
- プロパティに不足はないか
  - 返却値にidを追加しています

## UIの変更
- なし
## 動作確認状況
- ローカルで確認
This commit is contained in:
makabe.t 2023-08-30 06:53:58 +00:00
parent e82f66e32a
commit a9d5d926ba
3 changed files with 105 additions and 0 deletions

View File

@ -748,6 +748,43 @@
"security": [{ "bearer": [] }] "security": [{ "bearer": [] }]
} }
}, },
"/accounts/worktypes": {
"get": {
"operationId": "getWorktypes",
"summary": "",
"parameters": [],
"responses": {
"200": {
"description": "成功時のレスポンス",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetWorkTypesResponse"
}
}
}
},
"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": { "/users/confirm": {
"post": { "post": {
"operationId": "confirmUser", "operationId": "confirmUser",
@ -2645,6 +2682,25 @@
"required": ["orderedAccountId", "poNumber"] "required": ["orderedAccountId", "poNumber"]
}, },
"CancelIssueResponse": { "type": "object", "properties": {} }, "CancelIssueResponse": { "type": "object", "properties": {} },
"WorkType": {
"type": "object",
"properties": {
"id": { "type": "number", "description": "WorkTypeのID" },
"workTypeId": { "type": "string", "description": "WorkTypeID" },
"description": { "type": "string", "description": "WorkTypeの説明" }
},
"required": ["id", "workTypeId"]
},
"GetWorkTypesResponse": {
"type": "object",
"properties": {
"workTypes": {
"type": "array",
"items": { "$ref": "#/components/schemas/WorkType" }
}
},
"required": ["workTypes"]
},
"ConfirmRequest": { "ConfirmRequest": {
"type": "object", "type": "object",
"properties": { "token": { "type": "string" } }, "properties": { "token": { "type": "string" } },

View File

@ -42,6 +42,7 @@ import {
UpdateTypistGroupRequestParam, UpdateTypistGroupRequestParam,
CancelIssueRequest, CancelIssueRequest,
CancelIssueResponse, CancelIssueResponse,
GetWorkTypesResponse,
} from './types/types'; } from './types/types';
import { USER_ROLES, ADMIN_ROLES, TIERS } from '../../constants'; import { USER_ROLES, ADMIN_ROLES, TIERS } from '../../constants';
import { AuthGuard } from '../../common/guards/auth/authguards'; import { AuthGuard } from '../../common/guards/auth/authguards';
@ -638,4 +639,38 @@ export class AccountsController {
// ); // );
return {}; return {};
} }
@Get('/worktypes')
@ApiResponse({
status: HttpStatus.OK,
type: GetWorkTypesResponse,
description: '成功時のレスポンス',
})
@ApiResponse({
status: HttpStatus.UNAUTHORIZED,
description: '認証エラー',
type: ErrorResponse,
})
@ApiResponse({
status: HttpStatus.INTERNAL_SERVER_ERROR,
description: '想定外のサーバーエラー',
type: ErrorResponse,
})
@ApiOperation({ operationId: 'getWorktypes' })
@ApiBearerAuth()
@UseGuards(AuthGuard)
@UseGuards(RoleGuard.requireds({ roles: [ADMIN_ROLES.ADMIN] }))
async getWorktypes(@Req() req: Request): Promise<GetWorkTypesResponse> {
const token = retrieveAuthorizationToken(req);
const { userId } = jwt.decode(token, { json: true }) as AccessToken;
const context = makeContext(userId);
console.log(context.trackingId);
return {
workTypes: [
{ id: 1, workTypeId: 'workTypeId', description: 'description' },
],
};
}
} }

View File

@ -332,3 +332,17 @@ export class CancelIssueRequest {
} }
export class CancelIssueResponse {} export class CancelIssueResponse {}
export class WorkType {
@ApiProperty({ description: 'WorkTypeのID' })
id: number;
@ApiProperty({ description: 'WorkTypeID' })
workTypeId: string;
@ApiProperty({ description: 'WorkTypeの説明', required: false })
description?: string;
}
export class GetWorkTypesResponse {
@ApiProperty({ type: [WorkType] })
workTypes: WorkType[];
}