zs 1 year ago
parent
commit
c731085e3d
1 changed files with 8 additions and 0 deletions
  1. 8 0
      src/service/course.service.ts

+ 8 - 0
src/service/course.service.ts

@@ -3,6 +3,7 @@ import { InjectEntityModel } from '@midwayjs/typegoose';
 import { ReturnModelType } from '@typegoose/typegoose';
 import { BaseService } from 'free-midway-component';
 import { Course } from '../entity/course.entity';
+import { Application } from '../entity/application.entity';
 type modelType = ReturnModelType<typeof Course>;
 import _ = require('lodash');
 @Provide()
@@ -10,6 +11,9 @@ export class CourseService extends BaseService<modelType> {
   @InjectEntityModel(Course)
   model: modelType;
 
+  @InjectEntityModel(Application)
+  AppModel: ReturnModelType<typeof Application>;
+
   // 排名
   async rankQuery(filter) {
     const { match_id } = filter;
@@ -32,6 +36,10 @@ export class CourseService extends BaseService<modelType> {
       // 获得这支队伍在所有比赛中的胜负情况及积分
       const res = this.computedTeam(list, team_id);
       const info = this.getOtherInfoFromList(list, team_id);
+      await this.AppModel.updateOne(
+        { team_id: team_id },
+        { score: res.score.toString() }
+      );
       rList.push({ ...info, ...res });
     }
     const scoreList = _.orderBy(rList, 'score', ['desc']);