|
|
@@ -1,5 +1,6 @@
|
|
|
package cn.iocoder.yudao.module.system.service.sms;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO;
|
|
|
@@ -65,6 +66,23 @@ public class SmsChannelServiceImpl implements SmsChannelService {
|
|
|
smsChannelMapper.deleteById(id);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void deleteSmsChannelList(List<Long> ids) {
|
|
|
+ if (CollUtil.isEmpty(ids)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 校验存在
|
|
|
+ validateSmsChannelBatchExists(ids);
|
|
|
+ // 校验是否有在使用该账号的模版
|
|
|
+ for (Long id : ids) {
|
|
|
+ if (smsTemplateService.getSmsTemplateCountByChannelId(id) > 0) {
|
|
|
+ throw exception(SMS_CHANNEL_HAS_CHILDREN);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 批量删除
|
|
|
+ smsChannelMapper.deleteByIds(ids);
|
|
|
+ }
|
|
|
+
|
|
|
private SmsChannelDO validateSmsChannelExists(Long id) {
|
|
|
SmsChannelDO channel = smsChannelMapper.selectById(id);
|
|
|
if (channel == null) {
|
|
|
@@ -73,6 +91,13 @@ public class SmsChannelServiceImpl implements SmsChannelService {
|
|
|
return channel;
|
|
|
}
|
|
|
|
|
|
+ private void validateSmsChannelBatchExists(List<Long> ids) {
|
|
|
+ List<SmsChannelDO> channels = smsChannelMapper.selectByIds(ids);
|
|
|
+ if (channels.size() != ids.size()) {
|
|
|
+ throw exception(SMS_CHANNEL_NOT_EXISTS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public SmsChannelDO getSmsChannel(Long id) {
|
|
|
return smsChannelMapper.selectById(id);
|