/** * 栏目信息 */ 'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); // 附件信息 // const Attachment = new Schema({ // name: { type: String, maxLength: 128 }, // uri: { type: String, maxLength: 128 }, // }, { _id: false }); // 栏目信息 const SchemaDefine = { // site: { type: String, required: true, maxLength: 64 }, // 归属站点 // moudle: { type: String, required: true, maxLength: 20 }, // 栏目模块 // columnname: { type: String, required: false, maxLength: 100 }, // 栏目名称 // picurl: { type: String, required: false, maxLength: 256 }, // 栏目图片URL // description: { type: String, required: false, maxLength: 256 }, // 栏目描述 // inMenu: { type: String, required: false, maxLength: 5 }, // 是否在菜单中显示 // showModes: { type: String, required: false, maxLength: 5 }, // 展现方式 // isAudit: { type: String, required: false, maxLength: 5 }, // 是否需要审核 // attachment: [ Attachment ], // 附件 // issuer: String, // 栏目单位 site: { type: String, required: true, maxLength: 64 }, // 归属站点 title: { type: String, required: false, maxLength: 100 }, // 栏目名称 type: { type: String, required: false, maxLength: 5 }, // 所属类型 parent_id: { type: String, required: false, maxLength: 64 }, // 所属id parent: { type: String, required: false, maxLength: 100 }, // 所属名称 is_use: { type: String, required: false, maxLength: 5 }, // 是否使用,0=>使用中;1=>已禁止 news_type: { type: String, default: 1, maxLength: 5 }, // 0抓取,1正常输入 url: String, // 外部链接 content_id: { type: String, required: false, maxLength: 64 }, // 信息Id parent_type: { type: String, required: false, maxLength: 5 }, // 父亲类型 meta: { createdBy: String, // 创建用户 updatedBy: String, // 修改用户 }, // remark: { type: String, maxLength: 500 }, // 备注 }; const schema = new Schema(SchemaDefine, { 'multi-tenancy': true, toJSON: { virtuals: true } }); schema.plugin(metaPlugin); schema.index({ site: 1 }); schema.index({ 'meta.state': 1 }); schema.index({ 'meta.createdAt': -1 }); schema.index({ 'meta.createdAt': -1, top: -1, 'meta.state': 1 }); module.exports = app => { const { mongoose } = app; return mongoose.model('ColumnInfo', schema, 'cms_column'); };