diff --git a/dictation_server/src/api/odms/openapi.json b/dictation_server/src/api/odms/openapi.json index c18a26d..9c048cc 100644 --- a/dictation_server/src/api/odms/openapi.json +++ b/dictation_server/src/api/odms/openapi.json @@ -354,6 +354,120 @@ "security": [{ "bearer": [] }] } }, + "/accounts/typist-groups/{typistGroupId}": { + "get": { + "operationId": "getTypistGroup", + "summary": "", + "description": "ログインしているユーザーのアカウント配下でIDで指定されたタイピストグループを取得します", + "parameters": [ + { + "name": "typistGroupId", + "required": true, + "in": "path", + "schema": { "type": "number" } + } + ], + "responses": { + "200": { + "description": "成功時のレスポンス", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetTypistGroupsResponse" + } + } + } + }, + "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": ["accounts"], + "security": [{ "bearer": [] }] + }, + "post": { + "operationId": "updateTypistGroup", + "summary": "", + "description": "ログインしているユーザーのアカウント配下でIDで指定されたタイピストグループを編集します", + "parameters": [ + { + "name": "typistGroupId", + "required": true, + "in": "path", + "schema": { "type": "number" } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateTypistGroupRequest" + } + } + } + }, + "responses": { + "200": { + "description": "成功時のレスポンス", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateTypistGroupResponse" + } + } + } + }, + "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": ["accounts"], + "security": [{ "bearer": [] }] + } + }, "/accounts/partner": { "post": { "operationId": "createPartnerAccount", @@ -2299,6 +2413,22 @@ "required": ["typistGroupName", "typistIds"] }, "CreateTypistGroupResponse": { "type": "object", "properties": {} }, + "UpdateTypistGroupRequest": { + "type": "object", + "properties": { + "typistGroupName": { + "type": "string", + "minLength": 1, + "maxLength": 50 + }, + "typistIds": { + "minItems": 1, + "type": "array", + "items": { "type": "integer" } + } + }, + "required": ["typistGroupName", "typistIds"] + }, "CreatePartnerAccountRequest": { "type": "object", "properties": { diff --git a/dictation_server/src/features/accounts/accounts.controller.ts b/dictation_server/src/features/accounts/accounts.controller.ts index 1fec4f0..0d207c1 100644 --- a/dictation_server/src/features/accounts/accounts.controller.ts +++ b/dictation_server/src/features/accounts/accounts.controller.ts @@ -6,6 +6,7 @@ import { Get, Req, UseGuards, + Param, } from '@nestjs/common'; import { ApiOperation, @@ -35,6 +36,10 @@ import { GetDealersResponse, CreateTypistGroupResponse, CreateTypistGroupRequest, + GetTypistGroupResponse, + GetTypistGroupRequest, + UpdateTypistGroupRequest, + UpdateTypistGroupRequestParam, } from './types/types'; import { USER_ROLES, ADMIN_ROLES, TIERS } from '../../constants'; import { AuthGuard } from '../../common/guards/auth/authguards'; @@ -245,6 +250,49 @@ export class AccountsController { return { typistGroups }; } + @ApiResponse({ + status: HttpStatus.OK, + type: GetTypistGroupsResponse, + 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: 'getTypistGroup', + description: + 'ログインしているユーザーのアカウント配下でIDで指定されたタイピストグループを取得します', + }) + @ApiBearerAuth() + @UseGuards(AuthGuard) + @UseGuards(RoleGuard.requireds({ roles: [ADMIN_ROLES.ADMIN] })) + @Get('typist-groups/:typistGroupId') + async getTypistGroup( + @Req() req: Request, + @Param() param: GetTypistGroupRequest, + ): Promise { + console.log(req.header('Authorization')); + // アクセストークン取得 + const accessToken = retrieveAuthorizationToken(req); + const payload = jwt.decode(accessToken, { json: true }) as AccessToken; + + console.log(param.typistGroupId); + + return { typistGroupName: '', typistIds: [] }; + } + @ApiResponse({ status: HttpStatus.OK, type: CreateTypistGroupResponse, @@ -285,6 +333,51 @@ export class AccountsController { return {}; } + @ApiResponse({ + status: HttpStatus.OK, + type: CreateTypistGroupResponse, + 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: 'updateTypistGroup', + description: + 'ログインしているユーザーのアカウント配下でIDで指定されたタイピストグループを編集します', + }) + @ApiBearerAuth() + @UseGuards(AuthGuard) + @UseGuards(RoleGuard.requireds({ roles: [ADMIN_ROLES.ADMIN] })) + @Post('typist-groups/:typistGroupId') + async updateTypistGroup( + @Req() req: Request, + @Body() body: UpdateTypistGroupRequest, + @Param() param: UpdateTypistGroupRequestParam, + ): Promise { + // アクセストークン取得 + const accessToken = retrieveAuthorizationToken(req); + const payload = jwt.decode(accessToken, { json: true }) as AccessToken; + + console.log(param.typistGroupId); + console.log(body.typistGroupName); + console.log(body.typistIds); + + return {}; + } + @Post('partner') @ApiResponse({ status: HttpStatus.OK, diff --git a/dictation_server/src/features/accounts/types/types.ts b/dictation_server/src/features/accounts/types/types.ts index 36cbda5..7b7508c 100644 --- a/dictation_server/src/features/accounts/types/types.ts +++ b/dictation_server/src/features/accounts/types/types.ts @@ -11,6 +11,7 @@ import { IsArray, } from 'class-validator'; import { IsAdminPasswordvalid } from '../../../common/validators/admin.validator'; +import { Type } from 'class-transformer'; export class CreateAccountRequest { @ApiProperty() @@ -132,6 +133,20 @@ export class GetTypistGroupsResponse { typistGroups: TypistGroup[]; } +export class GetTypistGroupRequest { + @ApiProperty() + @Type(() => Number) + @IsInt() + @Min(0) + typistGroupId: number; +} +export class GetTypistGroupResponse { + @ApiProperty() + typistGroupName: string; + @ApiProperty({ isArray: true, type: 'integer' }) + typistIds: number[]; +} + export class CreateTypistGroupRequest { @ApiProperty({ minLength: 1, maxLength: 50 }) @MinLength(1) @@ -145,6 +160,27 @@ export class CreateTypistGroupRequest { export class CreateTypistGroupResponse {} +export class UpdateTypistGroupRequest { + @ApiProperty({ minLength: 1, maxLength: 50 }) + @MinLength(1) + @MaxLength(50) + typistGroupName: string; + @ApiProperty({ minItems: 1, isArray: true, type: 'integer' }) + @ArrayMinSize(1) + @IsArray() + @IsInt({ each: true }) + @Min(0, { each: true }) + typistIds: number[]; +} +export class UpdateTypistGroupRequestParam { + @ApiProperty() + @Type(() => Number) + @IsInt() + @Min(0) + typistGroupId: number; +} +export class UpdateTypistGroupResponse {} + export class CreatePartnerAccountRequest { @ApiProperty() companyName: string;