dock.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. const { Secret } = require('naf-framework-mongoose/lib/model/schema');
  6. // 展会视频表
  7. const videos = new Schema({
  8. file_path: { type: String, required: true }, // 视频路径
  9. videointro: { type: String, required: false, maxLength: 200 }, // 视频文件标题
  10. videointroinfo: { type: String, required: false, maxLength: 200 }, // 视频文件简介
  11. });
  12. // vip用户
  13. const vipuser = new Schema({
  14. vipname: { type: String, required: false, maxLength: 200 }, // 用户名称
  15. vipphone: { type: String, required: false, maxLength: 200 }, // 联系人手机
  16. email: { type: String, required: false, maxLength: 20 }, // 郵箱
  17. content: { type: String, required: false }, // 内容
  18. password: { type: String, select: false }, // 密码
  19. });
  20. vipuser.index({ id: 1 });
  21. // 展会表
  22. const dock = {
  23. room_id: { type: Number, required: true, maxLength: 10 }, // 房间号
  24. password: { type: Secret, select: false }, // 密码
  25. title: { type: String, required: false, maxLength: 200 }, // 对接会标题
  26. start_time: { type: String, required: true, maxLength: 200 }, // 开始时间
  27. end_time: { type: String, required: true, maxLength: 200 }, // 结束时间
  28. province: { type: String, required: false }, // 省
  29. place: { type: String, required: false }, // 市
  30. adminuser: { type: String, required: false, maxLength: 200 }, // 负责人
  31. phone: { type: String, required: false, maxLength: 200 }, // 负责人电话
  32. sponsor: { type: String, required: false, maxLength: 200 }, // 主办方
  33. organizer: { type: String, required: false, maxLength: 200 }, // 承办方
  34. videodata: { type: [ videos ], select: true }, // 视频路径
  35. vipuser: { type: [ vipuser ], default: [] }, // vip用户
  36. desc: { type: String, maxLength: 1000 }, // 简介
  37. status: { type: String, default: '0' }, // 状态:0准备中;1已开始;2已结束
  38. remark: { type: String, maxLength: 200 },
  39. create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
  40. };
  41. const schema = new Schema(dock, { toJSON: { virtuals: true } });
  42. schema.index({ id: 1 });
  43. schema.plugin(metaPlugin);
  44. module.exports = app => {
  45. const { mongoose } = app;
  46. return mongoose.model('Dock', schema, 'dock');
  47. };