banner.js 924 B

12345678910111213141516171819202122232425
  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. };
  12. const schema = new Schema(banner, { toJSON: { getters: true, virtuals: true } });
  13. schema.index({ id: 1 });
  14. schema.index({ 'meta.createdAt': 1 });
  15. schema.index({ name: 1 });
  16. schema.index({ type: 1 });
  17. schema.index({ status: 1 });
  18. schema.plugin(metaPlugin);
  19. module.exports = app => {
  20. const { mongoose } = app;
  21. return mongoose.model('Banner', schema, 'banner');
  22. };