dock.js 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. const apply = new Schema({
  5. user_id: { type: String, required: true, maxLength: 200 }, // 用户id
  6. user_name: { type: String, required: true, maxLength: 200 }, // 用户名称
  7. buyer: { type: String, required: true, maxLength: 1 }, // 买家/卖家 0/1
  8. goodsList: [ Object ],
  9. contact: { type: String, required: true, maxLength: 200 }, // 联系人
  10. contact_tel: { type: String, required: true, maxLength: 200 }, // 联系人电话
  11. email: { type: String, maxLength: 200 }, // 邮箱
  12. company: { type: String, maxLength: 200 }, // 单位名称
  13. apply_time: { type: String, maxLength: 200 }, // 申请时间
  14. status: { type: String, default: 0, maxLength: 1 }, // 申请状态 (0未审核;1已通过;2已拒绝)
  15. });
  16. apply.index({ id: 1 });
  17. apply.index({ userid: 1 });
  18. const Dock = {
  19. title: { type: String, required: true, maxLength: 200 }, // 对接会标题
  20. desc: { type: String, maxLength: 1000 }, // 简介
  21. status: { type: String, default: '0', maxLength: 1 }, // 状态:0准备中;1已开始;2已结束
  22. apply: { type: [ apply ], default: [] },
  23. };
  24. const schema = new Schema(Dock, { toJSON: { virtuals: true } });
  25. schema.index({ id: 1 });
  26. schema.plugin(metaPlugin);
  27. module.exports = app => {
  28. const { mongoose } = app;
  29. return mongoose.model('dock', schema, 'dock');
  30. };