1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 组队申请
- const team_apply = {
- 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' ] }, // 组别项目中的名称
- one_member_id: { type: String, required: true, zh: '成员一id' }, //
- one_member_name: { type: String, required: true, zh: '成员一姓名' }, //
- 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: '状态' }, // 字典表中公共审核状态-code:examine_status
- };
- const schema = new Schema(team_apply, { 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({ one_member_id: 1 });
- schema.index({ one_member_name: 1 });
- schema.index({ two_member_id: 1 });
- schema.index({ two_member_name: 1 });
- schema.index({ apply_time: 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('TeamApply', schema, 'teamApply');
- } else {
- const { mongoose } = app;
- model = mongoose.model('TeamApply', schema, 'teamApply');
- }
- return model;
- };
|