banner.js 1.1 KB

123456789101112131415161718192021222324252627282930
  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. shop: { type: String, required: false, zh: '店铺id' }, //
  7. name: { type: String, required: false, zh: '名称' }, //
  8. url: { type: Array, required: false, zh: '路径' }, //
  9. type: { type: String, required: false, zh: '类型' }, // 字典表:banner_type
  10. to: { type: String, required: false, zh: '跳转至' }, // 填写路径
  11. status: { type: String, required: false, default: '0', zh: '是否正在使用' }, // 字典status
  12. content: { type: String, required: false, zh: '自定义内容' }, //
  13. sort: { type: Number, required: false, zh: '排序' }, //
  14. };
  15. const schema = new Schema(banner, { toJSON: { getters: true, virtuals: true } });
  16. schema.index({ id: 1 });
  17. schema.index({ 'meta.createdAt': 1 });
  18. schema.index({ name: 1 });
  19. schema.index({ shop: 1 });
  20. schema.index({ type: 1 });
  21. schema.index({ status: 1 });
  22. schema.index({ sort: 1 });
  23. schema.plugin(metaPlugin);
  24. module.exports = app => {
  25. const { mongoose } = app;
  26. return mongoose.model('Banner', schema, 'banner');
  27. };