lrf 4 months ago
parent
commit
1f0c24121f
2 changed files with 119 additions and 5 deletions
  1. 116 3
      src/controller/match/matchExt.controller.ts
  2. 3 2
      src/error/service.error.ts

+ 116 - 3
src/controller/match/matchExt.controller.ts

@@ -149,6 +149,7 @@ export class MatchExtController implements BaseController {
    * @param data body
    * @property match_id 赛事id
    * @property start_time 初赛时间
+   * @property ids 报名数据id
    */
   @Post("/step2/fill", { routerName: '初赛阶段-组织初审-补充初赛时间信息' })
   async step2Fill(@Body() data: object) {
@@ -174,12 +175,124 @@ export class MatchExtController implements BaseController {
     const ids = get(data, 'ids', [])
     await this.matchRegService.update({ id: ids, ext_status: '2', status: '0' }, { start_time })
   }
-
+  /**
+   * 进入: 初赛阶段-公示名单, 只修改状态即可
+   * @param data body
+   * @property match_id 赛事id
+   */
   @Post('/step3', { routerName: '初赛阶段-公示名单' })
-  async step3(@Body() data: object) { }
+  async step3(@Body() data: object) {
+    /**
+    * 检查内容:
+    *  赛事拓展表:
+    *    ext.status = "2"
+    * 修改内容: 
+    *  赛事拓展表:
+    *    ext.status => "3" 变为 初赛阶段-公示名单
+    *  赛事报名表:
+    *    reg.ext_status: "2" => '3'
+    */
+    const match_id = get(data, 'match_id')
+    await this.service.checkMatchExtStatus(match_id, "2")
+    await this.service.update({ match_id }, { status: '2' })
+    await this.matchRegService.update({ match_id, ext_status: '1' }, { ext_status: '2' })
 
+  }
+  /**
+   * 查询初审名单
+   * @param match_id 赛事id
+   */
+  @Get('/step3/nameList/match_id', { routerName: '初赛阶段-公示名单-名单查询' })
+  async step3NameList(@Param('match_id') match_id: string) {
+    /**
+    * 检查内容:
+    *  赛事拓展表:
+    *    ext.status = "3"
+    * 查询内容: 
+    *  赛事报名表:
+    *    reg.ext_status: "3";
+    */
+    await this.service.checkMatchExtStatus(match_id, "3")
+    const list = await this.matchRegService.query({ match_id, ext_status: '3' })
+    return list;
+  }
+
+  /**
+   * 进入: 初赛阶段-赛事进行, 只修改状态即可
+   * @param data body
+   * @property match_id 赛事id
+   */
   @Post('/step4', { routerName: '初赛阶段-赛事进行' })
-  async step4(@Body() data: object) { }
+  async step4(@Body() data: object) {
+    /**
+    * 检查内容:
+    *  赛事拓展表:
+    *    ext.status = "3"
+    * 修改内容: 
+    *  赛事拓展表:
+    *    ext.status => "4" 变为 初赛阶段-赛事进行
+    *  赛事报名表:
+    *    reg.ext_status: "3" => '4'
+    */
+    const match_id = get(data, 'match_id')
+    await this.service.checkMatchExtStatus(match_id, "3")
+    await this.service.update({ match_id }, { status: '4' })
+    await this.matchRegService.update({ match_id, ext_status: '3' }, { ext_status: '4' })
+  }
+  /**
+   * 初赛阶段-赛事进行-上传成绩, 只上传分数
+   * @param match_id 赛事id
+   * @property reg_id 选手id
+   * @property status 是否通过; 1:通过初赛;2未通过初赛
+   * @property score 分数
+   */
+  @Post('/step4/score/:match_id', { routerName: '初赛阶段-赛事进行-上传成绩' })
+  async step4Score(@Param('match_id') match_id: string, @Body() data: object) {
+    /**
+    * 检查内容:
+    *  赛事拓展表:
+    *    ext.status = "4"
+    * 修改内容: 
+    *  赛事报名表:
+    *    reg.ext_status: "4"
+    *    reg.status: '0'
+    *    reg.score = ${score}
+    */
+    await this.service.checkMatchExtStatus(match_id, "4")
+    const reg_id = get(data, 'reg_id')
+    // const status = get(data, 'status')
+    const score = get(data, 'score')
+    const query = { id: reg_id, ext_status: '4', status: '0' }
+    const regData = await this.matchRegService.fetch(query)
+    if (!regData) {
+      // 抛出异常: 该选手不符合上传成绩的要求,请检查选手信息
+      throw new ServiceError(ErrorCode.MATCH_REG_USER_ERROR);
+    }
+    await this.matchRegService.update({ id: reg_id }, { score })
+  }
+
+  /**
+   * 决定决赛名单
+   * @param match_id 赛事id
+   * @param data body
+   * @property ids 报名信息id
+   */
+  @Post('/step4/to5/:match_id', { routerName: "初赛阶段-赛事进行-选择决赛名单" })
+  async step4To5(@Param('match_id') match_id: string, @Body() data: object) {
+    /**
+    * 检查内容:
+    *  赛事拓展表:
+    *    ext.status = "4"
+    * 修改内容: 
+    *  赛事报名表:
+    *    reg.ext_status: "4"
+    *    reg.status: '0'
+    *    reg.status: '0' => '1'
+    */
+    await this.service.checkMatchExtStatus(match_id, "4")
+    const ids = get(data, 'ids', [])
+    await this.matchRegService.update({ id: ids, ext_status: '4', status:'0' }, { status: '1' })
+  }
 
   @Post('/step5', { routerName: '决赛阶段-组织决赛' })
   async step5(@Body() data: object) { }

+ 3 - 2
src/error/service.error.ts

@@ -67,8 +67,9 @@ export enum ErrorCode {
   MATCH_STATUS_ERROR = "MATCH_STATUS_ERROR",
   MATCH_EXT_STATUS_ERROR = "MATCH_EXT_STATUS_ERROR",
   MATCH_REG_NOT_FOUND = "MATCH_REG_NOT_FOUND",
-  MATCH_REG_STATUS_ERROR ="MATCH_REG_STATUS_ERROR",
-  TIME_FORMAT_ERROR ="TIME_FORMAT_ERROR",
+  MATCH_REG_STATUS_ERROR = "MATCH_REG_STATUS_ERROR",
+  MATCH_REG_USER_ERROR = "MATCH_REG_USER_ERROR",
+  TIME_FORMAT_ERROR = "TIME_FORMAT_ERROR",
 
   // export
   NO_EXPORT_SETTING = 'NO_EXPORT_SETTING',