lrf před 2 roky
rodič
revize
ac5e0ee11b
1 změnil soubory, kde provedl 9 přidání a 1 odebrání
  1. 9 1
      app/service/user/notice.js

+ 9 - 1
app/service/user/notice.js

@@ -4,12 +4,20 @@ const { BusinessError, ErrorCode } = require('naf-core').Error;
 const _ = require('lodash');
 const assert = require('assert');
 
-// 
+//
 class NoticeService extends CrudService {
   constructor(ctx) {
     super(ctx, 'notice');
     this.model = this.ctx.model.User.Notice;
   }
+
+  async create(body) {
+    const { customer = [], ...others } = body;
+    if (!_.isArray(customer)) throw new BusinessError(ErrorCode.DATA_INVALID, '数据格式错误');
+    if (customer.length <= 0) throw new BusinessError(ErrorCode.BADPARAM, '缺少发送对象');
+    const arr = customer.map(i => ({ customer: i, ...others }));
+    await this.model.insertMany(arr);
+  }
 }
 
 module.exports = NoticeService;