lrf 2 rokov pred
rodič
commit
91b8c67022

+ 101 - 0
app/controller/config/.eliminate.js

@@ -0,0 +1,101 @@
+module.exports = {
+  create: {
+    requestBody: [
+      'match_id',
+      'group_id',
+      'project_id',
+      'address_id',
+      'referee_id',
+      'match_time',
+      'player_type',
+      'player_one',
+      'player_one_score',
+      'player_one_node',
+      'player_two',
+      'player_two_score',
+      'player_two_node',
+      'is_change',
+      'status',
+      'winner',
+    ],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: [
+      'match_id',
+      'group_id',
+      'project_id',
+      'address_id',
+      'referee_id',
+      'match_time',
+      'player_type',
+      'player_one',
+      'player_one_score',
+      'player_one_node',
+      'player_two',
+      'player_two_score',
+      'player_two_node',
+      'is_change',
+      'status',
+      'winner',
+    ],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+        match_id: 'match_id',
+        group_id: 'group_id',
+        project_id: 'project_id',
+        address_id: 'address_id',
+        referee_id: 'referee_id',
+        'match_time@start': 'match_time@start',
+        'match_time@end': 'match_time@end',
+        player_type: 'player_type',
+        player_one: 'player_one',
+        player_two: 'player_two',
+        is_change: 'is_change',
+        status: 'status',
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+  graphData: {
+    parameters: {
+      query: {
+        match_id: 'match_id',
+        group_id: 'group_id',
+        project_id: 'project_id',
+      },
+    },
+  },
+  playerList: {
+    parameters: {
+      query: {
+        match_id: 'match_id',
+        group_id: 'group_id',
+        project_id: 'project_id',
+      },
+    },
+  },
+};

+ 13 - 0
app/controller/eliminate.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./config/.eliminate.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
+
+// 
+class EliminateController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.eliminate;
+  }
+}
+module.exports = CrudController(EliminateController, meta);

+ 11 - 1
app/controller/home.js

@@ -3,12 +3,22 @@ const Controller = require('egg').Controller;
 const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
 const { BusinessError, ErrorCode } = require('naf-core').Error;
 const { ObjectId } = require('mongoose').Types;
+const _ = require('lodash');
 
 // 项目测试及管理员登陆
 class HomeController extends Controller {
   async index() {
     const { ctx } = this;
-    ctx.body = 'hello';
+    ctx.body = 'hei!';
+    // const match_id = '630ec4700a92b0a015ccfd14';
+    // const group_id = '6318277947be96470e849b6a';
+    // const project_id = '631827f047be96470e849bc1';
+    // await this.ctx.service.matchTeamGroup.checkEliminate(match_id, group_id, project_id);
+  }
+  async util() {
+    const body = this.ctx.request.body;
+    const data = await this.ctx.service.eliminate.toNextRace(body);
+    this.ctx.ok({ data });
   }
 }
 module.exports = CrudController(HomeController, {});

+ 53 - 0
app/model/race/eliminate.js

@@ -0,0 +1,53 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 淘汰赛赛程
+const eliminate = {
+  match_id: { type: String, required: false, zh: '赛事i', ref: 'Race.Match' }, //
+  group_id: { type: String, required: false, zh: '组别id', ref: 'Race.MatchGroup' }, //
+  project_id: { type: String, required: false, zh: '项目id', ref: 'Race.MatchProject' }, //
+  address_id: { type: String, required: false, zh: '场地id', ref: 'Race.MatchAddress' }, //
+  referee_id: { type: String, required: false, zh: '裁判id', ref: 'Race.User' }, //
+  match_time: { type: String, required: false, zh: '比赛时间' }, //
+  player_type: { type: String, required: false, zh: '选手类型' }, // 0:单打,user;1:双打,teamApply
+  player_one: { type: String, required: false, zh: '选手一' }, //
+  player_one_score: { type: Number, required: false, zh: '选手一比分' }, //
+  player_one_node: { type: String, required: false, zh: '选手一节点' }, //
+  player_two: { type: String, required: false, zh: '选手二' }, //
+  player_two_score: { type: String, required: false, zh: '选手二比分' }, //
+  player_two_node: { type: String, required: false, zh: '选手二节点' }, //
+  is_change: { type: String, required: false, zh: '是否交换' }, //
+  status: { type: String, required: false, default: '0', zh: '赛程状态' }, // 0:待开始,1:已开始,2:已结束
+  winner: { type: String, required: false, zh: '胜者' }, //
+};
+const schema = new Schema(eliminate, { toJSON: { getters: true, virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ match_id: 1 });
+schema.index({ group_id: 1 });
+schema.index({ project_id: 1 });
+schema.index({ address_id: 1 });
+schema.index({ referee_id: 1 });
+schema.index({ match_time: 1 });
+schema.index({ player_type: 1 });
+schema.index({ player_one: 1 });
+schema.index({ player_two: 1 });
+schema.index({ is_change: 1 });
+schema.index({ status: 1 });
+
+schema.plugin(metaPlugin);
+
+const source = 'race';
+module.exports = app => {
+  const is_multiple = app.mongooseDB.clients;
+  let model;
+  if (is_multiple) {
+    const conn = app.mongooseDB.get(source);
+    model = conn.model('Eliminate', schema, 'eliminate');
+  } else {
+    const { mongoose } = app;
+    model = mongoose.model('Eliminate', schema, 'eliminate');
+  }
+  return model;
+};

+ 2 - 0
app/router.js

@@ -23,6 +23,7 @@ module.exports = app => {
   const ipAddress = getIPAdress();
   console.log(`前缀:http://${ipAddress}:${cluster.listen.port}${routePrefix}`);
   router.get('/', controller.home.index);
+  router.post('/', controller.home.util);
   require('./z_router/user')(app); // 比赛模块用户
   require('./z_router/match')(app); // 比赛信息
   require('./z_router/matchGroup')(app); // 比赛组别
@@ -34,4 +35,5 @@ module.exports = app => {
   require('./z_router/matchTeamGroup')(app); // 小组赛设置
   require('./z_router/matchAddress')(app); // 场地设置
   require('./z_router/matchSmallGroupSchedule')(app); // 小组赛赛程
+  require('./z_router/eliminate')(app); // 淘汰赛赛程
 };

+ 362 - 0
app/service/eliminate.js

@@ -0,0 +1,362 @@
+'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');
+
+class EliminateService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'eliminate');
+    this.model = this.ctx.model.Race.Eliminate;
+    this.matchModel = this.ctx.model.Race.Match;
+    this.matchGroupModel = this.ctx.model.Race.MatchTeamGroup;
+  }
+  /**
+   * 获取流程图数据
+   * @param {Object} param 比赛项目的参数
+   * @return {Array} 选手列表
+   */
+  async playerList({ match_id, group_id, project_id }) {
+    assert(match_id, '缺少赛事信息');
+    assert(group_id, '缺少组别信息');
+    assert(project_id, '缺少项目信息');
+    const match = await this.matchModel.findById(match_id);
+    if (!match) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到赛事信息');
+    const { format } = match;
+    // 0为小组赛,不需要这里处理
+    if (format === '0') return;
+    let players = [];
+    // 1.为淘汰赛,直接找项目的报名选手进行安排
+    // 2.为小组后淘汰,先找项目的小组再给小组排名;然后根据每组的取前几,决定淘汰赛选手
+    const groupResult = await this.ctx.model.Race.MatchSmallGroupSchedule.find({ project_id, status: '2' });
+    const r = await this.groupRanking(groupResult);
+    for (const team_id in r) {
+      const list = r[team_id];
+      for (const p of list) {
+        players.push(p.player);
+      }
+    }
+    const head = _.head(groupResult);
+    const player_type = _.get(head, 'player_type');
+    if (player_type === 'Race.TeamApply') {
+      const list = await this.ctx.service.teamApply.query({ _id: players });
+      players = list.map(i => {
+        const { one_member_name, two_member_name, _id } = i;
+        const obj = { _id, name: `${one_member_name}-${two_member_name}` };
+        return obj;
+      });
+    }
+    return players;
+  }
+
+  /**
+   * 获取流程图数据
+   * @param {Object} param 比赛项目的参数
+   * @return {Object} {nodes,edges} 流程图数据
+   */
+  async graphData({ match_id, group_id, project_id }) {
+    assert(match_id, '缺少赛事信息');
+    assert(group_id, '缺少组别信息');
+    assert(project_id, '缺少项目信息');
+    const match = await this.matchModel.findById(match_id);
+    if (!match) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到赛事信息');
+    const { format } = match;
+    // 0为小组赛,不需要这里处理
+    if (format === '0') return;
+    // 1.为淘汰赛,直接找项目的报名选手进行安排
+    // 2.为小组后淘汰,先找项目的小组再给小组排名;然后根据每组的取前几,决定淘汰赛选手
+    // 总之第一步是将选手取出来
+    const groupResult = await this.ctx.model.Race.MatchSmallGroupSchedule.find({ project_id, status: '2' });
+    const r = await this.groupRanking(groupResult);
+    const players = [];
+    for (const team_id in r) {
+      const list = r[team_id];
+      for (const p of list) {
+        players.push(p.player);
+      }
+    }
+    const level = this.getLevel(players.length);
+    const chartData = this.getChartData(level);
+    return chartData;
+  }
+
+  /**
+   * 获取赛事流程数据(在matchTeamGroup的service中使用的)
+   * 利用边关系,2个节点指向同一节点,即为一场比赛
+   * @param {Object} data 流程图数据
+   * @property {Array} edges 流程图数据的边关系
+   * @return {Array} 赛事流程数据
+   */
+  getEliminateData(data) {
+    const { edges } = data;
+    let stop = false;
+    const schList = [];
+    let dupAll = JSON.parse(JSON.stringify(edges));
+    while (!stop) {
+      const dup = JSON.parse(JSON.stringify(dupAll));
+      // 取出第一个关系
+      const head = dup[0];
+      // 删除第一个关系
+      dup.shift();
+      // 查看是否有与第一个关系指向一个目标的地方
+      const r = dup.find(f => f.target === head.target);
+      if (r) {
+        // 有,则将这俩关系组为一个比赛,然后在dup中删除
+        const sch = { player_one_node: head.source, player_two_node: r.source };
+        schList.push(sch);
+        const ri = dup.find(f => f.target === head.target);
+        dup.splice(ri, 1);
+      }
+      dupAll = dup;
+      if (dupAll.length <= 0) stop = true;
+    }
+    return schList;
+  }
+
+  // 获取表单数据
+  getChartData(level) {
+    let returnData = {};
+    const nodes = [];
+    const edges = [];
+    // 生成基数层
+    const allPersonNumber = 2 ** level;
+    for (let i = 1; i <= allPersonNumber; i++) {
+      const level = 1; // 基数层固定为第一层
+      const node = this.getNode(level, i);
+      nodes.push(node);
+    }
+    // 生成 胜败组
+    const winnerTeamLine = allPersonNumber / 2;
+    for (let i = 1; i <= allPersonNumber; i++) {
+      const level = 2; // 胜负组固定为第二层
+      const mark = i <= winnerTeamLine ? 'w' : 'l';
+      const node = this.getNode(level, i, mark);
+      nodes.push(node);
+      // 但是只有 胜者组线 以前会产生 边关系; 胜者组线以后的数据为败者组,不与基数层产生关系线
+      if (i <= winnerTeamLine) {
+        const { level, pos, id } = node;
+        const source1 = `${level - 1}-${2 * pos - 1}`;
+        const source2 = `${level - 1}-${2 * pos}`;
+        const target = id;
+        const edge1 = this.getEdge(source1, target);
+        const edge2 = this.getEdge(source2, target);
+        edges.push(edge1, edge2);
+      }
+    }
+
+    // 接下来开始进行赛事统一处理
+    returnData = this.nextProcess(3, nodes, edges);
+
+    return returnData;
+  }
+
+  nextProcess(startLevel, nodes, edges) {
+    // 1.正常进行安排:level向前进
+    const lastLevel = nodes.filter(f => f.level === startLevel - 1);
+    const group = _.chunk(lastLevel, 2);
+    const thisLevelNodes = [];
+    const thisLevelEdges = [];
+    for (let i = 1; i <= group.length; i++) {
+      const e = group[i - 1];
+      const source1 = _.head(e);
+      const source2 = _.last(e);
+      const mark1 = _.get(source1, 'mark');
+      const mark2 = _.get(source2, 'mark');
+      // 先检查mark是否是一致的,如果不一致,就不需要处理了
+      if (mark1 !== mark2) continue;
+      const nl = startLevel;
+      const pos = i;
+      const node = this.getNode(nl, pos, mark1);
+      const edge1 = this.getEdge(source1.id, node.id);
+      const edge2 = this.getEdge(source2.id, node.id);
+      thisLevelNodes.push(node);
+      thisLevelEdges.push(edge1, edge2);
+    }
+    // 2.检查当前层级是否应该加入败者的比赛(例如:4进2, 剩余2个人要决出名次,就需要加比赛)
+    const thisLevelNodesGroup = _.chunk(thisLevelNodes, 2);
+    for (let i = 0; i < thisLevelNodesGroup.length; i++) {
+      const e = thisLevelNodesGroup[i];
+      // 先检查mark是否是一致的,如果不一致,就不需要处理了
+      const s1 = _.head(e);
+      const s2 = _.last(e);
+      if (s1.mark !== s2.mark) continue;
+      // 获取最后一个节点,为了下面计算新节点的pos
+      const last = _.last(thisLevelNodes);
+      const groupLast = _.last(e);
+      const mark = `${_.get(groupLast, 'mark')}l`;
+      const pos = _.get(last, 'pos') + 1;
+      const level = startLevel;
+      // 这地方应该生成的是
+      const obj1 = this.getNode(level, pos, mark);
+      const obj2 = this.getNode(level, pos + 1, mark);
+      thisLevelNodes.push(obj1, obj2);
+    }
+    nodes.push(...thisLevelNodes);
+    edges.push(...thisLevelEdges);
+    if (thisLevelNodes.length > 0) {
+      const { nodes: sn, edges: se } = this.nextProcess(startLevel + 1, nodes, edges);
+      nodes = sn;
+      edges = se;
+    }
+    return { nodes, edges };
+  }
+
+  getNode(level, pos, mark, name = '选手') {
+    const id = `${mark ? `${mark}-` : ''}${level}-${pos}`;
+    const nName = `${name}${id}`;
+    return { id, name: nName, level, pos, mark };
+  }
+  getEdge(source, target) {
+    return { source, target };
+  }
+
+  async getPersonNumber({ match_id, group_id, project_id }) {
+    const list = await this.matchGroupModel.find({ match_id, group_id, project_id }, { rise: 1 });
+    const number = list.reduce((p, n) => p + parseInt(n.rise) || 0, 0);
+    return number;
+  }
+
+  /**
+   * 返回按比赛结果,将各个小组晋级的选手及成绩
+   * @param {Array} list 某项目的所有比赛
+   * @return {Array} {team_id:[{player,win,score}]}
+   */
+  async groupRanking(list) {
+    list = JSON.parse(JSON.stringify(list));
+    // 先看每场比赛有没有胜者,有胜者就过,没有就设置下
+    list = list.map(i => {
+      const { winner, player_one, player_one_score, player_two, player_two_score } = i;
+      if (winner) return i;
+      if (player_one_score > player_two_score) i.winner = player_one;
+      else i.winner = player_two;
+      return i;
+    });
+    list = _.groupBy(list, 'team_id');
+    for (const team_id in list) {
+      const groups = list[team_id];
+      // 过滤出选手
+      let players = [];
+      const p1s = groups.map(i => i.player_one);
+      const p2s = groups.map(i => i.player_two);
+      players.push(...p1s, ...p2s);
+      players = _.uniq(players);
+      // 转换成object[], player:选手; win: 胜场; score:净胜球
+      players = players.map(i => ({ player: i, win: 0, score: 0 }));
+      for (const g of groups) {
+        const { winner, player_one, player_one_score, player_two, player_two_score } = g;
+        const p1RoundScore = this.getScore(player_one_score, player_two_score);
+        const p2RoundScore = this.getScore(player_two_score, player_one_score);
+        const p1 = players.find(f => f.player === player_one);
+        const p2 = players.find(f => f.player === player_two);
+        // p1,p2谁没有就不行
+        if (!p1 || !p2) continue;
+        p1.score = p1.score + p1RoundScore;
+        p2.score = p2.score + p2RoundScore;
+        if (winner === player_one) p1.win += 1;
+        else p2.win += 1;
+      }
+      players = _.orderBy(players, [ 'win', 'score' ], [ 'desc', 'desc' ]);
+      const team = await this.ctx.model.Race.MatchTeamGroup.findById(team_id);
+      if (!team) continue;
+      const { rise } = team;
+      const toNext = _.head(_.chunk(players, rise));
+      list[team_id] = toNext;
+    }
+    return list;
+  }
+  /**
+   * 计算净胜分
+   * @param {String|Number} s1 分数1
+   * @param {String|Number} s2 分数2
+   * @return {Number} 净胜分
+   */
+  getScore(s1, s2) {
+    return parseInt(s1) - parseInt(s2);
+  }
+
+  /**
+   * 计算比赛轮数
+   * @param {Number} number 淘汰赛总人数
+   * @return {Number} 比赛轮数
+   */
+  getLevel(number) {
+    let i = 1;
+    let stop = false;
+    while (!stop) {
+      const num = 2 ** i;
+      if (num === number) stop = true;
+      else if (i > 10) stop = true;
+      else i++;
+    }
+    if (i > 10) throw new BusinessError(ErrorCode.SERVICE_FAULT, '人数过多,请使用小组赛+淘汰赛赛制');
+    return i;
+  }
+
+  // 如果打完比赛,则自动推进
+  async afterUpdate(filter, data) {
+    const { status } = data;
+    if (status === '2') await this.toNextRace(data);
+    return data;
+  }
+  // 自动推进至下一场
+  async toNextRace(data) {
+    const { match_id, group_id, project_id, player_one, player_one_score, player_one_node, player_two, player_two_node, player_two_score } = data;
+    let winner = _.get(data, 'winner');
+    let looser;
+    // 找到输家
+    if (!winner) {
+      if (player_one_score > player_two_score) winner = player_one;
+      else winner = player_two;
+    }
+    if (winner === player_one) looser = player_two;
+    else looser = player_one;
+
+    const number = await this.getPersonNumber({ match_id, group_id, project_id });
+    const chartLevel = this.getLevel(number);
+    const chartData = this.getChartData(chartLevel);
+    // 通过整图关系,找到下一步
+    const { edges, nodes } = chartData;
+    // 通过边关系找到下一节点
+    const list = edges.filter(f => f.source === player_one_node || f.source === player_two_node);
+    const getTarget = nodeEdge => _.get(nodeEdge, 'target');
+    if (getTarget(_.head(list)) !== getTarget(_.last(list))) throw new BusinessError(ErrorCode.DATA_INVALID, '两个选手的图位置错误');
+    // 确定了胜者晋级的节点id
+    const target = getTarget(_.head(list));
+    const node = nodes.find(f => f.id === target);
+    const { id } = node;
+    const wQeury = {
+      $or: [
+        { player_one_node: id, player_one: { $exists: false } },
+        { player_two_node: id, player_two: { $exists: false } },
+      ],
+    };
+    const wEData = await this.model.findOne(wQeury);
+    if (id === wEData.player_one_node) wEData.player_one = winner;
+    else wEData.player_two = winner;
+    await wEData.save();
+    // 再得出败者的节点id
+    const { mark, level } = node;
+    let midArr = nodes.filter(f => f.level === level);
+    // 先过滤掉胜者节点的mark类型
+    midArr = midArr.filter(f => f.mark !== mark);
+    // 再依次找,哪个节点没有人,没有人就安排上
+    midArr = _.orderBy(midArr, [ 'pos' ], [ 'asc' ]);
+    for (const n of midArr) {
+      const { id } = n;
+      const query = {
+        $or: [
+          { player_one_node: id, player_one: { $exists: false } },
+          { player_two_node: id, player_two: { $exists: false } },
+        ],
+      };
+      const eliminate = await this.model.findOne(query);
+      if (!eliminate) continue;
+      if (eliminate.player_one_node === id) eliminate.player_one = looser;
+      else eliminate.player_two = looser;
+      await eliminate.save();
+      break;
+    }
+  }
+}
+
+module.exports = EliminateService;

+ 1 - 1
app/service/match.js

@@ -42,7 +42,7 @@ class MatchService extends CrudService {
         const users = [];
         for (const sign of signs) {
           const userObj = _.get(sign, 'user_id.user_id');
-          const user = _.pick(userObj, [ 'icon', 'name' ]);
+          const user = _.pick(userObj, ['icon', 'name']);
           user._id = _.get(sign, 'user_id._id');
           users.push(user);
         }

+ 18 - 0
app/service/matchTeamGroup.js

@@ -18,6 +18,7 @@ class MatchTeamGroupService extends CrudService {
     this.userModel = this.ctx.model.Race.User;
     this.matchModel = this.ctx.model.Race.Match;
     this.matchProjectModel = this.ctx.model.Race.MatchProject;
+    this.eliminateModel = this.ctx.model.Race.Eliminate;
   }
   /**
    * 根据项目和选手类型查询可选择的分组人员
@@ -74,6 +75,23 @@ class MatchTeamGroupService extends CrudService {
     // 先删除该比赛项目的所有小组
     await this.model.deleteMany({ project_id });
     await this.model.insertMany(data);
+    // 检查并添加淘汰赛信息
+    const group_id = _.get(_.head(data), 'group_id');
+    await this.checkEliminate(match_id, group_id, project_id);
+  }
+  // 检查并创建淘汰赛赛程
+  async checkEliminate(match_id, group_id, project_id) {
+    // 有赛程就删了,重新创建
+    await this.eliminateModel.deleteMany({ match_id, group_id, project_id });
+    const groups = await this.model.find({ match_id, group_id, project_id });
+    const personTotal = groups.reduce((p, n) => p + (parseInt(n.rise) || 0), 0);
+    const level = this.ctx.service.eliminate.getLevel(personTotal);
+    const chartData = this.ctx.service.eliminate.getChartData(level);
+    let eliminateData = this.ctx.service.eliminate.getEliminateData(chartData);
+    const head = _.head(groups);
+    const player_type = _.get(head, 'person_type');
+    eliminateData = eliminateData.map(i => ({ ...i, player_type, match_id, group_id, project_id }));
+    await this.eliminateModel.insertMany(eliminateData);
   }
 
   async auto({ match_id, group_id, project_id, team_number = 0 }) {

+ 21 - 0
app/z_router/eliminate.js

@@ -0,0 +1,21 @@
+'use strict';
+// 路由配置
+const path = require('path');
+const regPath = path.resolve('app', 'public', 'routerRegister');
+const routerRegister = require(regPath);
+const rkey = 'eliminate';
+const ckey = 'eliminate';
+const keyZh = '淘汰赛赛程';
+const routes = [
+  { method: 'get', path: `${rkey}/playerList`, controller: `${ckey}.playerList`, name: `${ckey}PlayerList`, zh: `${keyZh}淘汰赛选手数据` },
+  { method: 'get', path: `${rkey}/graphData`, controller: `${ckey}.graphData`, name: `${ckey}GraphData`, zh: `${keyZh}淘汰赛流程图数据查询` },
+  { method: 'get', path: `${rkey}`, controller: `${ckey}.index`, name: `${ckey}Query`, zh: `${keyZh}列表查询` },
+  { method: 'get', path: `${rkey}/:id`, controller: `${ckey}.show`, name: `${ckey}Show`, zh: `${keyZh}查询` },
+  { method: 'post', path: `${rkey}`, controller: `${ckey}.create`, name: `${ckey}Create`, zh: `创建${keyZh}` },
+  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, name: `${ckey}Update`, zh: `修改${keyZh}` },
+  { method: 'delete', path: `${rkey}/:id`, controller: `${ckey}.destroy`, name: `${ckey}Delete`, zh: `删除${keyZh}` },
+];
+
+module.exports = app => {
+  routerRegister(app, routes, keyZh, rkey, ckey);
+};