notice.js 951 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 被通知详情表
  5. const notifiedInfo = new Schema({
  6. notifiedid: { type: String, required: false, maxLength: 200 }, // 被通知人id
  7. status: { type: String, required: false, maxLength: 200, default: '0' }, // 状态,0-未读,1-已读
  8. readtime: { type: String, required: false, maxLength: 200 }, // 读取时间
  9. });
  10. // 通知表
  11. const NoticeSchema = {
  12. noticeid: { type: String, required: true, maxLength: 200 }, // 通知人id
  13. content: { type: String, required: true }, // 通知内容
  14. notified: { type: [ notifiedInfo ], select: true }, // 被通知信息
  15. };
  16. const schema = new Schema(NoticeSchema, { toJSON: { virtuals: true } });
  17. schema.index({ id: 1 });
  18. schema.plugin(metaPlugin);
  19. module.exports = app => {
  20. const { mongoose } = app;
  21. return mongoose.model('Notice', schema, 'notice');
  22. };