lrf vor 2 Jahren
Ursprung
Commit
c29f5848b1
5 geänderte Dateien mit 0 neuen und 88 gelöschten Zeilen
  1. 0 8
      app/controller/config/.race.js
  2. 0 13
      app/controller/race.js
  3. 0 1
      app/router.js
  4. 0 50
      app/service/race.js
  5. 0 16
      app/z_router/race.js

+ 0 - 8
app/controller/config/.race.js

@@ -1,8 +0,0 @@
-module.exports = {
-  coachToBeJudge: {
-    requestBody: ['!coach_id', '!school_id'],
-  },
-  userToBeJudge: {
-    requestBody: ['!user_id', '!school_id'],
-  },
-};

+ 0 - 13
app/controller/race.js

@@ -1,13 +0,0 @@
-'use strict';
-const meta = require('./config/.race.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
-
-// 比赛模块的部分交互业务
-class RaceController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.race;
-  }
-}
-module.exports = CrudController(RaceController, meta);

+ 0 - 1
app/router.js

@@ -47,5 +47,4 @@ module.exports = app => {
 
   require('./z_router/view/student')(app); // 学生视图
   require('./z_router/statistics')(app); // 统计
-  require('./z_router/race')(app); // 比赛业务
 };

+ 0 - 50
app/service/race.js

@@ -1,50 +0,0 @@
-'use strict';
-const { CrudService } = require('naf-framework-mongoose-free/lib/service');
-const { BusinessError, ErrorCode } = require('naf-core').Error;
-const _ = require('lodash');
-const assert = require('assert');
-
-// 与race模块相关联的处理
-class RaceService extends CrudService {
-  constructor(ctx) {
-    super(ctx, 'race');
-    this.coachModel = this.ctx.model.User.Coach;
-    this.baseUrl = _.get(this.app.config, 'httpPrefix.race');
-    this.httpUtil = this.ctx.service.util.httpUtil;
-    this.userModel = this.ctx.model.User.User;
-    this.schoolModel = this.ctx.model.User.School;
-  }
-  // 教练成为本校的裁判
-  async coachToBeJudge({ coach_id, school_id }) {
-    const coach = await this.coachModel.findById(coach_id).populate('user_id');
-    if (!coach) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到教练信息');
-    const user_id = _.get(coach, 'user_id._id');
-    const openid = _.get(coach, 'user_id.openid');
-    // 查找parent_id
-    const parent_id = await this.getPatentId(school_id);
-    const obj = { user_id, type: '2', openid, parent_id };
-    const res = await this.httpUtil.cpost(`${this.baseUrl}/user/bindJudge`, obj);
-    return res;
-  }
-  // 用户绑定为教练
-  async userToBeJudge({ user_id, school_id }) {
-    const user = await this.userModel.findById(user_id);
-    if (!user) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到用户信息');
-    const { openid } = user;
-    const obj = { user_id, type: '2', openid, parent_id: await this.getPatentId(school_id) };
-    const res = await this.httpUtil.cpost(`${this.baseUrl}/user/bindJudge`, obj);
-    return res;
-  }
-  // 根据学校id,查询比赛项目中的用户的id
-  async getPatentId(school_id) {
-    const data = await this.schoolModel.findById(school_id).populate('user_id');
-    if (!data) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到学校信息');
-    const user_id = _.get(data, 'user_id._id');
-    if (!user_id) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到学校用户信息');
-    const res = await this.httpUtil.cget(`${this.baseUrl}/user?user_id=${user_id}`);
-    if (!res) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到比赛模块用户信息');
-    return _.get(res, '_id');
-  }
-}
-
-module.exports = RaceService;

+ 0 - 16
app/z_router/race.js

@@ -1,16 +0,0 @@
-'use strict';
-// 路由配置
-const path = require('path');
-const regPath = path.resolve('app', 'public', 'routerRegister');
-const routerRegister = require(regPath);
-const rkey = 'race';
-const ckey = 'race';
-const keyZh = '比赛业务';
-const routes = [
-  { method: 'post', path: `${rkey}/ctbj`, controller: `${ckey}.coachToBeJudge`, name: `${ckey}coachToBeJudge`, zh: `${keyZh}-教练成为本校裁判` },
-  { method: 'post', path: `${rkey}/utbj`, controller: `${ckey}.userToBeJudge`, name: `${ckey}userToBeJudge`, zh: `${keyZh}-教练成为本校裁判` },
-];
-
-module.exports = app => {
-  routerRegister(app, routes, keyZh, rkey, ckey);
-};