|
|
|
@ -20,9 +20,10 @@ package com.elink.esua.epdc.service.impl; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
|
import com.elink.esua.epdc.dao.SmsTemplateDao; |
|
|
|
import com.elink.esua.epdc.dto.SmsTemplateDTO; |
|
|
|
import com.elink.esua.epdc.entity.SmsTemplateEntity; |
|
|
|
@ -83,13 +84,39 @@ public class SmsTemplateServiceImpl extends BaseServiceImpl<SmsTemplateDao, SmsT |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(SmsTemplateDTO dto) { |
|
|
|
String templateType = dto.getTemplateType(); |
|
|
|
if (StringUtils.isNotBlank(templateType)) { |
|
|
|
if (getTemplateType(dto) > 0) { |
|
|
|
throw new RenException("您输入的模板类型已存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
SmsTemplateEntity entity = ConvertUtils.sourceToTarget(dto, SmsTemplateEntity.class); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 统计模板类型数量 |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public Integer getTemplateType(SmsTemplateDTO dto) { |
|
|
|
QueryWrapper<SmsTemplateEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq("TEMPLATE_TYPE", dto.getTemplateType()); |
|
|
|
String id = dto.getId(); |
|
|
|
wrapper.ne(id != null, "id", dto.getId()); |
|
|
|
wrapper.eq("del_flag", "0"); |
|
|
|
return baseDao.selectCount(wrapper); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(SmsTemplateDTO dto) { |
|
|
|
String templateType = dto.getTemplateType(); |
|
|
|
if (StringUtils.isNotBlank(templateType)) { |
|
|
|
if (getTemplateType(dto) > 0) { |
|
|
|
throw new RenException("您输入的模板类型已存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
SmsTemplateEntity entity = ConvertUtils.sourceToTarget(dto, SmsTemplateEntity.class); |
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|
|