Merged PR 279: ユーザー一覧API IF修正

## 概要
[Task2230: ユーザー一覧API IF修正](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2230)

- ユーザー一覧取得APIのIFを更新しました。
  - openapi.jsonを更新
  - サービスからの返却値をIFに合わせて仮の値を入れています。

## レビューポイント
- API IFの修正内容は認識通りか

## UIの変更
- なし

## 動作確認状況
- ローカルで確認
  - Swagger
This commit is contained in:
makabe.t 2023-07-27 08:11:56 +00:00
parent cba2ef582a
commit d080bb74b3
7 changed files with 88 additions and 27 deletions

View File

@ -1967,9 +1967,9 @@
"GetOrderHistoriesRequest": {
"type": "object",
"properties": {
"limit": { "type": "number" },
"offset": { "type": "number" },
"accountId": { "type": "number" }
"limit": { "type": "number", "description": "取得件数" },
"offset": { "type": "number", "description": "開始位置" },
"accountId": { "type": "number", "description": "アカウントID" }
},
"required": ["limit", "offset", "accountId"]
},
@ -1990,7 +1990,15 @@
"emailVerified": { "type": "boolean" },
"autoRenew": { "type": "boolean" },
"licenseAlert": { "type": "boolean" },
"notification": { "type": "boolean" }
"notification": { "type": "boolean" },
"encryption": { "type": "boolean" },
"prompt": { "type": "boolean" },
"expiration": { "type": "string", "nullable": true },
"remaining": { "type": "number", "nullable": true },
"licenseStatus": {
"type": "string",
"description": "Normal/NoLicense/Alert/Renew"
}
},
"required": [
"name",
@ -2001,7 +2009,12 @@
"emailVerified",
"autoRenew",
"licenseAlert",
"notification"
"notification",
"encryption",
"prompt",
"expiration",
"remaining",
"licenseStatus"
]
},
"GetUsersResponse": {

View File

@ -182,3 +182,13 @@ export const PNS = {
APNS: 'apns',
FCM: 'fcm',
};
/**
*
*/
export const USER_LICENSE_STATUS = {
NORMAL: 'Normal',
NO_LICENSE: 'NoLicense',
ALERT: 'Alert',
RENEW: 'Renew',
};

View File

@ -23,7 +23,6 @@ import jwt from 'jsonwebtoken';
@ApiTags('notification')
@Controller('notification')
@ApiBearerAuth()
export class NotificationController {
constructor(private readonly notificationService: NotificationService) {}
@Post('register')

View File

@ -23,35 +23,40 @@ describe('NotificationService.register', () => {
it('DBからのユーザー取得に失敗した場合、エラーとなる', async () => {
const notificationHubMockValue = makeDefaultNotificationHubMockValue();
const usersRepositoryMockValue = makeDefaultUsersRepositoryMockValue();
usersRepositoryMockValue.findUserByExternalId= new Error("DB failed.")
usersRepositoryMockValue.findUserByExternalId = new Error('DB failed.');
const service = await makeNotificationServiceMock(
usersRepositoryMockValue,
notificationHubMockValue,
);
await expect(service.register('external_id', 'apns', 'handler')).rejects.toEqual(
new HttpException(makeErrorResponse("E009999"), HttpStatus.INTERNAL_SERVER_ERROR)
await expect(
service.register('external_id', 'apns', 'handler'),
).rejects.toEqual(
new HttpException(
makeErrorResponse('E009999'),
HttpStatus.INTERNAL_SERVER_ERROR,
),
);
});
it('NotificationHubへの登録に失敗した場合、エラーとなる', async () => {
const notificationHubMockValue = makeDefaultNotificationHubMockValue();
const usersRepositoryMockValue = makeDefaultUsersRepositoryMockValue();
notificationHubMockValue.register = new Error("register failed.");
it('NotificationHubへの登録に失敗した場合、エラーとなる', async () => {
const notificationHubMockValue = makeDefaultNotificationHubMockValue();
const usersRepositoryMockValue = makeDefaultUsersRepositoryMockValue();
notificationHubMockValue.register = new Error('register failed.');
const service = await makeNotificationServiceMock(
usersRepositoryMockValue,
notificationHubMockValue,
);
const service = await makeNotificationServiceMock(
usersRepositoryMockValue,
notificationHubMockValue,
);
await expect(
service.register('external_id', 'apns', 'handler'),
).rejects.toEqual(
new HttpException(
makeErrorResponse('E009999'),
HttpStatus.INTERNAL_SERVER_ERROR,
),
);
});
await expect(
service.register('external_id', 'apns', 'handler'),
).rejects.toEqual(
new HttpException(
makeErrorResponse('E009999'),
HttpStatus.INTERNAL_SERVER_ERROR,
),
);
});
});

View File

@ -1,6 +1,9 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsIn } from 'class-validator';
import { TASK_LIST_SORTABLE_ATTRIBUTES } from '../../../constants';
import {
TASK_LIST_SORTABLE_ATTRIBUTES,
USER_LICENSE_STATUS,
} from '../../../constants';
import { USER_ROLES } from '../../../constants';
export class ConfirmRequest {
@ -37,6 +40,26 @@ export class User {
@ApiProperty()
notification: boolean;
@ApiProperty()
encryption: boolean;
@ApiProperty()
prompt: boolean;
@ApiProperty({ nullable: true })
expiration?: string | undefined;
@ApiProperty({ nullable: true })
remaining?: number | undefined;
@ApiProperty({
description: `${Object.values(USER_LICENSE_STATUS).join('/')}`,
})
@IsIn(Object.values(USER_LICENSE_STATUS), {
message: 'invalid license status',
})
licenseStatus: string;
}
export class GetUsersResponse {

View File

@ -586,6 +586,9 @@ const expectedUsers = [
autoRenew: false,
licenseAlert: false,
notification: false,
encryption: false,
prompt: false,
licenseStatus: 'NoLicense',
},
{
name: 'Hanako Sato',
@ -597,6 +600,9 @@ const expectedUsers = [
autoRenew: false,
licenseAlert: false,
notification: false,
encryption: false,
prompt: false,
licenseStatus: 'NoLicense',
},
];

View File

@ -22,6 +22,7 @@ import { User as EntityUser } from '../../repositories/users/entity/user.entity'
import { UsersRepositoryService } from '../../repositories/users/users.repository.service';
import { GetRelationsResponse, User } from './types/types';
import { EmailAlreadyVerifiedError } from '../../repositories/users/errors/types';
import { USER_LICENSE_STATUS } from '../../constants';
@Injectable()
export class UsersService {
@ -321,6 +322,10 @@ export class UsersService {
user.autoRenew = dbUsers[i].auto_renew;
user.licenseAlert = dbUsers[i].license_alert;
user.notification = dbUsers[i].notification;
// TODO: 仮の値を入れておく
user.encryption = false;
user.prompt = false;
user.licenseStatus = USER_LICENSE_STATUS.NO_LICENSE;
users.push(user);
}
return users;