shopNotice.js 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 店铺系统消息
  5. const shopNotice = {
  6. shop: { type: String, required: false, zh: '店铺' }, //
  7. source: { type: String, required: false, zh: '消息来源' }, // 字典:notice_source
  8. source_type: { type: String, required: false, zh: '消息类型' }, // 字典:notice_source_type
  9. source_id: { type: String, required: false, zh: '来源id' }, //
  10. time: { type: String, required: false, zh: '发送时间' }, //
  11. content: { type: String, required: false, zh: '内容' }, //
  12. type: { type: String, required: false, default: '1', zh: '发送类型' }, // 字典:notice_type;只是显示;默认:人为发送
  13. status: { type: String, required: false, default: '0', zh: '状态' }, // 字典:notice_status
  14. };
  15. const schema = new Schema(shopNotice, { toJSON: { getters: true, virtuals: true } });
  16. schema.index({ id: 1 });
  17. schema.index({ 'meta.createdAt': 1 });
  18. schema.index({ shop: 1 });
  19. schema.index({ source: 1 });
  20. schema.index({ source_id: 1 });
  21. schema.index({ time: 1 });
  22. schema.index({ type: 1 });
  23. schema.index({ status: 1 });
  24. schema.plugin(metaPlugin);
  25. module.exports = app => {
  26. const { mongoose } = app;
  27. return mongoose.model('ShopNotice', schema, 'shopNotice');
  28. };