zs 4 kuukautta sitten
vanhempi
commit
06c62e9cd1

+ 16 - 5
src/controller/match/matchExt.controller.ts

@@ -1,7 +1,7 @@
-import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
+import { ApiTags, ApiQuery } from '@midwayjs/swagger';
 import { Validate } from '@midwayjs/validate';
 import { Controller, Inject, Get, Param, Post, Body, Del, Query } from '@midwayjs/core';
-import { get, omit, pick } from 'lodash';
+import { cloneDeep, get, omit, pick } from 'lodash';
 import { ServiceError, ErrorCode } from '../../error/service.error';
 import { BaseController } from '../../frame/BaseController';
 import { MatchExtService } from '../../service/match/matchExt.service';
@@ -213,8 +213,19 @@ export class MatchExtController implements BaseController {
      *    reg.ext_status: "3";
      */
     await this.service.checkMatchExtStatus(match_id, '3');
-    const data = await this.matchRegService.query({ match_id, ext_status: '3' });
-    return data;
+    const { data } = await this.matchRegService.query({ match_id, ext_status: '3', status: '0' });
+    const fillList = [];
+    for (const i of data) {
+      const newItem = cloneDeep(i);
+      const user_id = get(i, 'user_id');
+      const user = await this.userService.fetch({ id: user_id });
+      if (user) newItem.user_name = get(user, 'nick_name');
+      const match_id = get(i, 'match_id');
+      const match = await this.matchService.fetch({ id: match_id });
+      if (match) newItem.match_name = get(match, 'name');
+      fillList.push(newItem);
+    }
+    return fillList;
   }
 
   /**
@@ -410,7 +421,7 @@ export class MatchExtController implements BaseController {
       // 按理说,不应该出现没有排序的情况
       if (!thisOrderNum) continue;
       // 顺序不一致,说明少了
-      if (lastOrderNum != thisOrderNum) {
+      if (lastOrderNum !== thisOrderNum) {
         // 少了就需要把当前的补上.会出现2种情况, 正常顺序<当前顺序: 按正常顺序进行补充;
         // 正常顺序>当前顺序:说明从此开始,后面的序号都是乱的,是不应该出现的情况.如果出现了,就需要人为调整了.所以只考虑第一个情况
         break;

+ 16 - 15
src/controller/match/matchRegistration.controller.ts

@@ -32,7 +32,7 @@ export class MatchRegistrationController implements BaseController {
   @Inject()
   smsService: AliyunSmsService;
   @Inject()
-  matchExtService: MatchExtService
+  matchExtService: MatchExtService;
 
   @Config('PathConfig.path')
   path;
@@ -70,27 +70,28 @@ export class MatchRegistrationController implements BaseController {
   @Validate()
   async create(@Body() data: object) {
     // 检查赛事拓展表中对应的拓展信息状态,如果不是报名中,则不允许添加
-    const match_id = get(data, 'match_id')
+    const match_id = get(data, 'match_id');
     if (!match_id) {
       // 抛出异常: 需要赛事信息
-      throw new ServiceError(ErrorCode.MATCH_REG_NEED_MATCH_ID)
+      throw new ServiceError(ErrorCode.MATCH_REG_NEED_MATCH_ID);
     }
-    const matchInfo = await this.matchService.fetch({ id: match_id })
+    const matchInfo = await this.matchService.fetch({ id: match_id });
     if (!matchInfo) {
-
+      // 抛出异常: 没找到赛事
+      throw new ServiceError(ErrorCode.DATA_NOT_FOUND);
     }
     const match_status = get(matchInfo, 'match_status');
-    if (match_status != "1") {
+    if (match_status !== '1') {
       // 抛出异常: 该赛事已不处于报名阶段,无法进行报名
       throw new ServiceError(ErrorCode.MATCH_NOT_FOUND);
     }
-    const matchExtInfo = await this.matchExtService.fetch({ match_id })
+    const matchExtInfo = await this.matchExtService.fetch({ match_id });
     if (!matchExtInfo) {
       // 抛出异常: 未找到赛事拓展信息
-      throw new ServiceError(ErrorCode.MATCH_EXT_DATA_NOT_FOUND)
+      throw new ServiceError(ErrorCode.MATCH_EXT_DATA_NOT_FOUND);
     }
-    const match_ext_status = get(matchExtInfo, 'status')
-    if (match_ext_status != '0') {
+    const match_ext_status = get(matchExtInfo, 'status');
+    if (match_ext_status !== '0') {
       // 抛出异常: 该赛事已不处于报名阶段,无法进行报名
       throw new ServiceError(ErrorCode.MATCH_REG_MATCH_IS_NOT_REG);
     }
@@ -183,11 +184,11 @@ export class MatchRegistrationController implements BaseController {
 
   @Post('/score/:id', { routerName: '为初审选手打分' })
   async setScore(@Param('id') id: string, @Body() data: object) {
-    const regData = await this.service.fetch({ id })
-    if (!regData) throw new ServiceError(ErrorCode.DATA_NOT_FOUND)
-    const score = get(data, 'score')
-    if (score) await this.service.update({ id }, { score })
-    return 'ok'
+    const regData = await this.service.fetch({ id });
+    if (!regData) throw new ServiceError(ErrorCode.DATA_NOT_FOUND);
+    const score = get(data, 'score');
+    if (score) await this.service.update({ id }, { score });
+    return 'ok';
   }
 
   @Get('/view/:match_id', { routerName: '查看初审名单结果' })