lrf 2 năm trước cách đây
mục cha
commit
ac5e0ee11b
1 tập tin đã thay đổi với 9 bổ sung1 xóa
  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;