|
@@ -32,7 +32,7 @@ class MatchTeamGroupService extends CrudService {
|
|
|
|
|
|
const teamGroups = await this.model.find({ project_id, _id: { $ne: team_id } }, { person: 1 });
|
|
|
|
|
|
- const personList = _.flattenDeep(teamGroups.map((i) => i.person));
|
|
|
+ const personList = _.flattenDeep(teamGroups.map(i => i.person));
|
|
|
if (person_type === 'Race.TeamApply') {
|
|
|
allPerson = await this.teamApplyModel.find({ project_id, status: '1', _id: { $nin: personList } });
|
|
|
} else {
|
|
@@ -47,7 +47,7 @@ class MatchTeamGroupService extends CrudService {
|
|
|
},
|
|
|
});
|
|
|
allPerson = JSON.parse(JSON.stringify(allPerson));
|
|
|
- allPerson = allPerson.map((i) => {
|
|
|
+ allPerson = allPerson.map(i => {
|
|
|
i.user_name = _.get(i, 'user_id.user_id.name');
|
|
|
i.user_id = _.get(i, 'user_id._id');
|
|
|
return i;
|
|
@@ -56,7 +56,7 @@ class MatchTeamGroupService extends CrudService {
|
|
|
|
|
|
|
|
|
if (person_type === 'Race.TeamApply') {
|
|
|
- allPerson = allPerson.filter((f) => !personList.includes(f._id));
|
|
|
+ allPerson = allPerson.filter(f => !personList.includes(f._id));
|
|
|
return allPerson;
|
|
|
}
|
|
|
return allPerson;
|
|
@@ -69,7 +69,7 @@ class MatchTeamGroupService extends CrudService {
|
|
|
const canOpera = await this.canOpera(match_id);
|
|
|
if (!canOpera) throw new BusinessError(ErrorCode.SERVICE_FAULT, '当前赛事不处于可更改赛事相关信息状态');
|
|
|
const project_id = _.get(_.head(data), 'project_id');
|
|
|
- const belongOneProject = data.every((e) => e.project_id === project_id);
|
|
|
+ const belongOneProject = data.every(e => e.project_id === project_id);
|
|
|
if (!belongOneProject) throw new BusinessError(ErrorCode.DATA_INVALID, '自动创建的小组并不全都属于同一个比赛项目,无法创建小组');
|
|
|
|
|
|
await this.model.deleteMany({ project_id });
|
|
@@ -160,7 +160,7 @@ class MatchTeamGroupService extends CrudService {
|
|
|
const { project_name } = filter;
|
|
|
if (project_name) {
|
|
|
const projectList = await this.matchProjectModel.find({ name: new RegExp(project_name) }, { _id: 1 });
|
|
|
- const project_id = projectList.map((i) => i._id);
|
|
|
+ const project_id = projectList.map(i => i._id);
|
|
|
filter.project_id = project_id;
|
|
|
delete filter.project_name;
|
|
|
}
|
|
@@ -200,8 +200,8 @@ class MatchTeamGroupService extends CrudService {
|
|
|
if (person_type === 'Race.User') {
|
|
|
|
|
|
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));
|
|
|
+ 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;
|
|
|
});
|
|
@@ -211,7 +211,7 @@ class MatchTeamGroupService extends CrudService {
|
|
|
const teamApplys = await this.teamApplyModel.find({ _id: person });
|
|
|
const parr = [];
|
|
|
for (const p of person) {
|
|
|
- const r = teamApplys.find((f) => ObjectId(f._id).equals(p));
|
|
|
+ const r = teamApplys.find(f => ObjectId(f._id).equals(p));
|
|
|
if (r) {
|
|
|
const { one_member_name, two_member_name } = r;
|
|
|
parr.push({ id: p, name: `${one_member_name}-${two_member_name}` });
|
|
@@ -228,8 +228,8 @@ class MatchTeamGroupService extends CrudService {
|
|
|
if (person_type === 'Race.User') {
|
|
|
|
|
|
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));
|
|
|
+ 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;
|
|
|
});
|
|
@@ -239,7 +239,7 @@ class MatchTeamGroupService extends CrudService {
|
|
|
const teamApplys = await this.teamApplyModel.find({ _id: person });
|
|
|
const parr = [];
|
|
|
for (const p of person) {
|
|
|
- const r = teamApplys.find((f) => ObjectId(f._id).equals(p));
|
|
|
+ const r = teamApplys.find(f => ObjectId(f._id).equals(p));
|
|
|
if (r) {
|
|
|
const { one_member_name, two_member_name } = r;
|
|
|
parr.push({ id: p, name: `${one_member_name}-${two_member_name}` });
|
|
@@ -258,7 +258,7 @@ class MatchTeamGroupService extends CrudService {
|
|
|
* @return {Boolean} 是否可以操作
|
|
|
*/
|
|
|
async canOpera(match_id) {
|
|
|
- const num = await this.matchModel.count({ _id: match_id, status: ['1', '2'] });
|
|
|
+ const num = await this.matchModel.count({ _id: match_id, status: [ '1', '2' ] });
|
|
|
return num > 0;
|
|
|
}
|
|
|
}
|