|
@@ -8,7 +8,7 @@ import {
|
|
} from 'free-midway-component';
|
|
} from 'free-midway-component';
|
|
import { Expert } from '../../entity/user/expert.entity';
|
|
import { Expert } from '../../entity/user/expert.entity';
|
|
import { Admin } from '../../entity/user/admin.entity';
|
|
import { Admin } from '../../entity/user/admin.entity';
|
|
-import { LoginDTO } from '../../interface/user/expert.interface';
|
|
|
|
|
|
+import { LoginDTO, QDTO_expert } from '../../interface/user/expert.interface';
|
|
import isEqual = require('lodash/isEqual');
|
|
import isEqual = require('lodash/isEqual');
|
|
import get = require('lodash/get');
|
|
import get = require('lodash/get');
|
|
import head = require('lodash/head');
|
|
import head = require('lodash/head');
|
|
@@ -42,19 +42,19 @@ export class ExpertService extends BaseService<modelType> {
|
|
throw new ServiceError('密码错误', FrameworkErrorEnum.SERVICE_FAULT);
|
|
throw new ServiceError('密码错误', FrameworkErrorEnum.SERVICE_FAULT);
|
|
return user;
|
|
return user;
|
|
}
|
|
}
|
|
- async dealQueryCondition({ code, ...condition }) {
|
|
|
|
- const role = this.ctx.user.type;
|
|
|
|
|
|
+ async dealQueryCondition(condition: QDTO_expert): Promise<QDTO_expert> {
|
|
|
|
+ const { type, code } = this.ctx.user;
|
|
condition = this.util.dealQuery(condition);
|
|
condition = this.util.dealQuery(condition);
|
|
// 查询业务管理
|
|
// 查询业务管理
|
|
const busFind = async query =>
|
|
const busFind = async query =>
|
|
- await this.adminModel.find({ ...query, role: '3' }, { code: 1 });
|
|
|
|
|
|
+ await this.adminModel.find({ ...query, type: '3' }, { code: 1 });
|
|
// 查询机构管理
|
|
// 查询机构管理
|
|
const orgFind = async query =>
|
|
const orgFind = async query =>
|
|
- await this.adminModel.find({ ...query, role: '2' }, { code: 1 });
|
|
|
|
|
|
+ await this.adminModel.find({ ...query, type: '2' }, { code: 1 });
|
|
// 查询管理员
|
|
// 查询管理员
|
|
const aFind = async query =>
|
|
const aFind = async query =>
|
|
- await this.adminModel.find({ ...query, role: '1' }, { code: 1 });
|
|
|
|
- if (role === '1' && code) {
|
|
|
|
|
|
+ await this.adminModel.find({ ...query, type: '1' }, { code: 1 });
|
|
|
|
+ if (type === '1' && code) {
|
|
// 管理员查询
|
|
// 管理员查询
|
|
// =>获取该code下的机构管理员列表 => 用机构管理员id 获取业务管理员列表 => 将code都整理出来作为查询条件
|
|
// =>获取该code下的机构管理员列表 => 用机构管理员id 获取业务管理员列表 => 将code都整理出来作为查询条件
|
|
const a = await aFind({ code });
|
|
const a = await aFind({ code });
|
|
@@ -66,13 +66,13 @@ export class ExpertService extends BaseService<modelType> {
|
|
const aid = get(head(a), '_id');
|
|
const aid = get(head(a), '_id');
|
|
const orgList = await orgFind({ pid: aid });
|
|
const orgList = await orgFind({ pid: aid });
|
|
const busList = await busFind({ pid: orgList.map(i => i._id) });
|
|
const busList = await busFind({ pid: orgList.map(i => i._id) });
|
|
- const codes = [
|
|
|
|
|
|
+ const codes: any = [
|
|
...orgList.map(i => i.code),
|
|
...orgList.map(i => i.code),
|
|
...busList.map(i => i.code),
|
|
...busList.map(i => i.code),
|
|
code,
|
|
code,
|
|
];
|
|
];
|
|
condition.code = codes;
|
|
condition.code = codes;
|
|
- } else if (role === '2' && code) {
|
|
|
|
|
|
+ } else if (type === '2' && code) {
|
|
// 机构查询
|
|
// 机构查询
|
|
// =>获取该code下的业务管理员列表 => 将code都整理出来作为查询条件
|
|
// =>获取该code下的业务管理员列表 => 将code都整理出来作为查询条件
|
|
const o = await orgFind({ code });
|
|
const o = await orgFind({ code });
|
|
@@ -83,9 +83,9 @@ export class ExpertService extends BaseService<modelType> {
|
|
);
|
|
);
|
|
const oid = get(head(o), '_id');
|
|
const oid = get(head(o), '_id');
|
|
const busList = await busFind({ pid: oid });
|
|
const busList = await busFind({ pid: oid });
|
|
- const codes = [...busList.map(i => i.code), code];
|
|
|
|
|
|
+ const codes: any = [...busList.map(i => i.code), code];
|
|
condition.code = codes;
|
|
condition.code = codes;
|
|
- } else if (code) {
|
|
|
|
|
|
+ } else if (type === '3' && code) {
|
|
// 业务查询
|
|
// 业务查询
|
|
// code直接查询用户返回即可
|
|
// code直接查询用户返回即可
|
|
condition.code = code;
|
|
condition.code = code;
|