column.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * 栏目信息
  3. */
  4. 'use strict';
  5. const Schema = require('mongoose').Schema;
  6. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  7. // 附件信息
  8. // const Attachment = new Schema({
  9. // name: { type: String, maxLength: 128 },
  10. // uri: { type: String, maxLength: 128 },
  11. // }, { _id: false });
  12. // 栏目信息
  13. const SchemaDefine = {
  14. // site: { type: String, required: true, maxLength: 64 }, // 归属站点
  15. // moudle: { type: String, required: true, maxLength: 20 }, // 栏目模块
  16. // columnname: { type: String, required: false, maxLength: 100 }, // 栏目名称
  17. // picurl: { type: String, required: false, maxLength: 256 }, // 栏目图片URL
  18. // description: { type: String, required: false, maxLength: 256 }, // 栏目描述
  19. // inMenu: { type: String, required: false, maxLength: 5 }, // 是否在菜单中显示
  20. // showModes: { type: String, required: false, maxLength: 5 }, // 展现方式
  21. // isAudit: { type: String, required: false, maxLength: 5 }, // 是否需要审核
  22. // attachment: [ Attachment ], // 附件
  23. // issuer: String, // 栏目单位
  24. site: { type: String, required: true, maxLength: 64 }, // 归属站点
  25. title: { type: String, required: false, maxLength: 100 }, // 栏目名称
  26. type: { type: String, required: false, maxLength: 5 }, // 所属类型
  27. parent_id: { type: String, required: false, maxLength: 64 }, // 所属id
  28. parent: { type: String, required: false, maxLength: 100 }, // 所属名称
  29. is_use: { type: String, required: false, maxLength: 5 }, // 是否使用,0=>使用中;1=>已禁止
  30. news_type: { type: String, default: 1, maxLength: 5 }, // 0抓取,1正常输入
  31. url: String, // 外部链接
  32. content_id: { type: String, required: false, maxLength: 64 }, // 信息Id
  33. parent_type: { type: String, required: false, maxLength: 5 }, // 父亲类型
  34. meta: {
  35. createdBy: String, // 创建用户
  36. updatedBy: String, // 修改用户
  37. },
  38. // remark: { type: String, maxLength: 500 }, // 备注
  39. };
  40. const schema = new Schema(SchemaDefine, { 'multi-tenancy': true, toJSON: { virtuals: true } });
  41. schema.plugin(metaPlugin);
  42. schema.index({ site: 1 });
  43. schema.index({ 'meta.state': 1 });
  44. schema.index({ 'meta.createdAt': -1 });
  45. schema.index({ 'meta.createdAt': -1, top: -1, 'meta.state': 1 });
  46. module.exports = app => {
  47. const { mongoose } = app;
  48. return mongoose.model('ColumnInfo', schema, 'cms_column');
  49. };