column.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. name: { type: String, required: true, 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. sort: [{ type: Number, maxLength: 5 }], // 排序
  23. issuer: String, // 栏目单位
  24. meta: {
  25. createdBy: String, // 创建用户
  26. updatedBy: String, // 修改用户
  27. },
  28. remark: { type: String, maxLength: 500 }, // 备注
  29. };
  30. const schema = new Schema(SchemaDefine, { 'multi-tenancy': true, toJSON: { virtuals: true } });
  31. schema.plugin(metaPlugin);
  32. schema.index({ column: 1 });
  33. schema.index({ 'meta.state': 1 });
  34. schema.index({ 'meta.createdAt': -1 });
  35. schema.index({ 'meta.createdAt': -1, top: -1, 'meta.state': 1 });
  36. module.exports = app => {
  37. const { mongoose } = app;
  38. return mongoose.model('ColumnInfo', schema, 'cms_column');
  39. };