- 处理:TODO

- 删除:userAddress 移动到 user 模块
This commit is contained in:
cherishsince 2020-05-03 20:50:02 +08:00
parent 174b19723a
commit fb75521bc6
7 changed files with 66 additions and 163 deletions

View File

@ -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<SmsSignDO> {
default IPage<SmsSignDO> listSmsSign(ListSmsSignDTO queryDTO) {
LambdaQueryWrapper<SmsSignDO> 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<SmsSignDO> page = new Page<SmsSignDO>()
.setSize(queryDTO.getPageSize())
.setCurrent(queryDTO.getPageNo())
.setDesc("create_time");
return selectPage(page, queryWrapper);
}
}

View File

@ -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<SmsTemplateDO> {
default IPage<SmsTemplateDO> listSmsTemplate(ListSmsTemplateDTO listSmsTemplateDTO) {
QueryWrapper<SmsTemplateDO> 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<SmsTemplateDO> page = new Page<SmsTemplateDO>()
.setSize(listSmsTemplateDTO.getPageSize())
.setCurrent(listSmsTemplateDTO.getPageNo())
.setDesc("create_time");
return selectPage(page, queryWrapper);
}
}

View File

@ -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<UserAddressDO> selectByUserIdAndDeleted(
Integer deleted,
Integer userId
);
UserAddressDO selectByUserIdAndId(
Integer userId,
Integer id
);
UserAddressDO selectHasDefault(
Integer deleted,
Integer userId,
Integer hasDefault
);
}

View File

@ -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";

View File

@ -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<ListSmsSignBO> listSmsSign(ListSmsSignDTO queryDTO) {
// TODO FROM 芋艿 to 小范mybatis-plus QueryWrapper 不要到 Service 可以抽 Dao 方法里哈其它的类似可以瞅瞅噢
QueryWrapper<SmsSignDO> 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<SmsSignDO> page = new Page<SmsSignDO>()
.setSize(queryDTO.getPageSize())
.setCurrent(queryDTO.getPageNo())
.setDesc("create_time");
IPage<SmsSignDO> signPage = smsSignMapper.selectPage(page, queryWrapper);
// TODO DOME FROM 芋艿 to 小范mybatis-plus QueryWrapper 不要到 Service 可以抽 Dao 方法里哈其它的类似可以瞅瞅噢
IPage<SmsSignDO> signPage = smsSignMapper.listSmsSign(queryDTO);
List<ListSmsSignBO> signList = SmsSignConvert.INSTANCE.convert(signPage.getRecords());
return new PageResult<ListSmsSignBO>().setList(signList).setTotal((int) signPage.getTotal());
}
@Override
public PageResult<ListSmsTemplateBO> listSmsTemplate(ListSmsTemplateDTO listSmsTemplateDTO) {
QueryWrapper<SmsTemplateDO> 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<SmsTemplateDO> page = new Page<SmsTemplateDO>()
.setSize(listSmsTemplateDTO.getPageSize())
.setCurrent(listSmsTemplateDTO.getPageNo())
.setDesc("create_time");
IPage<SmsTemplateDO> signPage = smsTemplateMapper.selectPage(page, queryWrapper);
IPage<SmsTemplateDO> signPage = smsTemplateMapper.listSmsTemplate(listSmsTemplateDTO);
List<ListSmsTemplateBO> 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<ListSmsTemplateBO>().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);
}
// 保存数据库

View File

@ -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";

View File

@ -1,72 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.system.biz.dao.user.UserAddressMapper">
<sql id="FIELDS">
id, user_id, area_no, `name`, mobile, address,
create_time, update_time, has_default, deleted
</sql>
<insert id="insert" parameterType="UserAddressDO" useGeneratedKeys="true" keyProperty="id">
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}
)
</insert>
<update id="updateById">
UPDATE user_address
<set>
<if test="userAddressDO.areaNo != null">
, area_no = #{userAddressDO.areaNo}
</if>
<if test="userAddressDO.name != null">
, `name` = #{userAddressDO.name}
</if>
<if test="userAddressDO.mobile != null">
, mobile = #{userAddressDO.mobile}
</if>
<if test="userAddressDO.address != null">
, address = #{userAddressDO.address}
</if>
<if test="userAddressDO.updateTime != null">
, update_time = #{userAddressDO.updateTime}
</if>
<if test="userAddressDO.hasDefault != null">
, has_default = #{userAddressDO.hasDefault}
</if>
<if test="userAddressDO.deleted != null">
, deleted = #{userAddressDO.deleted}
</if>
</set>
WHERE id = #{id}
</update>
<select id="selectByUserIdAndId" resultType="cn.iocoder.mall.system.biz.dataobject.user.UserAddressDO">
SELECT
<include refid="FIELDS" />
FROM user_address
WHERE user_id = #{userId}
AND id = #{id}
</select>
<select id="selectByUserIdAndDeleted" resultType="cn.iocoder.mall.system.biz.dataobject.user.UserAddressDO">
SELECT
<include refid="FIELDS" />
FROM user_address
WHERE deleted = #{deleted}
AND `user_id` = #{userId}
</select>
<select id="selectHasDefault" resultType="cn.iocoder.mall.system.biz.dataobject.user.UserAddressDO">
SELECT
<include refid="FIELDS" />
FROM user_address
WHERE deleted = #{deleted}
AND `user_id` = #{userId}
AND `has_default` = #{hasDefault}
</select>
</mapper>