|
@@ -17,7 +17,6 @@ export class ApplyCompanyService extends BaseServiceV2 {
|
|
|
|
|
|
@Inject()
|
|
|
userService: UserService;
|
|
|
-
|
|
|
// 认领检查
|
|
|
async createExamine(data) {
|
|
|
const { user } = data;
|
|
@@ -34,13 +33,15 @@ export class ApplyCompanyService extends BaseServiceV2 {
|
|
|
const company = await this.companyService.fetch({ user: get(result, 'user') });
|
|
|
if (company) throw new ServiceError(ErrorCode.SERVICE_APPLY);
|
|
|
else {
|
|
|
- // 修改企业用户id
|
|
|
- await this.companyService.update({ id: get(result, 'company') }, { id: get(result, 'company'), user: get(result, 'user') });
|
|
|
// 查询用户角色
|
|
|
const userInfo = await this.userService.fetch({ id: get(result, 'user') });
|
|
|
- const is_update = userInfo.role.find(i => i === 'Company');
|
|
|
- // 如果没有企业角色 增加一个企业角色
|
|
|
- if (!is_update) await this.userService.fetch({ id: get(result, 'user'), role: [...userInfo.role, ['Company']] });
|
|
|
+ if (userInfo) {
|
|
|
+ const is_update = userInfo.role.find(i => i === 'Company');
|
|
|
+ // 如果没有企业角色 增加一个企业角色
|
|
|
+ if (!is_update) await this.userService.update({ id: get(result, 'user') }, { id: get(result, 'user'), role: [...userInfo.role, 'Company'] });
|
|
|
+ // 修改企业用户id
|
|
|
+ await this.companyService.update({ id: get(result, 'company') }, { id: get(result, 'company'), user: get(result, 'user') });
|
|
|
+ } else throw new ServiceError(ErrorCode.USER_NOT_FOUND);
|
|
|
}
|
|
|
}
|
|
|
|