|
@@ -0,0 +1,28 @@
|
|
|
+'use strict';
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
|
|
|
+
|
|
|
+// 被通知详情表
|
|
|
+const notifiedInfo = new Schema({
|
|
|
+ notifiedid: { type: String, required: false, maxLength: 200 }, // 被通知人id
|
|
|
+ status: { type: String, required: false, maxLength: 200, default: '0' }, // 状态,0-未读,1-已读
|
|
|
+ readtime: { type: String, required: false, maxLength: 200 }, // 读取时间
|
|
|
+});
|
|
|
+
|
|
|
+// 通知表
|
|
|
+const NoticeSchema = {
|
|
|
+ noticeid: { type: String, required: true, maxLength: 200 }, // 通知人id
|
|
|
+ content: { type: String, required: true }, // 通知内容
|
|
|
+ notified: { type: [ notifiedInfo ], select: true }, // 被通知信息
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+const schema = new Schema(NoticeSchema, { toJSON: { virtuals: true } });
|
|
|
+schema.index({ id: 1 });
|
|
|
+schema.plugin(metaPlugin);
|
|
|
+
|
|
|
+module.exports = app => {
|
|
|
+ const { mongoose } = app;
|
|
|
+ return mongoose.model('Notice', schema, 'notice');
|
|
|
+};
|