소스 검색

比赛申请创建的检查

lrf 2 년 전
부모
커밋
882fd0384c
1개의 변경된 파일12개의 추가작업 그리고 0개의 파일을 삭제
  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 地址栏查询条件