Selaa lähdekoodia

比赛申请创建的检查

lrf 2 vuotta sitten
vanhempi
commit
882fd0384c
1 muutettua tiedostoa jossa 12 lisäystä ja 0 poistoa
  1. 12 0
      app/service/teamApply.js

+ 12 - 0
app/service/teamApply.js

@@ -11,6 +11,18 @@ class TeamApplyService extends CrudService {
     this.model = this.ctx.model.Race.TeamApply;
     this.matchSignModel = this.ctx.model.Race.MatchSign;
   }
+
+  async beforeCreate(body) {
+    // 检查该项目下,这个俩用户是否有报名申请
+    const { project_id, one_member_id, one_member_name, two_member_id, two_member_name } = body;
+    let num = await this.checkHasTeamApply(project_id, one_member_id);
+    if (num > 0) throw new BusinessError(ErrorCode.SERVICE_FAULT, `${one_member_name} 在该比赛项目下已有组队申请`);
+    num = await this.checkHasTeamApply(project_id, two_member_id);
+    if (num > 0) throw new BusinessError(ErrorCode.SERVICE_FAULT, `${two_member_name} 在该比赛项目下已有组队申请`);
+    return body;
+  }
+
+
   /**
    * 查询项目下可以组队的人
    * @param {Object} query 地址栏查询条件