notice.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  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,user表uid
  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. content: { type: String, required: false }, // 如果属于自己的信息,就放这里,上面放信息标题
  11. });
  12. // 通知表
  13. const NoticeSchema = {
  14. planyearid: { type: String, required: true, maxLength: 200 }, // 年度计划id
  15. planid: { type: String, required: true, maxLength: 200 }, // 计划id
  16. termid: { type: String, required: false, maxLength: 200 }, // 期id
  17. classid: { type: String, required: false, maxLength: 200 }, // 班级id
  18. noticeid: { type: String, required: true, maxLength: 200 }, // 通知人id
  19. content: { type: String, required: true }, // 通知内容
  20. type: { type: String, required: false, maxLength: 200, default: '0' }, // 状态,0-培训自定义通知;1-日历通知;2-班主任计划通知;3-学校计划通知;4-课表通知;5-分寝通知;6-预安排课表通知
  21. notified: { type: [ notifiedInfo ], select: true }, // 被通知信息
  22. };
  23. const schema = new Schema(NoticeSchema, { toJSON: { virtuals: true } });
  24. schema.index({ id: 1 });
  25. schema.plugin(metaPlugin);
  26. module.exports = app => {
  27. const { mongoose } = app;
  28. return mongoose.model('Notice', schema, 'notice');
  29. };