Merged PR 358: API IF実装
## 概要 [Task2459: API IF実装](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2459) - タイピストグループ取得、編集APIのIFを実装しました。 - API定義をjsonファイルに出力 ## レビューポイント - パスは適切か - パラメータの内容と制約は適切か ## UIの変更 - なし ## 動作確認状況 - ローカルで確認
This commit is contained in:
parent
7be84e9bbc
commit
50a837efb9
@ -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": {
|
||||
|
||||
@ -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<GetTypistGroupResponse> {
|
||||
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<CreateTypistGroupResponse> {
|
||||
// アクセストークン取得
|
||||
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,
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user