Merged PR 485: API IF実装
## 概要 [Task2610: API IF実装](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2610) - WorkTypeID削除API IFを実装し、OpenAPI定義を更新しました。 ## レビューポイント - パスは適切か - レスポンスは想定通りか ## UIの変更 - なし ## 動作確認状況 - ローカルで確認
This commit is contained in:
parent
d258d569f7
commit
45350d0ab8
@ -990,6 +990,59 @@
|
||||
"security": [{ "bearer": [] }]
|
||||
}
|
||||
},
|
||||
"/accounts/worktypes/{id}/delete": {
|
||||
"post": {
|
||||
"operationId": "deleteWorktype",
|
||||
"summary": "",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"in": "path",
|
||||
"description": "Worktypeの内部ID",
|
||||
"schema": { "type": "number" }
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "成功時のレスポンス",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/DeleteWorktypeResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "指定WorktypeIDが削除済み / 指定WorktypeIDがWorkflowで使用中",
|
||||
"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": [] }]
|
||||
}
|
||||
},
|
||||
"/accounts/worktypes/{id}/option-items": {
|
||||
"get": {
|
||||
"operationId": "getOptionItems",
|
||||
@ -3706,6 +3759,7 @@
|
||||
"required": ["worktypeId"]
|
||||
},
|
||||
"UpdateWorktypeResponse": { "type": "object", "properties": {} },
|
||||
"DeleteWorktypeResponse": { "type": "object", "properties": {} },
|
||||
"GetWorktypeOptionItem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@ -66,6 +66,8 @@ import {
|
||||
GetAuthorsResponse,
|
||||
GetAccountInfoMinimalAccessRequest,
|
||||
GetAccountInfoMinimalAccessResponse,
|
||||
DeleteWorktypeRequestParam,
|
||||
DeleteWorktypeResponse,
|
||||
} from './types/types';
|
||||
import { USER_ROLES, ADMIN_ROLES, TIERS } from '../../constants';
|
||||
import { AuthGuard } from '../../common/guards/auth/authguards';
|
||||
@ -828,6 +830,47 @@ export class AccountsController {
|
||||
return {};
|
||||
}
|
||||
|
||||
@Post('/worktypes/:id/delete')
|
||||
@ApiResponse({
|
||||
status: HttpStatus.OK,
|
||||
type: DeleteWorktypeResponse,
|
||||
description: '成功時のレスポンス',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: HttpStatus.BAD_REQUEST,
|
||||
description: '指定WorktypeIDが削除済み / 指定WorktypeIDがWorkflowで使用中',
|
||||
type: ErrorResponse,
|
||||
})
|
||||
@ApiResponse({
|
||||
status: HttpStatus.UNAUTHORIZED,
|
||||
description: '認証エラー',
|
||||
type: ErrorResponse,
|
||||
})
|
||||
@ApiResponse({
|
||||
status: HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
description: '想定外のサーバーエラー',
|
||||
type: ErrorResponse,
|
||||
})
|
||||
@ApiOperation({ operationId: 'deleteWorktype' })
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(AuthGuard)
|
||||
@UseGuards(RoleGuard.requireds({ roles: [ADMIN_ROLES.ADMIN] }))
|
||||
async deleteWorktype(
|
||||
@Req() req: Request,
|
||||
@Param() param: DeleteWorktypeRequestParam,
|
||||
): Promise<DeleteWorktypeResponse> {
|
||||
const { id } = param;
|
||||
const token = retrieveAuthorizationToken(req);
|
||||
const { userId } = jwt.decode(token, { json: true }) as AccessToken;
|
||||
|
||||
const context = makeContext(userId);
|
||||
|
||||
console.log(context.trackingId);
|
||||
console.log(`worktypeId: ${id}`);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
@Get('/worktypes/:id/option-items')
|
||||
@ApiResponse({
|
||||
status: HttpStatus.OK,
|
||||
|
||||
@ -497,6 +497,16 @@ export class UpdateWorktypeRequestParam {
|
||||
id: number;
|
||||
}
|
||||
|
||||
export class DeleteWorktypeRequestParam {
|
||||
@ApiProperty({ description: 'Worktypeの内部ID' })
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
id: number;
|
||||
}
|
||||
|
||||
export class DeleteWorktypeResponse {}
|
||||
|
||||
export class PostActiveWorktypeRequest {
|
||||
@ApiProperty({
|
||||
required: false,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user