lrf 2 rokov pred
rodič
commit
601ae840b8

+ 7 - 5
app/controller/user/config/.notice.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ['!customer', 'time', 'content', 'status'],
+    requestBody: ['!customer', 'source', 'source_id', 'time', 'content', 'status'],
   },
   destroy: {
     params: ['!id'],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ['!id'],
-    requestBody: ['customer', 'time', 'content', 'status'],
+    requestBody: ['customer', 'source', 'source_id', 'time', 'content', 'status'],
   },
   show: {
     parameters: {
@@ -19,9 +19,11 @@ module.exports = {
   index: {
     parameters: {
       query: {
-        'meta.createdAt@start': 'meta.createdAt@start',
-        'meta.createdAt@end': 'meta.createdAt@end',
+        'time@start': 'time@start',
+        'time@end': 'timet@end',
         customer: 'customer',
+        source: 'source',
+        source_id: 'source_id',
         status: 'status',
       },
       // options: {
@@ -31,7 +33,7 @@ module.exports = {
     service: 'query',
     options: {
       query: ['skip', 'limit'],
-      sort: ['meta.createdAt'],
+      sort: ['time'],
       desc: true,
       count: true,
     },

+ 6 - 1
app/model/user/notice.js

@@ -5,6 +5,8 @@ const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
 // 系统通知表
 const notice = {
   customer: { type: String, required: true, zh: '用户', ref: 'User.User' }, //
+  source: { type: String, required: false, zh: '消息来源' }, // 字典:notice_source
+  source_id: { type: String, required: false, zh: '来源id' }, //
   time: { type: String, required: false, zh: '发送时间' }, //
   content: { type: String, required: false, zh: '内容' }, //
   status: { type: String, required: false, default: '0', zh: '状态' }, // 字典:notice_status
@@ -13,11 +15,14 @@ const schema = new Schema(notice, { toJSON: { getters: true, virtuals: true } })
 schema.index({ id: 1 });
 schema.index({ 'meta.createdAt': 1 });
 schema.index({ customer: 1 });
+schema.index({ source: 1 });
+schema.index({ source_id: 1 });
+schema.index({ time: 1 });
 schema.index({ status: 1 });
 
 schema.plugin(metaPlugin);
 
-module.exports = (app) => {
+module.exports = app => {
   const { mongoose } = app;
   return mongoose.model('Notice', schema, 'notice');
 };