|
@@ -36,16 +36,14 @@ class MatchTeamGroupService extends CrudService {
|
|
|
if (person_type === 'TeamApply') {
|
|
|
allPerson = await this.teamApplyModel.find({ project_id, status: '1', _id: { $nin: personList } });
|
|
|
} else {
|
|
|
- const conn = this.app.mongooseDB.get('base');
|
|
|
- const schema = _.get(this.ctx.model, 'Base.User.schema');
|
|
|
- const m = conn.model('User', schema);
|
|
|
allPerson = await this.matchSignModel.find({ project_id, pay_status: '1', user_id: { $nin: personList } }).populate({
|
|
|
path: 'user_id',
|
|
|
select: 'user_id',
|
|
|
+ model: this.userModel,
|
|
|
populate: {
|
|
|
path: 'user_id',
|
|
|
select: 'name',
|
|
|
- model: m,
|
|
|
+ model: this.baseUserModel,
|
|
|
},
|
|
|
});
|
|
|
allPerson = JSON.parse(JSON.stringify(allPerson));
|
|
@@ -128,9 +126,6 @@ class MatchTeamGroupService extends CrudService {
|
|
|
} else {
|
|
|
|
|
|
const users = [];
|
|
|
- const conn = this.app.mongooseDB.get('base');
|
|
|
- const schema = _.get(this.ctx.model, 'Base.User.schema');
|
|
|
- const m = conn.model('User', schema);
|
|
|
for (const i of returnData) {
|
|
|
const { person } = i;
|
|
|
for (const p of person) {
|
|
@@ -138,7 +133,7 @@ class MatchTeamGroupService extends CrudService {
|
|
|
const user = await this.userModel.findById(user_id).populate({
|
|
|
path: 'user_id',
|
|
|
select: 'name',
|
|
|
- model: m,
|
|
|
+ model: this.baseUserModel,
|
|
|
});
|
|
|
p.user_name = _.get(user, 'user_id.name');
|
|
|
}
|
|
@@ -205,10 +200,7 @@ class MatchTeamGroupService extends CrudService {
|
|
|
const { person, person_type } = d;
|
|
|
if (person_type === 'User') {
|
|
|
|
|
|
- const conn = this.app.mongooseDB.get('base');
|
|
|
- const schema = _.get(this.ctx.model, 'Base.User.schema');
|
|
|
- const m = conn.model('User', schema);
|
|
|
- const users = await this.userModel.find({ _id: person }).populate({ path: 'user_id', model: m, select: 'name' });
|
|
|
+ const users = await this.userModel.find({ _id: person }).populate({ path: 'user_id', model: this.baseUserModel, select: 'name' });
|
|
|
const parr = person.map(i => {
|
|
|
const r = users.find(f => ObjectId(f._id).equals(i));
|
|
|
if (r) return { id: r._id, name: _.get(r, 'user_id.name') };
|
|
@@ -236,10 +228,7 @@ class MatchTeamGroupService extends CrudService {
|
|
|
const { person = [], person_type } = d;
|
|
|
if (person_type === 'User') {
|
|
|
|
|
|
- const conn = this.app.mongooseDB.get('base');
|
|
|
- const schema = _.get(this.ctx.model, 'Base.User.schema');
|
|
|
- const m = conn.model('User', schema);
|
|
|
- const users = await this.userModel.find({ _id: person }).populate({ path: 'user_id', model: m, select: 'name' });
|
|
|
+ const users = await this.userModel.find({ _id: person }).populate({ path: 'user_id', model: this.baseUserModel, select: 'name' });
|
|
|
const parr = person.map(i => {
|
|
|
const r = users.find(f => ObjectId(f._id).equals(i));
|
|
|
if (r) return { id: r._id, name: _.get(r, 'user_id.name') };
|