|
@@ -19,13 +19,14 @@ class PersonalService extends CrudService {
|
|
|
this.util = this.ctx.service.util.util;
|
|
|
}
|
|
|
async query(condition, { skip = 0, limit = 0 }) {
|
|
|
- condition = await this.dealQueryCondition(condition);
|
|
|
- const res = await this.model.find(condition).skip(parseInt(skip)).limit(parseInt(limit));
|
|
|
+ const query = await this.dealQueryCondition(_.cloneDeep(condition));
|
|
|
+ console.log(query);
|
|
|
+ const res = await this.model.find(query).skip(parseInt(skip)).limit(parseInt(limit));
|
|
|
return res;
|
|
|
}
|
|
|
- async count({ role, code, ...condition }) {
|
|
|
- condition = await this.dealQueryCondition(condition);
|
|
|
- const res = await this.model.count(condition);
|
|
|
+ async count(condition) {
|
|
|
+ const query = await this.dealQueryCondition(_.cloneDeep(condition));
|
|
|
+ const res = await this.model.count(query);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
@@ -33,10 +34,12 @@ class PersonalService extends CrudService {
|
|
|
condition = this.util.dealQuery(condition);
|
|
|
if (role === '1') {
|
|
|
//code查询机构,取出机构的code,用code到model(个人用户)里查询用户,合为一个数组,返回
|
|
|
- const orgRes = await this.adminModel.find({ code }, { code: 1 });
|
|
|
- const codes = orgRes.map((i) => i.code);
|
|
|
+ const orgRes = await this.adminModel.find({ code }, { _id: 1 });
|
|
|
+ const ids = orgRes.map((i) => i._id);
|
|
|
+ const res2 = await this.adminModel.find({ pid: ids, role: '2' }, { code });
|
|
|
+ const codes = res2.map((i) => i.code);
|
|
|
condition.code = codes;
|
|
|
- } else {
|
|
|
+ } else if (code) {
|
|
|
//code直接查询用户返回即可
|
|
|
condition.code = code;
|
|
|
}
|