menus.js 1.1 KB

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  5. const { ObjectId } = require('mongoose').Types;
  6. // 菜单表
  7. const menus = {
  8. name: { type: String, zh: '菜单名称' },
  9. parent_id: { type: String, zh: '父级菜单' },
  10. order_num: { type: Number, zh: '显示顺序' },
  11. path: { type: String, zh: '路由地址' },
  12. component: { type: String, zh: '组件地址' },
  13. type: { type: String, zh: '菜单类型' }, // 0:目录,1:菜单,2:子页面.....
  14. status: { type: String, zh: '状态', default: '0' }, // 0:使用;1;禁用
  15. icon: { type: String, zh: '图标', default: 'icon-shouye' },
  16. config: { type: Object }, // 设置,页面的按钮,函数设置
  17. remark: { type: String },
  18. };
  19. const schema = new Schema(menus, { toJSON: { virtuals: true } });
  20. schema.index({ id: 1 });
  21. schema.index({ 'meta.createdAt': 1 });
  22. schema.plugin(metaPlugin);
  23. module.exports = app => {
  24. const { mongoose } = app;
  25. return mongoose.model('Menus', schema, 'menus');
  26. };