lrf 2 years ago
parent
commit
ddbd882601

+ 39 - 0
app/controller/config/.matchAddress.js

@@ -0,0 +1,39 @@
+module.exports = {
+  create: {
+    requestBody: ['!belong_id', '!name', 'remark', 'is_use'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['belong_id', 'name', 'remark', 'is_use'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+        belong_id: 'belong_id',
+        name: 'name',
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 81 - 0
app/controller/config/.matchSmallGroupSchedule.js

@@ -0,0 +1,81 @@
+module.exports = {
+  create: {
+    requestBody: [
+      '!match_id',
+      '!group_id',
+      '!project_id',
+      '!team_id',
+      '!address_id',
+      '!referee_id',
+      '!match_time',
+      '!player_type',
+      '!player_one',
+      'player_one_score',
+      '!player_two',
+      'player_two_score',
+      'is_change',
+      'status',
+      'winner',
+    ],
+  },
+  destroy: {
+    params: [ '!id' ],
+    service: 'delete',
+  },
+  update: {
+    params: [ '!id' ],
+    requestBody: [
+      'match_id',
+      'group_id',
+      'project_id',
+      'team_id',
+      'address_id',
+      'referee_id',
+      'match_time',
+      'player_type',
+      'player_one',
+      'player_one_score',
+      'player_two',
+      'player_two_score',
+      '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',
+        team_id: 'team_id',
+        address_id: 'address_id',
+        referee_id: 'referee_id',
+        match_time: 'match_time',
+        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,
+    },
+  },
+};

+ 13 - 0
app/controller/matchAddress.js

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

+ 13 - 0
app/controller/matchSmallGroupSchedule.js

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

+ 32 - 0
app/model/race/matchAddress.js

@@ -0,0 +1,32 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 赛事场地
+const match_address = {
+  belong_id: { type: String, required: true, zh: '归属id', ref: 'user', getProp: [ 'name' ] }, // 用户表中的名称
+  name: { type: String, required: true, zh: '名称' }, //
+  remark: { type: String, required: false, zh: '备注' }, //
+  is_use: { type: String, required: false, default: '0', zh: '是否使用' }, // 0:启用,1:禁用
+};
+const schema = new Schema(match_address, { toJSON: { getters: true, virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ belong_id: 1 });
+schema.index({ name: 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('MatchAddress', schema, 'matchAddress');
+  } else {
+    const { mongoose } = app;
+    model = mongoose.model('MatchAddress', schema, 'matchAddress');
+  }
+  return model;
+};

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

@@ -0,0 +1,53 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 小组赛赛程设置
+const match_small_group_schedule = {
+  match_id: { type: String, required: true, zh: '赛事id', ref: 'Match', getProp: [ 'name' ] }, // 赛事信息中的名称
+  group_id: { type: String, required: true, zh: '组别id', ref: 'Group', getProp: [ 'name' ] }, // 赛事组别中的名称
+  project_id: { type: String, required: true, zh: '项目id', ref: 'Project', getProp: [ 'name' ] }, // 组内项目中的名称
+  team_id: { type: String, required: true, zh: '小组id', ref: 'MatchTeamGroup', getProp: [ 'name' ] }, // 小组赛组设置中的name
+  address_id: { type: String, required: true, zh: '场地id', ref: 'Address', getProp: [ 'name' ] }, // 赛事场地中name
+  referee_id: { type: String, required: true, zh: '裁判id', ref: 'User', getProp: [ 'name' ] }, // 用户表中的name
+  match_time: { type: String, required: true, zh: '比赛时间' }, //
+  player_type: { type: String, required: true, zh: '选手类型' }, // 0:单打,user;1:双打,teamApply
+  player_one: { type: String, required: true, zh: '选手一', refPath: 'player_type' }, //
+  player_one_score: { type: String, required: false, zh: '选手一比分' }, //
+  player_two: { type: String, required: true, zh: '选手二', refPath: 'player_type' }, //
+  player_two_score: { type: String, required: false, zh: '选手二比分' }, //
+  is_change: { type: String, required: false, default: '0', zh: '是否交换' }, // 0:未交换,1:已交换
+  status: { type: String, required: false, default: '0', zh: '赛程状态' }, // 0:待开始,1:已开始,2:已结束
+  winner: { type: String, required: false, zh: '胜者' }, //
+};
+const schema = new Schema(match_small_group_schedule, { 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({ team_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('Msgs', schema, 'msgs');
+  } else {
+    const { mongoose } = app;
+    model = mongoose.model('Msgs', schema, 'msgs');
+  }
+  return model;
+};

+ 2 - 0
app/router.js

@@ -32,4 +32,6 @@ module.exports = app => {
   require('./z_router/bill')(app); // 账单
   require('./z_router/payOrder')(app); // 支付订单
   require('./z_router/matchTeamGroup')(app); // 小组赛设置
+  require('./z_router/matchAddress')(app); // 场地设置
+  require('./z_router/matchSmallGroupSchedule')(app); // 小组赛赛程
 };

+ 15 - 0
app/service/matchAddress.js

@@ -0,0 +1,15 @@
+'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 MatchAddressService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'matchaddress');
+    this.model = this.ctx.model.Race.MatchAddress;
+  }
+}
+
+module.exports = MatchAddressService;

+ 15 - 0
app/service/matchSmallGroupSchedule.js

@@ -0,0 +1,15 @@
+'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 MatchSmallGroupScheduleService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'matchsmallgroupschedule');
+    this.model = this.ctx.model.Race.MatchSmallGroupSchedule;
+  }
+}
+
+module.exports = MatchSmallGroupScheduleService;

+ 3 - 0
app/service/matchTeamGroup.js

@@ -14,6 +14,9 @@ class MatchTeamGroupService extends CrudService {
     this.matchSignModel = this.ctx.model.Race.MatchSign;
   }
 
+  // TODO query 需要自己改,将选手的信息换出来
+
+
   async saveAll(data) {
     for (const i of data) {
       const { _id } = i;

+ 19 - 0
app/z_router/matchAddress.js

@@ -0,0 +1,19 @@
+'use strict';
+// 路由配置
+const path = require('path');
+const regPath = path.resolve('app', 'public', 'routerRegister');
+const routerRegister = require(regPath);
+const rkey = 'matchAddress';
+const ckey = 'matchAddress';
+const keyZh = '比赛场地';
+const routes = [
+  { 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`, middleware: [ 'password' ], 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);
+};

+ 19 - 0
app/z_router/matchSmallGroupSchedule.js

@@ -0,0 +1,19 @@
+'use strict';
+// 路由配置
+const path = require('path');
+const regPath = path.resolve('app', 'public', 'routerRegister');
+const routerRegister = require(regPath);
+const rkey = 'msgs';
+const ckey = 'matchSmallGroupSchedule';
+const keyZh = '小组赛赛程';
+const routes = [
+  { 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`, middleware: [ 'password' ], 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);
+};