|
@@ -1,10 +1,35 @@
|
|
|
-import { Provide } from '@midwayjs/core';
|
|
|
+import { Inject, Provide } from '@midwayjs/core';
|
|
|
import { InjectEntityModel } from '@midwayjs/typeorm';
|
|
|
import { Repository } from 'typeorm';
|
|
|
import { ApplyCompany } from '../../entity/users/applyCompany.entity';
|
|
|
import { BaseServiceV2 } from '../../frame/BaseServiceV2';
|
|
|
+import { get } from 'lodash';
|
|
|
+import { CompanyService } from './company.service';
|
|
|
+import { UserService } from '../system/user.service';
|
|
|
@Provide()
|
|
|
export class ApplyCompanyService extends BaseServiceV2 {
|
|
|
@InjectEntityModel(ApplyCompany)
|
|
|
model: Repository<ApplyCompany>;
|
|
|
+
|
|
|
+ @Inject()
|
|
|
+ companyService: CompanyService;
|
|
|
+
|
|
|
+ @Inject()
|
|
|
+ userService: UserService;
|
|
|
+
|
|
|
+
|
|
|
+ * 填充
|
|
|
+ * @param {object} data 数据
|
|
|
+ */
|
|
|
+ async fillName(data) {
|
|
|
+ const { company, user } = data;
|
|
|
+
|
|
|
+ const companyInfo = await this.companyService.fetch({ id: company });
|
|
|
+ if (companyInfo) data = { ...data, company_name: get(companyInfo, 'name') };
|
|
|
+
|
|
|
+ const userInfo = await this.userService.fetch({ id: user });
|
|
|
+ if (userInfo) data = { ...data, user_name: get(userInfo, 'nick_name') };
|
|
|
+
|
|
|
+ return data;
|
|
|
+ }
|
|
|
}
|