From fb75521bc67aefcb295de161b39a980dd66b8ef5 Mon Sep 17 00:00:00 2001 From: cherishsince Date: Sun, 3 May 2020 20:50:02 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E5=A4=84=E7=90=86=EF=BC=9ATODO=20-=20?= =?UTF-8?q?=E5=88=A0=E9=99=A4=EF=BC=9AuserAddress=20=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E5=88=B0=20user=20=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/biz/dao/sms/SmsSignMapper.java | 24 +++++++ .../system/biz/dao/sms/SmsTemplateMapper.java | 27 +++++++ .../biz/dao/user/UserAddressMapper.java | 41 ----------- ...ientOfAliYun.java => AliYunSmsClient.java} | 6 +- .../biz/service/sms/SmsServiceImpl.java | 55 +++----------- ...ntOfYunPian.java => YunPianSmsClient.java} | 4 +- .../src/main/resources/mapper/UserAddress.xml | 72 ------------------- 7 files changed, 66 insertions(+), 163 deletions(-) delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/user/UserAddressMapper.java rename system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/{SmsClientOfAliYun.java => AliYunSmsClient.java} (97%) rename system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/{SmsClientOfYunPian.java => YunPianSmsClient.java} (99%) delete mode 100644 system/system-biz/src/main/resources/mapper/UserAddress.xml diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/sms/SmsSignMapper.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/sms/SmsSignMapper.java index e3f8ac542..6aa05f8dd 100644 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/sms/SmsSignMapper.java +++ b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/sms/SmsSignMapper.java @@ -1,8 +1,13 @@ package cn.iocoder.mall.system.biz.dao.sms; import cn.iocoder.mall.system.biz.dataobject.sms.SmsSignDO; +import cn.iocoder.mall.system.biz.dto.smsSign.ListSmsSignDTO; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.stereotype.Repository; +import org.springframework.util.StringUtils; /** * 短信 @@ -12,4 +17,23 @@ import org.springframework.stereotype.Repository; */ @Repository public interface SmsSignMapper extends BaseMapper { + + default IPage listSmsSign(ListSmsSignDTO queryDTO) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + if (queryDTO.getApplyStatus() != null) { + queryWrapper.eq(SmsSignDO::getApplyStatus, queryDTO.getApplyStatus()); + } + if (!StringUtils.isEmpty(queryDTO.getSign())) { + queryWrapper.like(SmsSignDO::getSign, queryDTO.getSign()); + } + if (!StringUtils.isEmpty(queryDTO.getId())) { + queryWrapper.eq(SmsSignDO::getId, queryDTO.getId()); + } + + Page page = new Page() + .setSize(queryDTO.getPageSize()) + .setCurrent(queryDTO.getPageNo()) + .setDesc("create_time"); + return selectPage(page, queryWrapper); + } } diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/sms/SmsTemplateMapper.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/sms/SmsTemplateMapper.java index 04770f2ff..effa88f88 100644 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/sms/SmsTemplateMapper.java +++ b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/sms/SmsTemplateMapper.java @@ -1,8 +1,13 @@ package cn.iocoder.mall.system.biz.dao.sms; import cn.iocoder.mall.system.biz.dataobject.sms.SmsTemplateDO; +import cn.iocoder.mall.system.biz.dto.smsTemplate.ListSmsTemplateDTO; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.stereotype.Repository; +import org.springframework.util.StringUtils; /** * 短信 template @@ -12,4 +17,26 @@ import org.springframework.stereotype.Repository; */ @Repository public interface SmsTemplateMapper extends BaseMapper { + + default IPage listSmsTemplate(ListSmsTemplateDTO listSmsTemplateDTO) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (listSmsTemplateDTO.getApplyStatus() != null) { + queryWrapper.eq("apply_status", listSmsTemplateDTO.getApplyStatus()); + } + if (listSmsTemplateDTO.getSmsSignId() != null) { + queryWrapper.eq("sms_sign_id", listSmsTemplateDTO.getSmsSignId()); + } + if (!StringUtils.isEmpty(listSmsTemplateDTO.getTemplate())) { + queryWrapper.like("template", listSmsTemplateDTO.getTemplate()); + } + if (!StringUtils.isEmpty(listSmsTemplateDTO.getId())) { + queryWrapper.eq("id", listSmsTemplateDTO.getId()); + } + + Page page = new Page() + .setSize(listSmsTemplateDTO.getPageSize()) + .setCurrent(listSmsTemplateDTO.getPageNo()) + .setDesc("create_time"); + return selectPage(page, queryWrapper); + } } diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/user/UserAddressMapper.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/user/UserAddressMapper.java deleted file mode 100644 index 862f5bc22..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/user/UserAddressMapper.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.mall.system.biz.dao.user; - -import cn.iocoder.mall.system.biz.dataobject.user.UserAddressDO; -import org.apache.ibatis.annotations.Param; -import org.springframework.stereotype.Repository; - -import java.util.List; - -/** - * 用户 地址 - * - * @author Sin - * @time 2019-04-06 13:29 - */ -@Repository -// TODO FROM 芋艿 to 小范:替换成 Mybatis Plus -public interface UserAddressMapper { - - int insert(UserAddressDO userAddressDO); - - int updateById( - @Param("id") Integer id, - @Param("userAddressDO") UserAddressDO userAddressDO - ); - - List selectByUserIdAndDeleted( - Integer deleted, - Integer userId - ); - - UserAddressDO selectByUserIdAndId( - Integer userId, - Integer id - ); - - UserAddressDO selectHasDefault( - Integer deleted, - Integer userId, - Integer hasDefault - ); -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/SmsClientOfAliYun.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/AliYunSmsClient.java similarity index 97% rename from system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/SmsClientOfAliYun.java rename to system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/AliYunSmsClient.java index 4215d90e4..ef121bc89 100644 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/SmsClientOfAliYun.java +++ b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/AliYunSmsClient.java @@ -26,10 +26,10 @@ import java.util.Map; * @author Sin * @time 2019/5/25 12:28 PM */ -@Component // TODO FROM 芋艿 to 小范:建议类名改成 AliYunSmsClient -public class SmsClientOfAliYun implements SmsClient { +@Component // TODO DOME FROM 芋艿 to 小范:建议类名改成 AliYunSmsClient +public class AliYunSmsClient implements SmsClient { - private static final Logger LOGGER = LoggerFactory.getLogger(SmsClientOfAliYun.class); + private static final Logger LOGGER = LoggerFactory.getLogger(AliYunSmsClient.class); private static final String DOMAIN = "dysmsapi.aliyuncs.com"; private static final String SUCCESS_CODE = "OK"; diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/SmsServiceImpl.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/SmsServiceImpl.java index f6b74a6d5..2261662c1 100644 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/SmsServiceImpl.java +++ b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/SmsServiceImpl.java @@ -1,6 +1,7 @@ package cn.iocoder.mall.system.biz.service.sms; import cn.iocoder.common.framework.exception.ServiceException; +import cn.iocoder.common.framework.util.ServiceExceptionUtil; import cn.iocoder.common.framework.vo.PageResult; import cn.iocoder.mall.mybatis.enums.DeletedStatusEnum; import cn.iocoder.mall.system.biz.bo.smsSign.ListSmsSignBO; @@ -53,65 +54,30 @@ public class SmsServiceImpl implements SmsService { private SmsSendMapper smsSendMapper; @Autowired - @Qualifier("smsClientOfYunPian") + @Qualifier("yunPianSmsClient") private SmsClient smsYunPianClient; @Autowired - @Qualifier("smsClientOfAliYun") + @Qualifier("aliYunSmsClient") private SmsClient smsAliYunClient; @Override public PageResult listSmsSign(ListSmsSignDTO queryDTO) { - // TODO FROM 芋艿 to 小范:mybatis-plus 的 QueryWrapper 不要到 Service 层,可以抽 Dao 方法里哈。其它的类似可以瞅瞅噢 - QueryWrapper queryWrapper = new QueryWrapper<>(); - if (queryDTO.getApplyStatus() != null) { - queryWrapper.eq("apply_status", queryDTO.getApplyStatus()); - } - if (!StringUtils.isEmpty(queryDTO.getSign())) { - queryWrapper.like("sign", queryDTO.getSign()); - } - if (!StringUtils.isEmpty(queryDTO.getId())) { - queryWrapper.eq("id", queryDTO.getId()); - } - - Page page = new Page() - .setSize(queryDTO.getPageSize()) - .setCurrent(queryDTO.getPageNo()) - .setDesc("create_time"); - - IPage signPage = smsSignMapper.selectPage(page, queryWrapper); + // TODO DOME FROM 芋艿 to 小范:mybatis-plus 的 QueryWrapper 不要到 Service 层,可以抽 Dao 方法里哈。其它的类似可以瞅瞅噢 + IPage signPage = smsSignMapper.listSmsSign(queryDTO); List signList = SmsSignConvert.INSTANCE.convert(signPage.getRecords()); return new PageResult().setList(signList).setTotal((int) signPage.getTotal()); } @Override public PageResult listSmsTemplate(ListSmsTemplateDTO listSmsTemplateDTO) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - if (listSmsTemplateDTO.getApplyStatus() != null) { - queryWrapper.eq("apply_status", listSmsTemplateDTO.getApplyStatus()); - } - if (listSmsTemplateDTO.getSmsSignId() != null) { - queryWrapper.eq("sms_sign_id", listSmsTemplateDTO.getSmsSignId()); - } - if (!StringUtils.isEmpty(listSmsTemplateDTO.getTemplate())) { - queryWrapper.like("template", listSmsTemplateDTO.getTemplate()); - } - if (!StringUtils.isEmpty(listSmsTemplateDTO.getId())) { - queryWrapper.eq("id", listSmsTemplateDTO.getId()); - } - - Page page = new Page() - .setSize(listSmsTemplateDTO.getPageSize()) - .setCurrent(listSmsTemplateDTO.getPageNo()) - .setDesc("create_time"); - - IPage signPage = smsTemplateMapper.selectPage(page, queryWrapper); + IPage signPage = smsTemplateMapper.listSmsTemplate(listSmsTemplateDTO); List templateList = SmsTemplateConvert.INSTANCE.convert(signPage.getRecords()); if (CollectionUtils.isEmpty(templateList)) { - // TODO FROM 芋艿 to 小范,Collections.EMPTY_LIST =》Collections.emptyList();另外,可以考虑直接 Convert 哈 - return new PageResult<>().setList(Collections.EMPTY_LIST).setTotal((int) signPage.getTotal()); + // TODO DOME FROM 芋艿 to 小范,Collections.EMPTY_LIST =》Collections.emptyList();另外,可以考虑直接 Convert 哈 + return new PageResult().setList(Collections.emptyList()).setTotal((int) signPage.getTotal()); } // 获取 sign @@ -149,9 +115,8 @@ public class SmsServiceImpl implements SmsService { ); if (smsSignDO != null) { - // TODO FROM 芋艿 to 小范:可以使用 ServiceExceptionUtil.exception(SystemErrorCodeEnum.SMS_SIGN_IS_EXISTENT); - throw new ServiceException(SystemErrorCodeEnum.SMS_SIGN_IS_EXISTENT.getCode(), - SystemErrorCodeEnum.SMS_SIGN_IS_EXISTENT.getMessage()); + // TODO DOME FROM 芋艿 to 小范:可以使用 ServiceExceptionUtil.exception(SystemErrorCodeEnum.SMS_SIGN_IS_EXISTENT); + throw ServiceExceptionUtil.exception(SystemErrorCodeEnum.SMS_SIGN_IS_EXISTENT); } // 保存数据库 diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/SmsClientOfYunPian.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/YunPianSmsClient.java similarity index 99% rename from system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/SmsClientOfYunPian.java rename to system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/YunPianSmsClient.java index 664cb6772..b1778ff16 100644 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/SmsClientOfYunPian.java +++ b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/sms/YunPianSmsClient.java @@ -31,9 +31,9 @@ import java.util.Map; * @time 2019/5/16 6:34 PM */ @Component -public class SmsClientOfYunPian implements SmsClient { +public class YunPianSmsClient implements SmsClient { - protected static final Logger LOGGER = LoggerFactory.getLogger(SmsClientOfYunPian.class); + protected static final Logger LOGGER = LoggerFactory.getLogger(YunPianSmsClient.class); private static final int SUCCESS_CODE = 0; private static final String SUCCESS_MESSAGE = "SUCCESS"; diff --git a/system/system-biz/src/main/resources/mapper/UserAddress.xml b/system/system-biz/src/main/resources/mapper/UserAddress.xml deleted file mode 100644 index 2e7af6d27..000000000 --- a/system/system-biz/src/main/resources/mapper/UserAddress.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - id, user_id, area_no, `name`, mobile, address, - create_time, update_time, has_default, deleted - - - - INSERT INTO user_address ( - user_id, area_no, `name`, mobile, address, - create_time, update_time, has_default, deleted - ) VALUES ( - #{userId}, #{areaNo}, #{name}, #{mobile}, #{address}, - #{createTime}, #{updateTime}, #{hasDefault}, #{deleted} - ) - - - - UPDATE user_address - - - , area_no = #{userAddressDO.areaNo} - - - , `name` = #{userAddressDO.name} - - - , mobile = #{userAddressDO.mobile} - - - , address = #{userAddressDO.address} - - - , update_time = #{userAddressDO.updateTime} - - - , has_default = #{userAddressDO.hasDefault} - - - , deleted = #{userAddressDO.deleted} - - - WHERE id = #{id} - - - - - - - - \ No newline at end of file