room.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 房间广告位
  5. const AdvertInfo = {
  6. title: { type: String, required: false }, // 广告标题
  7. imgdir: { type: String, required: false }, // 图片地址
  8. imgurl: { type: String, required: false }, // 图片链接地址
  9. };
  10. const RoomSchema = {
  11. name: { type: String, required: false, maxLength: 200 }, // 房间名称
  12. title: { type: String, required: false, maxLength: 200 }, // 标题
  13. type: { type: String, required: false, maxLength: 64 }, // 类型0、直播1、会议
  14. filedir: { type: String, required: false, maxLength: 200 }, // 封面图片
  15. url: { type: String, required: false, maxLength: 200 }, // 视频地址
  16. stream_id: { type: String, required: false }, // 视频回放文件id
  17. ishis: { type: String, required: false, maxLength: 64, default: '0' }, // 状态0、正常1、历史
  18. requestId: { type: String, required: false }, // 请求id
  19. file_id: { type: String, required: false }, // 文件id
  20. content: { type: String, required: false }, // 直播简介
  21. anchorid: { type: String, required: false, maxLength: 200 }, // 主播id
  22. username: { type: String, required: false, maxLength: 200 }, // 主播名称
  23. starttime: { type: String, required: false }, // 开始时间
  24. endtime: { type: String, required: false }, // 结束时间
  25. status: { type: String, required: false, maxLength: 64, default: '0' }, // 状态0、开启1、关闭
  26. isadvert: { type: Boolean, required: false, default: false }, // 是否有广告位0、开启1、关闭
  27. adverts: { type: [ AdvertInfo ], required: false, select: true }, // 广告位
  28. };
  29. const schema = new Schema(RoomSchema, { toJSON: { virtuals: true } });
  30. schema.index({ id: 1 });
  31. schema.plugin(metaPlugin);
  32. module.exports = app => {
  33. const { mongoose } = app;
  34. return mongoose.model('Room', schema, 'room');
  35. };