notice.js 1.3 KB

1234567891011121314151617181920212223242526272829303132
  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. username: { type: String, required: false, maxLength: 200 }, // 通知姓名
  8. status: { type: String, required: false, maxLength: 200, default: '0' }, // 状态,0-未读,1-已读
  9. readtime: { type: String, required: false, maxLength: 200 }, // 读取时间
  10. });
  11. // 通知表
  12. const NoticeSchema = {
  13. planyearid: { type: String, required: true, maxLength: 200 }, // 年度计划id
  14. planid: { type: String, required: true, maxLength: 200 }, // 计划id
  15. termid: { type: String, required: false, maxLength: 200 }, // 期id
  16. classid: { type: String, required: false, maxLength: 200 }, // 班级id
  17. noticeid: { type: String, required: true, maxLength: 200 }, // 通知人id
  18. content: { type: String, required: true }, // 通知内容
  19. notified: { type: [ notifiedInfo ], select: true }, // 被通知信息
  20. };
  21. const schema = new Schema(NoticeSchema, { toJSON: { virtuals: true } });
  22. schema.index({ id: 1 });
  23. schema.plugin(metaPlugin);
  24. module.exports = app => {
  25. const { mongoose } = app;
  26. return mongoose.model('Notice', schema, 'notice');
  27. };