|
@@ -4,12 +4,20 @@ const { BusinessError, ErrorCode } = require('naf-core').Error;
|
|
const _ = require('lodash');
|
|
const _ = require('lodash');
|
|
const assert = require('assert');
|
|
const assert = require('assert');
|
|
|
|
|
|
-//
|
|
|
|
|
|
+//
|
|
class NoticeService extends CrudService {
|
|
class NoticeService extends CrudService {
|
|
constructor(ctx) {
|
|
constructor(ctx) {
|
|
super(ctx, 'notice');
|
|
super(ctx, 'notice');
|
|
this.model = this.ctx.model.User.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;
|
|
module.exports = NoticeService;
|