Merged PR 345: API IF実装

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

- TypistGroup追加APIを実装しました。
  - openapi.jsonを更新

## レビューポイント
- パラメータの制限は適切か
- パスは適切か

## UIの変更
- なし

## 動作確認状況
- ローカルで確認
This commit is contained in:
makabe.t 2023-08-24 00:08:22 +00:00
parent 84e7deb52a
commit ba371ac4c0
3 changed files with 135 additions and 1 deletions

View File

@ -298,6 +298,60 @@
},
"tags": ["accounts"],
"security": [{ "bearer": [] }]
},
"post": {
"operationId": "createTypistGroup",
"summary": "",
"description": "ログインしているユーザーのアカウント配下にタイピストグループを追加します",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateTypistGroupRequest"
}
}
}
},
"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": {
@ -2177,6 +2231,23 @@
},
"required": ["typistGroups"]
},
"CreateTypistGroupRequest": {
"type": "object",
"properties": {
"typistGroupName": {
"type": "string",
"minLength": 1,
"maxLength": 50
},
"typistIds": {
"minItems": 1,
"type": "array",
"items": { "type": "string" }
}
},
"required": ["typistGroupName", "typistIds"]
},
"CreateTypistGroupResponse": { "type": "object", "properties": {} },
"CreatePartnerAccountRequest": {
"type": "object",
"properties": {

View File

@ -33,6 +33,8 @@ import {
IssueLicenseRequest,
IssueLicenseResponse,
GetDealersResponse,
CreateTypistGroupResponse,
CreateTypistGroupRequest,
} from './types/types';
import { USER_ROLES, ADMIN_ROLES, TIERS } from '../../constants';
import { AuthGuard } from '../../common/guards/auth/authguards';
@ -243,6 +245,46 @@ export class AccountsController {
return { typistGroups };
}
@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: 'createTypistGroup',
description:
'ログインしているユーザーのアカウント配下にタイピストグループを追加します',
})
@ApiBearerAuth()
@UseGuards(AuthGuard)
@UseGuards(RoleGuard.requireds({ roles: [ADMIN_ROLES.ADMIN] }))
@Post('typist-groups')
async createTypistGroup(
@Req() req: Request,
@Body() body: CreateTypistGroupRequest,
): Promise<CreateTypistGroupResponse> {
// アクセストークン取得
const accessToken = retrieveAuthorizationToken(req);
const payload = jwt.decode(accessToken, { json: true }) as AccessToken;
return {};
}
@Post('partner')
@ApiResponse({
status: HttpStatus.OK,

View File

@ -1,5 +1,14 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsEmail, IsInt, IsOptional, Matches, Min } from 'class-validator';
import {
IsEmail,
IsInt,
IsOptional,
Matches,
MaxLength,
Min,
ArrayMinSize,
MinLength,
} from 'class-validator';
import { IsAdminPasswordvalid } from '../../../common/validators/admin.validator';
export class CreateAccountRequest {
@ -122,6 +131,18 @@ export class GetTypistGroupsResponse {
typistGroups: TypistGroup[];
}
export class CreateTypistGroupRequest {
@ApiProperty({ minLength: 1, maxLength: 50 })
@MinLength(1)
@MaxLength(50)
typistGroupName: string;
@ApiProperty({ minItems: 1 })
@ArrayMinSize(1)
typistIds: number[];
}
export class CreateTypistGroupResponse {}
export class CreatePartnerAccountRequest {
@ApiProperty()
companyName: string;