Merged PR 374: API IF実装
## 概要 [Task2521: API IF実装](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2521) - Worktype追加API IFを実装しOpenAPI定義を更新しました。 ## レビューポイント - パスは認識通りか - パラメータは適切か ## UIの変更 - なし ## 動作確認状況 - ローカルで確認
This commit is contained in:
parent
9a67c513d9
commit
e77d8d8af0
@ -783,6 +783,59 @@
|
||||
},
|
||||
"tags": ["accounts"],
|
||||
"security": [{ "bearer": [] }]
|
||||
},
|
||||
"post": {
|
||||
"operationId": "createWorktype",
|
||||
"summary": "",
|
||||
"parameters": [],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/CreateWorktypesRequest"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "成功時のレスポンス",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/CreateWorktypeResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "WorktypeIDが重複 / WorktypeIDが空 / WorktypeIDが20件登録済み",
|
||||
"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": {
|
||||
@ -2701,6 +2754,19 @@
|
||||
},
|
||||
"required": ["workTypes"]
|
||||
},
|
||||
"CreateWorktypesRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"worktypeId": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"description": "WorktypeID"
|
||||
},
|
||||
"description": { "type": "string", "description": "Worktypeの説明" }
|
||||
},
|
||||
"required": ["worktypeId"]
|
||||
},
|
||||
"CreateWorktypeResponse": { "type": "object", "properties": {} },
|
||||
"ConfirmRequest": {
|
||||
"type": "object",
|
||||
"properties": { "token": { "type": "string" } },
|
||||
|
||||
@ -43,6 +43,8 @@ import {
|
||||
CancelIssueRequest,
|
||||
CancelIssueResponse,
|
||||
GetWorkTypesResponse,
|
||||
CreateWorktypeResponse,
|
||||
CreateWorktypesRequest,
|
||||
} from './types/types';
|
||||
import { USER_ROLES, ADMIN_ROLES, TIERS } from '../../constants';
|
||||
import { AuthGuard } from '../../common/guards/auth/authguards';
|
||||
@ -673,4 +675,45 @@ export class AccountsController {
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
@Post('/worktypes')
|
||||
@ApiResponse({
|
||||
status: HttpStatus.OK,
|
||||
type: CreateWorktypeResponse,
|
||||
description: '成功時のレスポンス',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: HttpStatus.BAD_REQUEST,
|
||||
description: 'WorktypeIDが重複 / WorktypeIDが空 / WorktypeIDが20件登録済み',
|
||||
type: ErrorResponse,
|
||||
})
|
||||
@ApiResponse({
|
||||
status: HttpStatus.UNAUTHORIZED,
|
||||
description: '認証エラー',
|
||||
type: ErrorResponse,
|
||||
})
|
||||
@ApiResponse({
|
||||
status: HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
description: '想定外のサーバーエラー',
|
||||
type: ErrorResponse,
|
||||
})
|
||||
@ApiOperation({ operationId: 'createWorktype' })
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(AuthGuard)
|
||||
@UseGuards(RoleGuard.requireds({ roles: [ADMIN_ROLES.ADMIN] }))
|
||||
async createWorktype(
|
||||
@Req() req: Request,
|
||||
@Body() body: CreateWorktypesRequest,
|
||||
): Promise<CreateWorktypeResponse> {
|
||||
const { worktypeId, description } = body;
|
||||
const token = retrieveAuthorizationToken(req);
|
||||
const { userId } = jwt.decode(token, { json: true }) as AccessToken;
|
||||
|
||||
const context = makeContext(userId);
|
||||
console.log(context.trackingId);
|
||||
console.log(worktypeId);
|
||||
console.log(description);
|
||||
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,3 +346,13 @@ export class GetWorkTypesResponse {
|
||||
@ApiProperty({ type: [WorkType] })
|
||||
workTypes: WorkType[];
|
||||
}
|
||||
|
||||
export class CreateWorktypesRequest {
|
||||
@ApiProperty({ minLength: 1, description: 'WorktypeID' })
|
||||
@MinLength(1)
|
||||
worktypeId: string;
|
||||
@ApiProperty({ description: 'Worktypeの説明', required: false })
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export class CreateWorktypeResponse {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user