teamApply.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 组队申请
  5. const team_apply = {
  6. match_id: { type: String, required: true, zh: '赛事id', ref: 'Race.Match', getProp: [ 'name' ] }, // 比赛信息表中的名称
  7. group_id: { type: String, required: true, zh: '组别id', ref: 'Race.MatchGroup', getProp: [ 'name' ] }, // 赛事组别中的名称
  8. project_id: { type: String, required: true, zh: '项目id', ref: 'Race.MatchProject', getProp: [ 'name' ] }, // 组别项目中的名称
  9. one_member_id: { type: String, required: true, zh: '成员一id' }, //
  10. one_member_name: { type: String, required: true, zh: '成员一姓名' }, //
  11. two_member_id: { type: String, required: true, zh: '成员二id' }, //
  12. two_member_name: { type: String, required: true, zh: '成员二姓名' }, //
  13. apply_time: { type: String, required: true, zh: '申请时间' }, //
  14. status: { type: String, required: false, default: '0', zh: '状态' }, // 字典表中公共审核状态-code:examine_status
  15. };
  16. const schema = new Schema(team_apply, { toJSON: { getters: true, virtuals: true } });
  17. schema.index({ id: 1 });
  18. schema.index({ 'meta.createdAt': 1 });
  19. schema.index({ match_id: 1 });
  20. schema.index({ group_id: 1 });
  21. schema.index({ project_id: 1 });
  22. schema.index({ one_member_id: 1 });
  23. schema.index({ one_member_name: 1 });
  24. schema.index({ two_member_id: 1 });
  25. schema.index({ two_member_name: 1 });
  26. schema.index({ apply_time: 1 });
  27. schema.index({ status: 1 });
  28. schema.plugin(metaPlugin);
  29. const source = 'race';
  30. module.exports = app => {
  31. const is_multiple = app.mongooseDB.clients;
  32. let model;
  33. if (is_multiple) {
  34. const conn = app.mongooseDB.get(source);
  35. model = conn.model('TeamApply', schema, 'teamApply');
  36. } else {
  37. const { mongoose } = app;
  38. model = mongoose.model('TeamApply', schema, 'teamApply');
  39. }
  40. return model;
  41. };