Merged PR 297: API IF実装

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

- ユーザー編集APIのI/Fを実装しました。
  - openapi.json生成

## レビューポイント
- プロパティは適切か

## UIの変更
- なし

## 動作確認状況
- ローカルで確認 Swagger
This commit is contained in:
makabe.t 2023-08-02 07:47:31 +00:00
parent 29bfc9f5a6
commit f1684a5616
3 changed files with 146 additions and 10 deletions

View File

@ -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": {

View File

@ -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 {}

View File

@ -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<PostUpdateUserResponse> {
const accessToken = retrieveAuthorizationToken(req);
const decodedToken = jwt.decode(accessToken, { json: true }) as AccessToken;
console.log(body);
console.log(decodedToken);
return {};
}
}