diff --git a/dictation_server/.vscode/settings.json b/dictation_server/.vscode/settings.json index 802da8c..a3c8e93 100644 --- a/dictation_server/.vscode/settings.json +++ b/dictation_server/.vscode/settings.json @@ -17,5 +17,6 @@ "editor.formatOnType": true, "editor.renderWhitespace": "all", "editor.insertSpaces": false, - "editor.renderLineHighlight": "all" + "editor.renderLineHighlight": "all", + "prettier.prettierPath": "./node_modules/prettier" } \ No newline at end of file diff --git a/dictation_server/src/api/odms/openapi.json b/dictation_server/src/api/odms/openapi.json index 96d5315..69a0544 100644 --- a/dictation_server/src/api/odms/openapi.json +++ b/dictation_server/src/api/odms/openapi.json @@ -216,6 +216,62 @@ ] } }, + "/accounts/me": { + "get": { + "operationId": "getMyAccount", + "summary": "", + "description": "ログインしているユーザーのアカウント情報を取得します", + "parameters": [], + "responses": { + "200": { + "description": "成功時のレスポンス", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetMyAccountResponse" + } + } + } + }, + "400": { + "description": "該当アカウントがDBに存在しない場合", + "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": { "post": { "operationId": "confirmUser", @@ -893,7 +949,7 @@ "name": "paramName", "required": false, "in": "query", - "description": "JOB_NUMBER/STATUS/ENCRYPTION/AUTHOR_ID/FILE_NAME/FILE_LENGTH/FILE_SIZE/RECORDING_STARTED_DATE/RECORDING_FINISHED_DATE/UPLOAD_DATE/TRANSCRIPTION_STARTED_DATE/TRANSCRIPTION_FINISHED_DATE", + "description": "JOB_NUMBER/STATUS/ENCRYPTION/AUTHOR_ID/WORK_TYPE/FILE_NAME/FILE_LENGTH/FILE_SIZE/RECORDING_STARTED_DATE/RECORDING_FINISHED_DATE/UPLOAD_DATE/TRANSCRIPTION_STARTED_DATE/TRANSCRIPTION_FINISHED_DATE", "schema": { "type": "string" } @@ -1783,6 +1839,24 @@ }, "required": ["licenseSummaryInfo"] }, + "Account": { + "type": "object", + "properties": { + "accountId": { + "type": "number" + } + }, + "required": ["accountId"] + }, + "GetMyAccountResponse": { + "type": "object", + "properties": { + "account": { + "$ref": "#/components/schemas/Account" + } + }, + "required": ["account"] + }, "ConfirmRequest": { "type": "object", "properties": { @@ -1999,7 +2073,7 @@ }, "paramName": { "type": "string", - "description": "JOB_NUMBER/STATUS/ENCRYPTION/AUTHOR_ID/FILE_NAME/FILE_LENGTH/FILE_SIZE/RECORDING_STARTED_DATE/RECORDING_FINISHED_DATE/UPLOAD_DATE/TRANSCRIPTION_STARTED_DATE/TRANSCRIPTION_FINISHED_DATE" + "description": "JOB_NUMBER/STATUS/ENCRYPTION/AUTHOR_ID/WORK_TYPE/FILE_NAME/FILE_LENGTH/FILE_SIZE/RECORDING_STARTED_DATE/RECORDING_FINISHED_DATE/UPLOAD_DATE/TRANSCRIPTION_STARTED_DATE/TRANSCRIPTION_FINISHED_DATE" } }, "required": ["direction", "paramName"] @@ -2017,7 +2091,7 @@ }, "paramName": { "type": "string", - "description": "JOB_NUMBER/STATUS/ENCRYPTION/AUTHOR_ID/FILE_NAME/FILE_LENGTH/FILE_SIZE/RECORDING_STARTED_DATE/RECORDING_FINISHED_DATE/UPLOAD_DATE/TRANSCRIPTION_STARTED_DATE/TRANSCRIPTION_FINISHED_DATE" + "description": "JOB_NUMBER/STATUS/ENCRYPTION/AUTHOR_ID/WORK_TYPE/FILE_NAME/FILE_LENGTH/FILE_SIZE/RECORDING_STARTED_DATE/RECORDING_FINISHED_DATE/UPLOAD_DATE/TRANSCRIPTION_STARTED_DATE/TRANSCRIPTION_FINISHED_DATE" } }, "required": ["direction", "paramName"] diff --git a/dictation_server/src/features/accounts/accounts.controller.ts b/dictation_server/src/features/accounts/accounts.controller.ts index 9ca5acb..0e27f68 100644 --- a/dictation_server/src/features/accounts/accounts.controller.ts +++ b/dictation_server/src/features/accounts/accounts.controller.ts @@ -3,6 +3,7 @@ import { Controller, HttpStatus, Post, + Get, Req, UseGuards, } from '@nestjs/common'; @@ -20,6 +21,7 @@ import { CreateAccountResponse, GetLicenseSummaryRequest, GetLicenseSummaryResponse, + GetMyAccountResponse, } from './types/types'; import { USER_ROLES, ADMIN_ROLES } from '../../constants'; import { AuthGuard } from '../../common/guards/auth/authguards'; @@ -120,4 +122,41 @@ export class AccountsController { }, }; } + + @ApiResponse({ + status: HttpStatus.OK, + type: GetMyAccountResponse, + description: '成功時のレスポンス', + }) + @ApiResponse({ + status: HttpStatus.BAD_REQUEST, + description: '該当アカウントがDBに存在しない場合', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.UNAUTHORIZED, + description: '認証エラー', + type: ErrorResponse, + }) + @ApiResponse({ + status: HttpStatus.INTERNAL_SERVER_ERROR, + description: '想定外のサーバーエラー', + type: ErrorResponse, + }) + @ApiOperation({ + operationId: 'getMyAccount', + description: 'ログインしているユーザーのアカウント情報を取得します', + }) + @ApiBearerAuth() + @UseGuards(AuthGuard) + @UseGuards(RoleGuard.requireds({ roles: [ADMIN_ROLES.ADMIN] })) + @Get('me') + async getMyAccount(@Req() req: Request): Promise { + console.log(req.header('Authorization')); + return { + account: { + accountId: 1, + }, + }; + } } diff --git a/dictation_server/src/features/accounts/types/types.ts b/dictation_server/src/features/accounts/types/types.ts index 2a4089d..416af83 100644 --- a/dictation_server/src/features/accounts/types/types.ts +++ b/dictation_server/src/features/accounts/types/types.ts @@ -72,3 +72,13 @@ export class GetLicenseSummaryResponse { @ApiProperty({ type: LicenseSummaryInfo }) licenseSummaryInfo: LicenseSummaryInfo; } + +export class Account { + @ApiProperty() + accountId: number; +} + +export class GetMyAccountResponse { + @ApiProperty({ type: Account }) + account: Account; +}