Merged PR 258: getRelationsを外部連携テスト用に内部実装
## 概要 [Task2257: 実装](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2257) - AuthorIDは本物の値を返却し、それ以外はダミーの固定値を返却する実装を入れました。 - npm run formatをかけました ## レビューポイント - 気になる点ないか:To真壁くん - npm run formatの結果共有:Toガンさん(パートナー追加PBIのところで出ていたので) ## 動作確認状況 - ローカルでPostmanを使用し、Authorのときとそうでないとき両方確認
This commit is contained in:
parent
5ee4c1e52f
commit
c6f63c962c
@ -217,11 +217,11 @@ describe('AccountsService', () => {
|
||||
);
|
||||
});
|
||||
it('パートナーを追加できる', async () => {
|
||||
const companyName = "TEST_COMPANY";
|
||||
const country = "US";
|
||||
const email = "xxx@example.com";
|
||||
const adminName = "ADMIN";
|
||||
const userId = "100";
|
||||
const companyName = 'TEST_COMPANY';
|
||||
const country = 'US';
|
||||
const email = 'xxx@example.com';
|
||||
const adminName = 'ADMIN';
|
||||
const userId = '100';
|
||||
const tier = 3;
|
||||
const usersRepositoryMockValue = makeDefaultUsersRepositoryMockValue();
|
||||
const userGroupsRepositoryMockValue =
|
||||
@ -231,7 +231,7 @@ describe('AccountsService', () => {
|
||||
makeDefaultAccountsRepositoryMockValue();
|
||||
const configMockValue = makeDefaultConfigValue();
|
||||
const sendGridMockValue = makeDefaultSendGridlValue();
|
||||
|
||||
|
||||
const service = await makeAccountsServiceMock(
|
||||
accountsRepositoryMockValue,
|
||||
usersRepositoryMockValue,
|
||||
@ -240,9 +240,16 @@ describe('AccountsService', () => {
|
||||
configMockValue,
|
||||
sendGridMockValue,
|
||||
);
|
||||
expect(await service.createPartnerAccount(companyName, country,email,adminName,userId,tier +1)).toEqual(
|
||||
undefined,
|
||||
);
|
||||
expect(
|
||||
await service.createPartnerAccount(
|
||||
companyName,
|
||||
country,
|
||||
email,
|
||||
adminName,
|
||||
userId,
|
||||
tier + 1,
|
||||
),
|
||||
).toEqual(undefined);
|
||||
});
|
||||
it('アカウントの追加に失敗した場合、エラーとなる', async () => {
|
||||
const companyName = 'TEST_COMPANY';
|
||||
|
||||
@ -169,7 +169,11 @@ export const makeConfigMock = (value: ConfigMockValue) => {
|
||||
};
|
||||
};
|
||||
export const makeSendGridServiceMock = (value: SendGridMockValue) => {
|
||||
const { createMailContentFromEmailConfirm,createMailContentFromEmailConfirmForNormalUser, sendMail } = value;
|
||||
const {
|
||||
createMailContentFromEmailConfirm,
|
||||
createMailContentFromEmailConfirmForNormalUser,
|
||||
sendMail,
|
||||
} = value;
|
||||
return {
|
||||
createMailContentFromEmailConfirm:
|
||||
createMailContentFromEmailConfirm instanceof Error
|
||||
|
||||
@ -185,4 +185,4 @@ export class GetPartnerLicensesResponse {
|
||||
ownPartnerLicense: PartnerLicenseInfo;
|
||||
@ApiProperty({ type: [PartnerLicenseInfo] })
|
||||
childrenPartnerLicenses: PartnerLicenseInfo[];
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,30 +202,12 @@ export class UsersController {
|
||||
description: 'ログインしているユーザーに関連する各種情報を取得します',
|
||||
})
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(AuthGuard)
|
||||
@Get('relations')
|
||||
async getRelations(@Req() req: Request): Promise<GetRelationsResponse> {
|
||||
console.log(req.header('Authorization'));
|
||||
return {
|
||||
authorId: 'AUTHOR',
|
||||
authorIdList: ['AUTHOR', 'AUTHOR1'],
|
||||
workTypeList: [
|
||||
{
|
||||
workTypeId: '1',
|
||||
optionItemList: [
|
||||
{
|
||||
label: '1',
|
||||
initialValueType: 0,
|
||||
defaultValue: 'default',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
isEncrypted: true,
|
||||
encryptionPassword: '',
|
||||
activeWorktype: '',
|
||||
audioFormat: 'DS2',
|
||||
prompt: true,
|
||||
};
|
||||
const token = retrieveAuthorizationToken(req);
|
||||
const { userId } = jwt.decode(token, { json: true }) as AccessToken;
|
||||
return await this.usersService.getRelations(userId);
|
||||
}
|
||||
|
||||
@ApiResponse({
|
||||
|
||||
@ -20,7 +20,7 @@ import { SendGridService } from '../../gateways/sendgrid/sendgrid.service';
|
||||
import { SortCriteriaRepositoryService } from '../../repositories/sort_criteria/sort_criteria.repository.service';
|
||||
import { User as EntityUser } from '../../repositories/users/entity/user.entity';
|
||||
import { UsersRepositoryService } from '../../repositories/users/users.repository.service';
|
||||
import { User } from './types/types';
|
||||
import { GetRelationsResponse, User } from './types/types';
|
||||
import { EmailAlreadyVerifiedError } from '../../repositories/users/errors/types';
|
||||
|
||||
@Injectable()
|
||||
@ -426,4 +426,147 @@ export class UsersService {
|
||||
this.logger.log(`[OUT] ${this.getSortCriteria.name}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定したユーザーの文字起こし業務に関連する情報を取得します
|
||||
* @param userId
|
||||
* @returns relations
|
||||
*/
|
||||
async getRelations(userId: string): Promise<GetRelationsResponse> {
|
||||
this.logger.log(`[IN] ${this.getRelations.name}`);
|
||||
try {
|
||||
const user = await this.usersRepository.findUserByExternalId(userId);
|
||||
|
||||
// TODO: PBI2105 本実装時に修正すること
|
||||
return {
|
||||
authorId: user.author_id,
|
||||
authorIdList: [user.author_id, 'XXX'],
|
||||
isEncrypted: false,
|
||||
audioFormat: 'DS2',
|
||||
prompt: false,
|
||||
workTypeList: [
|
||||
{
|
||||
workTypeId: 'workType1',
|
||||
optionItemList: [
|
||||
{
|
||||
label: 'optionItem11',
|
||||
initialValueType: 2,
|
||||
defaultValue: 'default11',
|
||||
},
|
||||
{
|
||||
label: 'optionItem12',
|
||||
initialValueType: 2,
|
||||
defaultValue: 'default12',
|
||||
},
|
||||
{
|
||||
label: 'optionItem13',
|
||||
initialValueType: 2,
|
||||
defaultValue: 'default13',
|
||||
},
|
||||
{
|
||||
label: 'optionItem14',
|
||||
initialValueType: 2,
|
||||
defaultValue: 'default14',
|
||||
},
|
||||
{
|
||||
label: 'optionItem15',
|
||||
initialValueType: 2,
|
||||
defaultValue: 'default15',
|
||||
},
|
||||
{
|
||||
label: 'optionItem16',
|
||||
initialValueType: 2,
|
||||
defaultValue: 'default16',
|
||||
},
|
||||
{
|
||||
label: 'optionItem17',
|
||||
initialValueType: 2,
|
||||
defaultValue: 'default17',
|
||||
},
|
||||
{
|
||||
label: 'optionItem18',
|
||||
initialValueType: 2,
|
||||
defaultValue: 'default18',
|
||||
},
|
||||
{
|
||||
label: 'optionItem19',
|
||||
initialValueType: 1,
|
||||
defaultValue: '',
|
||||
},
|
||||
{
|
||||
label: 'optionItem110',
|
||||
initialValueType: 3,
|
||||
defaultValue: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
workTypeId: 'workType2',
|
||||
optionItemList: [
|
||||
{
|
||||
label: 'optionItem21',
|
||||
initialValueType: 2,
|
||||
defaultValue: 'default21',
|
||||
},
|
||||
{
|
||||
label: 'optionItem22',
|
||||
initialValueType: 2,
|
||||
defaultValue: 'default22',
|
||||
},
|
||||
{
|
||||
label: 'optionItem23',
|
||||
initialValueType: 2,
|
||||
defaultValue: 'defaul23',
|
||||
},
|
||||
{
|
||||
label: 'optionItem24',
|
||||
initialValueType: 2,
|
||||
defaultValue: 'default24',
|
||||
},
|
||||
{
|
||||
label: 'optionItem25',
|
||||
initialValueType: 2,
|
||||
defaultValue: 'default25',
|
||||
},
|
||||
{
|
||||
label: 'optionItem26',
|
||||
initialValueType: 2,
|
||||
defaultValue: 'default26',
|
||||
},
|
||||
{
|
||||
label: 'optionItem27',
|
||||
initialValueType: 2,
|
||||
defaultValue: 'default27',
|
||||
},
|
||||
{
|
||||
label: 'optionItem28',
|
||||
initialValueType: 2,
|
||||
defaultValue: 'default28',
|
||||
},
|
||||
{
|
||||
label: 'optionItem29',
|
||||
initialValueType: 1,
|
||||
defaultValue: '',
|
||||
},
|
||||
{
|
||||
label: 'optionItem210',
|
||||
initialValueType: 3,
|
||||
defaultValue: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
activeWorktype: 'workType1',
|
||||
};
|
||||
} catch (e) {
|
||||
this.logger.error(`error=${e}`);
|
||||
|
||||
throw new HttpException(
|
||||
makeErrorResponse('E009999'),
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
} finally {
|
||||
this.logger.log(`[OUT] ${this.getRelations.name}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user