diff --git a/dictation_server/src/api/odms/openapi.json b/dictation_server/src/api/odms/openapi.json index 5562e3a..9e50827 100644 --- a/dictation_server/src/api/odms/openapi.json +++ b/dictation_server/src/api/odms/openapi.json @@ -749,6 +749,60 @@ "security": [{ "bearer": [] }] } }, + "/users/update": { + "post": { + "operationId": "updateUser", + "summary": "", + "description": "ユーザーの情報を更新します", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/PostUpdateUserRequest" } + } + } + }, + "responses": { + "200": { + "description": "成功時のレスポンス", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PostUpdateUserResponse" + } + } + } + }, + "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": ["users"], + "security": [{ "bearer": [] }] + } + }, "/files/audio/upload-finished": { "post": { "operationId": "uploadFinished", @@ -1976,16 +2030,8 @@ "LicenseOrder": { "type": "object", "properties": { - "orderDate": { - "format": "date-time", - "type": "string", - "description": "注文日付" - }, - "issueDate": { - "format": "date-time", - "type": "string", - "description": "発行日付" - }, + "orderDate": { "type": "string", "description": "注文日付" }, + "issueDate": { "type": "string", "description": "発行日付" }, "numberOfOrder": { "type": "number", "description": "注文数" }, "poNumber": { "type": "string", "description": "POナンバー" }, "status": { "type": "string", "description": "注文状態" } @@ -2191,6 +2237,22 @@ }, "required": ["direction", "paramName"] }, + "PostUpdateUserRequest": { + "type": "object", + "properties": { + "id": { "type": "number" }, + "role": { "type": "string", "description": "none/author/typist" }, + "authorId": { "type": "string" }, + "autoRenew": { "type": "boolean" }, + "licenseAlart": { "type": "boolean" }, + "notification": { "type": "boolean" }, + "encryption": { "type": "boolean" }, + "encryptionPassword": { "type": "string" }, + "prompt": { "type": "boolean" } + }, + "required": ["id", "role", "autoRenew", "licenseAlart", "notification"] + }, + "PostUpdateUserResponse": { "type": "object", "properties": {} }, "AudioOptionItem": { "type": "object", "properties": { diff --git a/dictation_server/src/features/users/types/types.ts b/dictation_server/src/features/users/types/types.ts index c789013..308cc26 100644 --- a/dictation_server/src/features/users/types/types.ts +++ b/dictation_server/src/features/users/types/types.ts @@ -184,3 +184,35 @@ export class GetSortCriteriaResponse { }) paramName: string; } + +export class PostUpdateUserRequest { + @ApiProperty() + id: number; + + @ApiProperty({ description: 'none/author/typist' }) + @IsIn([USER_ROLES.NONE, USER_ROLES.AUTHOR, USER_ROLES.TYPIST]) + role: string; + + @ApiProperty({ required: false }) + authorId?: string | undefined; + + @ApiProperty() + autoRenew: boolean; + + @ApiProperty() + licenseAlart: boolean; + + @ApiProperty() + notification: boolean; + + @ApiProperty({ required: false }) + encryption?: boolean | undefined; + + @ApiProperty({ required: false }) + encryptionPassword?: string | undefined; + + @ApiProperty({ required: false }) + prompt?: boolean | undefined; +} + +export class PostUpdateUserResponse {} diff --git a/dictation_server/src/features/users/users.controller.ts b/dictation_server/src/features/users/users.controller.ts index c3a1474..527e1f8 100644 --- a/dictation_server/src/features/users/users.controller.ts +++ b/dictation_server/src/features/users/users.controller.ts @@ -31,6 +31,8 @@ import { PostSortCriteriaResponse, GetSortCriteriaRequest, GetSortCriteriaResponse, + PostUpdateUserRequest, + PostUpdateUserResponse, } from './types/types'; import { UsersService } from './users.service'; import jwt from 'jsonwebtoken'; @@ -300,4 +302,44 @@ export class UsersController { ); return { direction, paramName }; } + + @ApiResponse({ + status: HttpStatus.OK, + type: PostUpdateUserResponse, + 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: 'updateUser', + description: 'ユーザーの情報を更新します', + }) + @ApiBearerAuth() + @UseGuards(AuthGuard) + @UseGuards(RoleGuard.requireds({ roles: [ADMIN_ROLES.ADMIN] })) + @Post('update') + async updateUser( + @Body() body: PostUpdateUserRequest, + @Req() req: Request, + ): Promise { + const accessToken = retrieveAuthorizationToken(req); + const decodedToken = jwt.decode(accessToken, { json: true }) as AccessToken; + + console.log(body); + console.log(decodedToken); + return {}; + } }