diff --git a/dictation_server/src/api/odms/openapi.json b/dictation_server/src/api/odms/openapi.json index 4e50b27..935d920 100644 --- a/dictation_server/src/api/odms/openapi.json +++ b/dictation_server/src/api/odms/openapi.json @@ -1219,7 +1219,7 @@ }, "/accounts/delete": { "post": { - "operationId": "deleteAccount", + "operationId": "deleteAccountAndData", "summary": "", "parameters": [], "requestBody": { @@ -2976,6 +2976,68 @@ "security": [{ "bearer": [] }] } }, + "/workflows/{workflowId}": { + "post": { + "operationId": "updateWorkflow", + "summary": "", + "description": "アカウント内のワークフローを編集します", + "parameters": [ + { + "name": "workflowId", + "required": true, + "in": "path", + "description": "ワークフローの内部ID", + "schema": { "type": "number" } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/UpdateWorkflowRequest" } + } + } + }, + "responses": { + "200": { + "description": "成功時のレスポンス", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateWorkflowResponse" + } + } + } + }, + "400": { + "description": "パラメータ不正エラー", + "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": ["workflows"], + "security": [{ "bearer": [] }] + } + }, "/notification/register": { "post": { "operationId": "register", @@ -4251,7 +4313,7 @@ "CreateWorkflowsRequest": { "type": "object", "properties": { - "authorId": { "type": "number", "description": "Authornの内部ID" }, + "authorId": { "type": "number", "description": "Authorの内部ID" }, "worktypeId": { "type": "number", "description": "Worktypeの内部ID" }, "templateId": { "type": "number", @@ -4267,6 +4329,25 @@ "required": ["authorId", "typists"] }, "CreateWorkflowsResponse": { "type": "object", "properties": {} }, + "UpdateWorkflowRequest": { + "type": "object", + "properties": { + "authorId": { "type": "number", "description": "Authorの内部ID" }, + "worktypeId": { "type": "number", "description": "Worktypeの内部ID" }, + "templateId": { + "type": "number", + "description": "テンプレートの内部ID" + }, + "typists": { + "description": "ルーティング候補のタイピストユーザー/タイピストグループ", + "minItems": 1, + "type": "array", + "items": { "$ref": "#/components/schemas/WorkflowTypist" } + } + }, + "required": ["authorId", "typists"] + }, + "UpdateWorkflowResponse": { "type": "object", "properties": {} }, "RegisterRequest": { "type": "object", "properties": { diff --git a/dictation_server/src/features/workflows/types/types.ts b/dictation_server/src/features/workflows/types/types.ts index 3bd82f9..d5a99e8 100644 --- a/dictation_server/src/features/workflows/types/types.ts +++ b/dictation_server/src/features/workflows/types/types.ts @@ -50,7 +50,7 @@ export class WorkflowTypist { } export class CreateWorkflowsRequest { - @ApiProperty({ description: 'Authornの内部ID' }) + @ApiProperty({ description: 'Authorの内部ID' }) @Type(() => Number) @IsInt() @Min(0) @@ -79,3 +79,42 @@ export class CreateWorkflowsRequest { } export class CreateWorkflowsResponse {} + +export class UpdateWorkflowRequestParam { + @ApiProperty({ description: 'ワークフローの内部ID' }) + @Type(() => Number) + @IsInt() + @Min(0) + workflowId: number; +} + +export class UpdateWorkflowRequest { + @ApiProperty({ description: 'Authorの内部ID' }) + @Type(() => Number) + @IsInt() + @Min(0) + authorId: number; + @ApiProperty({ description: 'Worktypeの内部ID', required: false }) + @IsOptional() + @Type(() => Number) + @IsInt() + @Min(0) + worktypeId?: number | undefined; + @ApiProperty({ description: 'テンプレートの内部ID', required: false }) + @IsOptional() + @Type(() => Number) + @IsInt() + @Min(0) + templateId?: number | undefined; + @ApiProperty({ + description: 'ルーティング候補のタイピストユーザー/タイピストグループ', + type: [WorkflowTypist], + minItems: 1, + }) + @Type(() => WorkflowTypist) + @IsArray() + @ArrayMinSize(1) + typists: WorkflowTypist[]; +} + +export class UpdateWorkflowResponse {} diff --git a/dictation_server/src/features/workflows/workflows.controller.ts b/dictation_server/src/features/workflows/workflows.controller.ts index a1521c4..269ca52 100644 --- a/dictation_server/src/features/workflows/workflows.controller.ts +++ b/dictation_server/src/features/workflows/workflows.controller.ts @@ -3,6 +3,7 @@ import { Controller, Get, HttpStatus, + Param, Post, Req, UseGuards, @@ -20,6 +21,9 @@ import { GetWorkflowsResponse, CreateWorkflowsRequest, CreateWorkflowsResponse, + UpdateWorkflowResponse, + UpdateWorkflowRequest, + UpdateWorkflowRequestParam, } from './types/types'; import { AuthGuard } from '../../common/guards/auth/authguards'; import { RoleGuard } from '../../common/guards/role/roleguards'; @@ -110,4 +114,51 @@ export class WorkflowsController { return {}; } + + @ApiResponse({ + status: HttpStatus.OK, + type: UpdateWorkflowResponse, + description: '成功時のレスポンス', + }) + @ApiResponse({ + status: HttpStatus.BAD_REQUEST, + description: 'パラメータ不正エラー', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.UNAUTHORIZED, + description: '認証エラー', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.INTERNAL_SERVER_ERROR, + description: '想定外のサーバーエラー', + type: ErrorResponse, + }) + @ApiOperation({ + operationId: 'updateWorkflow', + description: 'アカウント内のワークフローを編集します', + }) + @ApiBearerAuth() + @UseGuards(AuthGuard) + @UseGuards(RoleGuard.requireds({ roles: [ADMIN_ROLES.ADMIN] })) + @Post('/:workflowId') + async updateWorkflow( + @Req() req: Request, + @Param() param: UpdateWorkflowRequestParam, + @Body() body: UpdateWorkflowRequest, + ): Promise { + const { authorId } = body; + const { workflowId } = param; + const token = retrieveAuthorizationToken(req); + const { userId } = jwt.decode(token, { json: true }) as AccessToken; + console.log('updateWorkflow'); + + const context = makeContext(userId); + console.log(context.trackingId); + console.log(authorId); + console.log(workflowId); + + return {}; + } }