lrf 4 ヶ月 前
コミット
984c1104d7
1 ファイル変更7 行追加3 行削除
  1. 7 3
      src/controller/match/matchRegistration.controller.ts

+ 7 - 3
src/controller/match/matchRegistration.controller.ts

@@ -64,12 +64,16 @@ export class MatchRegistrationController implements BaseController {
       const dbData = await this.userService.create(user);
       regData = { user_id: dbData.id, ...regData }
     }
-    // 制作项目编号
-    const query = { match_id: get(data, 'match_id') }
+    // 检查是否报名
+    const query = { match_id: get(data, 'match_id'), user_id: get(regData, 'user_id') }
     const { total } = await this.service.query(query)
     if (total > 0) throw new ServiceError(ErrorCode.MATCH_USER_HAS_REGISTED)
+    // 制作项目编号
+    const { total: matchRegTotal = 0 } = await this.service.query({ match_id: get(data, 'match_id') })
+    const no = `${get(data, 'match_id')}-${get(regData, 'user_id')}-${matchRegTotal + 1}`
+    regData = { ...regData, no }
     const result = await this.service.create(regData);
-    return false;
+    return result;
   }
 
   @Post('/:id', { routerName: `修改${namePrefix}` })