lrf 3 месяцев назад
Родитель
Сommit
d66eaaacf2
1 измененных файлов с 17 добавлено и 3 удалено
  1. 17 3
      src/controller/match/matchRegistration.controller.ts

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

@@ -2,7 +2,7 @@ import { CVO_match, FVO_match, QVO_match, UVAO_match } from '../../interface/pla
 import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
 import { Validate } from '@midwayjs/validate';
 import { Controller, Inject, Get, Param, Post, Body, Del, Query, Config } 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 { MatchRegistrationService } from '../../service/match/matchRegistration.service';
@@ -10,6 +10,7 @@ import { UserService } from '../../service/system/user.service';
 import * as bcrypt from 'bcryptjs';
 import dayjs = require('dayjs');
 import { MatchService } from '../../service/platform/match.service';
+import { ServiceUtilService } from '../../service/serviceUtil.service';
 const namePrefix = '创新大赛-赛事报名';
 @ApiTags(['创新大赛-赛事报名'])
 @Controller('/matchReg', { tagName: namePrefix })
@@ -20,6 +21,8 @@ export class MatchRegistrationController implements BaseController {
   userService: UserService;
   @Inject()
   matchService: MatchService
+  @Inject()
+  serviceUtil: ServiceUtilService
   @Config('PathConfig.path')
   path;
   @Get('/')
@@ -30,8 +33,19 @@ export class MatchRegistrationController implements BaseController {
     const qobj = omit(query, ['skip', 'limit']);
     const others: any = pick(query, ['skip', 'limit']);
     others.order = { time: 'ASC' };
-    const result = await this.service.query(qobj, others);
-    return result;
+    const { data, total } = await this.service.query(qobj, others);
+    const fillList = []
+    for (const i of data) {
+      let 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 { data: fillList, total };
   }
 
   @Get('/:id')