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": [] }]
|
"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": {
|
"/accounts/partner": {
|
||||||
"post": {
|
"post": {
|
||||||
"operationId": "createPartnerAccount",
|
"operationId": "createPartnerAccount",
|
||||||
@ -2299,6 +2413,22 @@
|
|||||||
"required": ["typistGroupName", "typistIds"]
|
"required": ["typistGroupName", "typistIds"]
|
||||||
},
|
},
|
||||||
"CreateTypistGroupResponse": { "type": "object", "properties": {} },
|
"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": {
|
"CreatePartnerAccountRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import {
|
|||||||
Get,
|
Get,
|
||||||
Req,
|
Req,
|
||||||
UseGuards,
|
UseGuards,
|
||||||
|
Param,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import {
|
import {
|
||||||
ApiOperation,
|
ApiOperation,
|
||||||
@ -35,6 +36,10 @@ import {
|
|||||||
GetDealersResponse,
|
GetDealersResponse,
|
||||||
CreateTypistGroupResponse,
|
CreateTypistGroupResponse,
|
||||||
CreateTypistGroupRequest,
|
CreateTypistGroupRequest,
|
||||||
|
GetTypistGroupResponse,
|
||||||
|
GetTypistGroupRequest,
|
||||||
|
UpdateTypistGroupRequest,
|
||||||
|
UpdateTypistGroupRequestParam,
|
||||||
} from './types/types';
|
} from './types/types';
|
||||||
import { USER_ROLES, ADMIN_ROLES, TIERS } from '../../constants';
|
import { USER_ROLES, ADMIN_ROLES, TIERS } from '../../constants';
|
||||||
import { AuthGuard } from '../../common/guards/auth/authguards';
|
import { AuthGuard } from '../../common/guards/auth/authguards';
|
||||||
@ -245,6 +250,49 @@ export class AccountsController {
|
|||||||
return { typistGroups };
|
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({
|
@ApiResponse({
|
||||||
status: HttpStatus.OK,
|
status: HttpStatus.OK,
|
||||||
type: CreateTypistGroupResponse,
|
type: CreateTypistGroupResponse,
|
||||||
@ -285,6 +333,51 @@ export class AccountsController {
|
|||||||
return {};
|
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')
|
@Post('partner')
|
||||||
@ApiResponse({
|
@ApiResponse({
|
||||||
status: HttpStatus.OK,
|
status: HttpStatus.OK,
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import {
|
|||||||
IsArray,
|
IsArray,
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
import { IsAdminPasswordvalid } from '../../../common/validators/admin.validator';
|
import { IsAdminPasswordvalid } from '../../../common/validators/admin.validator';
|
||||||
|
import { Type } from 'class-transformer';
|
||||||
|
|
||||||
export class CreateAccountRequest {
|
export class CreateAccountRequest {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@ -132,6 +133,20 @@ export class GetTypistGroupsResponse {
|
|||||||
typistGroups: TypistGroup[];
|
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 {
|
export class CreateTypistGroupRequest {
|
||||||
@ApiProperty({ minLength: 1, maxLength: 50 })
|
@ApiProperty({ minLength: 1, maxLength: 50 })
|
||||||
@MinLength(1)
|
@MinLength(1)
|
||||||
@ -145,6 +160,27 @@ export class CreateTypistGroupRequest {
|
|||||||
|
|
||||||
export class CreateTypistGroupResponse {}
|
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 {
|
export class CreatePartnerAccountRequest {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
companyName: string;
|
companyName: string;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user