banner.js 1.1 KB

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 首屏滚动广告
  5. const banner = {
  6. name: { type: String, required: false, zh: '名称' }, //
  7. url: { type: Array, required: false, zh: '路径' }, //
  8. type: { type: String, required: false, zh: '类型' }, // 字典表:banner_type
  9. to: { type: String, required: false, zh: '跳转至' }, // 填写路径
  10. status: { type: String, required: false, default: '0', zh: '是否正在使用' }, // 字典status
  11. content: { type: String, required: false, zh: '自定义内容' }, //
  12. sort: { type: Number, required: false, zh: '排序' }, //
  13. };
  14. const schema = new Schema(banner, { toJSON: { getters: true, virtuals: true } });
  15. schema.index({ id: 1 });
  16. schema.index({ 'meta.createdAt': 1 });
  17. schema.index({ name: 1 });
  18. schema.index({ type: 1 });
  19. schema.index({ status: 1 });
  20. schema.index({ sort: 1 });
  21. schema.plugin(metaPlugin);
  22. module.exports = app => {
  23. const { mongoose } = app;
  24. return mongoose.model('Banner', schema, 'banner');
  25. };