/** * 栏目信息 */ 'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); // 栏目信息 const SchemaDefine = { site: { type: String, required: true, maxLength: 64 }, // 归属站点 parentId: { type: String, required: true, maxLength: 64 }, // 父级ID name: { type: String, required: true, maxLength: 100 }, // 菜单名称 picurl: { type: String, required: false, maxLength: 256 }, // 栏目图片URL sort: [{ type: Number, maxLength: 5 }], // 排序 description: { type: String, required: false, maxLength: 256 }, // 栏目描述 isShow: { type: String, required: false, maxLength: 5 }, // 是否需要审核 issuer: String, // 栏目单位 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({ column: 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('MenuInfo', schema, 'cms_menu'); };