lrf 2 vuotta sitten
vanhempi
commit
8f87d4efd5

+ 20 - 0
app/model/base/dict.js

@@ -0,0 +1,20 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+
+// 字典表
+const dict = {
+  label: { type: String, required: false, zh: '字典名称' }, //
+  code: { type: String, required: false, zh: '字典编码' }, //
+  list: { type: Array, required: false, zh: '字典选项' }, //
+};
+const schema = new Schema(dict, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.index({ code: 1 });
+
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const conn = app.mongooseDB.get('base');
+  return conn.model('Dict', schema, 'dict');
+};

+ 1 - 1
app/model/race/match.js

@@ -14,7 +14,7 @@ const match = {
   contact: { type: String, required: true, zh: '联系方式' }, // 联系方式
   explain: { type: String, required: false, zh: '报名说明' }, // 报名说明
   regular: { type: String, required: false, zh: '赛事规程' }, // 赛事规程
-  status: { type: String, required: true, default: '0', zh: '比赛状态', ref: 'dict', getProp: [ 'label' ] }, // 字典表中的标签
+  status: { type: String, required: true, default: '0', zh: '比赛状态' }, // 字典表中的标签
 };
 const schema = new Schema(match, { toJSON: { getters: true, virtuals: true } });
 schema.index({ id: 1 });

+ 2 - 2
app/model/race/matchProject.js

@@ -6,10 +6,10 @@ const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
 const match_project = {
   match_id: { type: String, required: true, zh: '赛事id', ref: 'match', getProp: [ 'name' ] }, // 比赛信息中的比赛名称
   group_id: { type: String, required: true, zh: '赛事分组id', ref: 'match_group', getProp: [ 'name' ] }, // 赛事分组中的组名称
-  type: { type: String, required: true, zh: '项目类别', ref: 'dict', getProp: [ 'label' ] }, // 字典表中的标签
+  type: { type: String, required: true, zh: '项目类别' }, // 字典表中的标签
   name: { type: String, required: true, zh: '名称' }, //
   age: { type: String, required: false, zh: '年龄限制' }, //
-  gender: { type: String, required: false, zh: '性别限制', ref: 'dict', getProp: [ 'label' ] }, // 字典表中的标签
+  gender: { type: String, required: false, zh: '性别限制' }, // 字典表中的标签
   num: { type: Number, required: false, zh: '人数限制' }, //
   explain: { type: String, required: false, zh: '说明' }, //
 };

+ 1 - 1
app/model/race/teamApply.js

@@ -12,7 +12,7 @@ const team_apply = {
   two_member_id: { type: String, required: true, zh: '成员二id' }, //
   two_member_name: { type: String, required: true, zh: '成员二姓名' }, //
   apply_time: { type: String, required: true, zh: '申请时间' }, //
-  status: { type: String, required: false, default: '0', zh: '状态', ref: 'dict', getProp: [ 'label' ] }, // 字典表中公共审核状态-code:examine_status
+  status: { type: String, required: false, default: '0', zh: '状态' }, // 字典表中公共审核状态-code:examine_status
 };
 const schema = new Schema(team_apply, { toJSON: { getters: true, virtuals: true } });
 schema.index({ id: 1 });

+ 8 - 1
app/service/matchSign.js

@@ -4,12 +4,19 @@ const { BusinessError, ErrorCode } = require('naf-core').Error;
 const _ = require('lodash');
 const assert = require('assert');
 
-// 
+//
 class MatchSignService extends CrudService {
   constructor(ctx) {
     super(ctx, 'matchsign');
     this.model = this.ctx.model.Race.MatchSign;
   }
+  /**
+   * 检查是否已经有该赛事,该组别,该项目的报名
+   * @param {Object} body 参数体
+   */
+  async beforeCreate(body) {
+    return body;
+  }
 }
 
 module.exports = MatchSignService;

+ 2 - 2
config/config.default.js

@@ -112,7 +112,7 @@ module.exports = appInfo => {
   config.mongoose = {
     clients: {
       base: {
-        url: `mongodb://127.0.0.1:27017/${config.baseDbName}`, // 120.48.146.1 127.0.0.1
+        url: `mongodb://120.48.146.1:27017/${config.baseDbName}`, // 120.48.146.1 127.0.0.1
         options: {
           user: 'admin',
           pass: 'admin',
@@ -122,7 +122,7 @@ module.exports = appInfo => {
         },
       },
       race: {
-        url: `mongodb://127.0.0.1:27017/${config.dbName}`, // 120.48.146.1 127.0.0.1
+        url: `mongodb://120.48.146.1:27017/${config.dbName}`, // 120.48.146.1 127.0.0.1
         options: {
           user: 'admin',
           pass: 'admin',