'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: 'Race.Match', getProp: [ 'name' ] }, // 赛事信息中的名称 group_id: { type: String, required: true, zh: '组别id', ref: 'Race.MatchGroup', getProp: [ 'name' ] }, // 赛事组别中的名称 project_id: { type: String, required: true, zh: '项目id', ref: 'Race.MatchProject', getProp: [ 'name' ] }, // 组内项目中的名称 team_id: { type: String, required: true, zh: '小组id', ref: 'Race.MatchTeamGroup', getProp: [ 'name' ] }, // 小组赛组设置中的name address_id: { type: String, required: true, zh: '场地id', ref: 'Race.MatchAddress', getProp: [ 'name' ] }, // 赛事场地中name referee_id: { type: String, required: true, zh: '裁判id', ref: 'Race.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; };