|
@@ -221,6 +221,38 @@ class MatchTeamGroupService extends CrudService {
|
|
|
|
|
|
return data;
|
|
|
}
|
|
|
+ async afterFetch(filter, d) {
|
|
|
+ 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 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') };
|
|
|
+ return i;
|
|
|
+ });
|
|
|
+ d.person = parr;
|
|
|
+ } else if (person_type === 'TeamApply') {
|
|
|
+ console.log(person);
|
|
|
+ // 组队
|
|
|
+ const teamApplys = await this.teamApplyModel.find({ _id: person });
|
|
|
+ const parr = [];
|
|
|
+ for (const p of parr) {
|
|
|
+ const r = teamApplys.find(f => ObjectId(f._id).equals(p));
|
|
|
+ console.log(r);
|
|
|
+ if (r) {
|
|
|
+ const { one_member_name, two_member_name } = r;
|
|
|
+ parr.push({ id: p, name: `${one_member_name}-${two_member_name}` });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ d.person = parr;
|
|
|
+ }
|
|
|
+
|
|
|
+ return d;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 根据该赛事状态,判断是否可以操作
|