lrf 3 kuukautta sitten
vanhempi
commit
6093b2e321

+ 14 - 2
src/controller/match/matchExt.controller.ts

@@ -485,7 +485,13 @@ export class MatchExtController implements BaseController {
     // 决赛名单,根据顺序升序
     const final_confirm = get(query, 'final_confirm')
     const { data: list } = await this.matchRegService.query({ match_id, ext_status: '5', final_confirm }, { order: { final_order_no: 'ASC' } });
-    return list;
+    const newList = []
+    for (const i of list) {
+      let newItem = cloneDeep(i)
+      newItem = this.matchRegService.dealData(newItem);
+      newList.push(newItem)
+    }
+    return newList;
   }
 
   /**
@@ -664,6 +670,12 @@ export class MatchExtController implements BaseController {
   @Post('/lastList/:match_id', { routerName: '赛事决赛名单' })
   async lastList(@Param('match_id') match_id: string) {
     const list = await this.matchRegService.getArrangeList(match_id)
-    return list;
+    const newList = []
+    for (const i of list) {
+      let newItem = cloneDeep(i)
+      newItem = this.matchRegService.dealData(newItem);
+      newList.push(newItem)
+    }
+    return newList;
   }
 }

+ 2 - 1
src/controller/match/matchRegistration.controller.ts

@@ -46,13 +46,14 @@ export class MatchRegistrationController implements BaseController {
     const { data, total } = await this.service.query(qobj, others);
     const fillList = [];
     for (const i of data) {
-      const newItem = cloneDeep(i);
+      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');
+      newItem = this.service.dealData(newItem);
       fillList.push(newItem);
     }
     return { data: fillList, total };

+ 23 - 1
src/service/match/matchRegistration.service.ts

@@ -3,7 +3,7 @@ import { InjectEntityModel } from '@midwayjs/typeorm';
 import { Repository } from 'typeorm';
 import { BaseServiceV2 } from '../../frame/BaseServiceV2';
 import { MatchRegistration } from '../../entity/match/matchRegistration.entity';
-import { get, orderBy } from 'lodash';
+import { get, isArray, orderBy, replace } from 'lodash';
 @Provide()
 export class MatchRegistrationService extends BaseServiceV2 {
   @InjectEntityModel(MatchRegistration)
@@ -31,4 +31,26 @@ export class MatchRegistrationService extends BaseServiceV2 {
     }
     return freeOrderList;
   }
+
+  async dealData(data) {
+    const info = get(data, 'info')
+    if (!info) return data;
+    if (!isArray(data)) return data;
+    // 特化查询: 找出 项目名称 和 负责人补充信息单位
+    const nameList = [{ key: 'project_name', problem: '项目名称' }, { key: 'person_unit', problem: '负责人单位' }]
+    for (const i of nameList) {
+      const targetProblem = get(i, 'problem')
+      const problemData = info.find(f => {
+        let problem = get(f, 'problem')
+        // 清除所有空格
+        problem = replace(problem, /\s+/g, '');
+        return targetProblem === problem;
+      })
+      if (!problemData) continue;
+      const key = get(i, 'key')
+      const reply = get(problemData, 'reply')
+      data[key] = reply
+    }
+    return data;
+  }
 }