Merged PR 382: API IF実装
## 概要 [Task2542: API IF実装](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2542) パートナー取得APIのIFを実装しました。 ## レビューポイント なし ## UIの変更 なし ## 動作確認状況 ローカルでSwaggerUiを確認 ## 補足 なし
This commit is contained in:
parent
0b7d979fae
commit
17640eefa1
@ -838,6 +838,64 @@
|
|||||||
"security": [{ "bearer": [] }]
|
"security": [{ "bearer": [] }]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/accounts/partners": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "getPartners",
|
||||||
|
"summary": "",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "limit",
|
||||||
|
"required": true,
|
||||||
|
"in": "query",
|
||||||
|
"description": "取得件数",
|
||||||
|
"schema": { "type": "number" }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "offset",
|
||||||
|
"required": true,
|
||||||
|
"in": "query",
|
||||||
|
"description": "開始位置",
|
||||||
|
"schema": { "type": "number" }
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "成功時のレスポンス",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": { "$ref": "#/components/schemas/GetPartnersResponse" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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": [] }]
|
||||||
|
}
|
||||||
|
},
|
||||||
"/users/confirm": {
|
"/users/confirm": {
|
||||||
"post": {
|
"post": {
|
||||||
"operationId": "confirmUser",
|
"operationId": "confirmUser",
|
||||||
@ -2767,6 +2825,47 @@
|
|||||||
"required": ["worktypeId"]
|
"required": ["worktypeId"]
|
||||||
},
|
},
|
||||||
"CreateWorktypeResponse": { "type": "object", "properties": {} },
|
"CreateWorktypeResponse": { "type": "object", "properties": {} },
|
||||||
|
"Partner": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": { "type": "string", "description": "会社名" },
|
||||||
|
"tier": { "type": "number", "description": "階層" },
|
||||||
|
"accountId": { "type": "number", "description": "アカウントID" },
|
||||||
|
"country": { "type": "string", "description": "国" },
|
||||||
|
"primaryAdmin": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "プライマリ管理者"
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "プライマリ管理者メールアドレス"
|
||||||
|
},
|
||||||
|
"dealerManagement": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "代行操作許可"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"name",
|
||||||
|
"tier",
|
||||||
|
"accountId",
|
||||||
|
"country",
|
||||||
|
"primaryAdmin",
|
||||||
|
"email",
|
||||||
|
"dealerManagement"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"GetPartnersResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"total": { "type": "number", "description": "合計件数" },
|
||||||
|
"partners": {
|
||||||
|
"type": "array",
|
||||||
|
"items": { "$ref": "#/components/schemas/Partner" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["total", "partners"]
|
||||||
|
},
|
||||||
"ConfirmRequest": {
|
"ConfirmRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": { "token": { "type": "string" } },
|
"properties": { "token": { "type": "string" } },
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import {
|
|||||||
Req,
|
Req,
|
||||||
UseGuards,
|
UseGuards,
|
||||||
Param,
|
Param,
|
||||||
|
Query,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import {
|
import {
|
||||||
ApiOperation,
|
ApiOperation,
|
||||||
@ -45,6 +46,8 @@ import {
|
|||||||
GetWorktypesResponse,
|
GetWorktypesResponse,
|
||||||
CreateWorktypeResponse,
|
CreateWorktypeResponse,
|
||||||
CreateWorktypesRequest,
|
CreateWorktypesRequest,
|
||||||
|
GetPartnersRequest,
|
||||||
|
GetPartnersResponse,
|
||||||
} 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';
|
||||||
@ -715,4 +718,85 @@ export class AccountsController {
|
|||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('/partners')
|
||||||
|
@ApiResponse({
|
||||||
|
status: HttpStatus.OK,
|
||||||
|
type: GetPartnersResponse,
|
||||||
|
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: 'getPartners' })
|
||||||
|
@ApiBearerAuth()
|
||||||
|
@UseGuards(AuthGuard)
|
||||||
|
@UseGuards(
|
||||||
|
RoleGuard.requireds({
|
||||||
|
roles: [ADMIN_ROLES.ADMIN],
|
||||||
|
tiers: [TIERS.TIER1, TIERS.TIER2],
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
async getPartners(
|
||||||
|
@Req() req: Request,
|
||||||
|
@Query() query: GetPartnersRequest,
|
||||||
|
): Promise<GetPartnersResponse> {
|
||||||
|
const { limit, offset } = query;
|
||||||
|
const token = retrieveAuthorizationToken(req);
|
||||||
|
const { userId } = jwt.decode(token, { json: true }) as AccessToken;
|
||||||
|
|
||||||
|
const context = makeContext(userId);
|
||||||
|
// TODO: パートナー取得APIで実装
|
||||||
|
// await this.accountService.getPartners(
|
||||||
|
// context,
|
||||||
|
// body.limit,
|
||||||
|
// body.offset,
|
||||||
|
// );
|
||||||
|
|
||||||
|
// 仮のreturn
|
||||||
|
return {
|
||||||
|
total: 1,
|
||||||
|
partners: [
|
||||||
|
{
|
||||||
|
name: 'testA',
|
||||||
|
tier: 5,
|
||||||
|
accountId: 1,
|
||||||
|
country: 'US',
|
||||||
|
primaryAdmin: 'nameA',
|
||||||
|
email: 'aaa@example.com',
|
||||||
|
dealerManagement: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'testB',
|
||||||
|
tier: 5,
|
||||||
|
accountId: 2,
|
||||||
|
country: 'US',
|
||||||
|
primaryAdmin: 'nameB',
|
||||||
|
email: 'bbb@example.com',
|
||||||
|
dealerManagement: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'testC',
|
||||||
|
tier: 5,
|
||||||
|
accountId: 1,
|
||||||
|
country: 'US',
|
||||||
|
primaryAdmin: 'nothing',
|
||||||
|
email: 'nothing',
|
||||||
|
dealerManagement: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -361,3 +361,38 @@ export class CreateWorktypesRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class CreateWorktypeResponse {}
|
export class CreateWorktypeResponse {}
|
||||||
|
|
||||||
|
export class GetPartnersRequest {
|
||||||
|
@ApiProperty({ description: '取得件数' })
|
||||||
|
@IsInt()
|
||||||
|
@Min(0)
|
||||||
|
limit: number;
|
||||||
|
@ApiProperty({ description: '開始位置' })
|
||||||
|
@IsInt()
|
||||||
|
@Min(0)
|
||||||
|
offset: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Partner {
|
||||||
|
@ApiProperty({ description: '会社名' })
|
||||||
|
name: string;
|
||||||
|
@ApiProperty({ description: '階層' })
|
||||||
|
tier: number;
|
||||||
|
@ApiProperty({ description: 'アカウントID' })
|
||||||
|
accountId: number;
|
||||||
|
@ApiProperty({ description: '国' })
|
||||||
|
country: string;
|
||||||
|
@ApiProperty({ description: 'プライマリ管理者' })
|
||||||
|
primaryAdmin: string;
|
||||||
|
@ApiProperty({ description: 'プライマリ管理者メールアドレス' })
|
||||||
|
email: string;
|
||||||
|
@ApiProperty({ description: '代行操作許可' })
|
||||||
|
dealerManagement: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GetPartnersResponse {
|
||||||
|
@ApiProperty({ description: '合計件数' })
|
||||||
|
total: number;
|
||||||
|
@ApiProperty({ type: [Partner] })
|
||||||
|
partners: Partner[];
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user