lrf 2 年之前
父節點
當前提交
6630f1978a
共有 3 個文件被更改,包括 18 次插入4 次删除
  1. 1 0
      app/controller/config/.matchTeamGroup.js
  2. 3 3
      app/model/race/matchTeamGroup.js
  3. 14 1
      app/service/matchTeamGroup.js

+ 1 - 0
app/controller/config/.matchTeamGroup.js

@@ -26,6 +26,7 @@ module.exports = {
         project_id: 'project_id',
         project_id: 'project_id',
         name: 'name',
         name: 'name',
         rise: 'rise',
         rise: 'rise',
+        project_name: 'project_name',
       },
       },
       // options: {
       // options: {
       //   "meta.state": 0 // 默认条件
       //   "meta.state": 0 // 默认条件

+ 3 - 3
app/model/race/matchTeamGroup.js

@@ -4,9 +4,9 @@ const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
 
 
 // 小组赛组设置
 // 小组赛组设置
 const match_team_group = {
 const match_team_group = {
-  match_id: { type: String, required: true, zh: '赛事id', ref: 'Match', getProp: ['name'] }, // 比赛信息中的名称
-  group_id: { type: String, required: true, zh: '组别id', ref: 'MatchGroup', getProp: ['name'] }, // 赛事组别中的名称
-  project_id: { type: String, required: true, zh: '项目id', ref: 'MatchProject', getProp: ['name'] }, // 组内项目中的名称
+  match_id: { type: String, required: true, zh: '赛事id', ref: 'Match', getProp: [ 'name' ] }, // 比赛信息中的名称
+  group_id: { type: String, required: true, zh: '组别id', ref: 'MatchGroup', getProp: [ 'name' ] }, // 赛事组别中的名称
+  project_id: { type: String, required: true, zh: '项目id', ref: 'MatchProject', getProp: [ 'name' ] }, // 组内项目中的名称
   name: { type: String, required: true, zh: '分组名称' }, //
   name: { type: String, required: true, zh: '分组名称' }, //
   person_type: { type: String, required: false, zh: '人员类型' }, // 单打:user;双打:teamApply
   person_type: { type: String, required: false, zh: '人员类型' }, // 单打:user;双打:teamApply
   person: { type: Array, required: false, zh: '组内人员' }, // refPath: 'person_type'
   person: { type: Array, required: false, zh: '组内人员' }, // refPath: 'person_type'

+ 14 - 1
app/service/matchTeamGroup.js

@@ -17,6 +17,7 @@ class MatchTeamGroupService extends CrudService {
     this.baseUserModel = this.ctx.model.Base.User;
     this.baseUserModel = this.ctx.model.Base.User;
     this.userModel = this.ctx.model.Race.User;
     this.userModel = this.ctx.model.Race.User;
     this.matchModel = this.ctx.model.Race.Match;
     this.matchModel = this.ctx.model.Race.Match;
+    this.matchProjectModel = this.ctx.model.Race.MatchProject;
   }
   }
   /**
   /**
    * 根据项目和选手类型查询可选择的分组人员
    * 根据项目和选手类型查询可选择的分组人员
@@ -160,6 +161,18 @@ class MatchTeamGroupService extends CrudService {
     return { filter, update };
     return { filter, update };
   }
   }
 
 
+
+  async beforeQuery(filter) {
+    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);
+      filter.project_id = project_id;
+      delete filter.project_name;
+    }
+    return filter;
+  }
+
   // 检查该组的成员是否在该比赛项目中的其他组中
   // 检查该组的成员是否在该比赛项目中的其他组中
   // true:没有问题,可以操作; false:有人在其他组,不能允许操作
   // true:没有问题,可以操作; false:有人在其他组,不能允许操作
   async checkPersonInOtherGroup(data) {
   async checkPersonInOtherGroup(data) {
@@ -220,7 +233,7 @@ class MatchTeamGroupService extends CrudService {
     return data;
     return data;
   }
   }
   async afterFetch(filter, d) {
   async afterFetch(filter, d) {
-    const { person, person_type } = d;
+    const { person = [], person_type } = d;
     if (person_type === 'User') {
     if (person_type === 'User') {
       // 单人
       // 单人
       const conn = this.app.mongooseDB.get('base');
       const conn = this.app.mongooseDB.get('base');