patentnotice.js 1.2 KB

123456789101112131415161718192021222324252627282930
  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 patentnotice = {
  8. send_id: { type: ObjectId }, // 发送人id
  9. send_name: { type: String }, // 发送人姓名
  10. to_type: { type: String }, // 0-所有人;1-机构用户;2-平台用户;3机构发给自己用户,4:科企发给个人用户
  11. to_id: { type: [ ObjectId ] }, // 接收人id
  12. to_name: { type: String }, // 接收人姓名
  13. is_read: { type: Boolean, default: false }, // 是否已读
  14. content: { type: String }, // 内容
  15. notice_file: { type: Array }, // 通知文件
  16. remark: { type: String },
  17. };
  18. const schema = new Schema(patentnotice, { toJSON: { virtuals: true } });
  19. schema.index({ id: 1 });
  20. schema.index({ send_id: 1 });
  21. schema.index({ send_name: 1 });
  22. schema.index({ to_type: 1 });
  23. schema.index({ to_id: 1 });
  24. schema.index({ is_read: 1 });
  25. schema.index({ 'meta.createdAt': 1 });
  26. schema.plugin(metaPlugin);
  27. module.exports = app => {
  28. const { mongoose } = app;
  29. return mongoose.model('Patentnotice', schema, 'patent_notice');
  30. };