Commit df1a30a9 authored by zhangfeng's avatar zhangfeng

客户端地址管理

parent 0904f244
...@@ -3,8 +3,10 @@ package cn.iocoder.yudao.module.member.service.address; ...@@ -3,8 +3,10 @@ package cn.iocoder.yudao.module.member.service.address;
import java.util.*; import java.util.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService; import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.module.ecw.api.paramValid.ParamValidatorApi;
import cn.iocoder.yudao.module.member.convert.address.UserAddressConvert; import cn.iocoder.yudao.module.member.convert.address.UserAddressConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.address.UserAddressDO; import cn.iocoder.yudao.module.member.dal.dataobject.address.UserAddressDO;
import cn.iocoder.yudao.module.member.dal.mysql.address.UserAddressMapper; import cn.iocoder.yudao.module.member.dal.mysql.address.UserAddressMapper;
...@@ -35,9 +37,12 @@ public class UserAddressServiceImpl extends AbstractService<UserAddressMapper, U ...@@ -35,9 +37,12 @@ public class UserAddressServiceImpl extends AbstractService<UserAddressMapper, U
private UserAddressMapper userAddressMapper; private UserAddressMapper userAddressMapper;
@Resource @Resource
private MemberUserService userService; private MemberUserService userService;
@Resource
private ParamValidatorApi paramValidatorApi;
@Override @Override
public Long createUserAddress(UserAddressCreateReqVO createReqVO) { public Long createUserAddress(UserAddressCreateReqVO createReqVO) {
verifyUserAddress(createReqVO);
// 插入 // 插入
UserAddressDO userAddress = UserAddressConvert.INSTANCE.convert(createReqVO); UserAddressDO userAddress = UserAddressConvert.INSTANCE.convert(createReqVO);
updateIsDefault(createReqVO, 0L); updateIsDefault(createReqVO, 0L);
...@@ -48,6 +53,7 @@ public class UserAddressServiceImpl extends AbstractService<UserAddressMapper, U ...@@ -48,6 +53,7 @@ public class UserAddressServiceImpl extends AbstractService<UserAddressMapper, U
@Override @Override
public void updateUserAddress(UserAddressUpdateReqVO updateReqVO) { public void updateUserAddress(UserAddressUpdateReqVO updateReqVO) {
verifyUserAddress(updateReqVO);
// 校验存在 // 校验存在
this.validateUserAddressExists(updateReqVO.getId()); this.validateUserAddressExists(updateReqVO.getId());
updateIsDefault(updateReqVO, updateReqVO.getId()); updateIsDefault(updateReqVO, updateReqVO.getId());
...@@ -67,9 +73,8 @@ public class UserAddressServiceImpl extends AbstractService<UserAddressMapper, U ...@@ -67,9 +73,8 @@ public class UserAddressServiceImpl extends AbstractService<UserAddressMapper, U
throw exception(USER_ADDRESS_FIELD_ERROR,"Address,AreaCode,Name,Phone must not null"); throw exception(USER_ADDRESS_FIELD_ERROR,"Address,AreaCode,Name,Phone must not null");
} }
// 校验手机号格式 // 校验手机号格式
if (!reqVO.getPhone().matches("^1[3-9]\\d{9}$")) { String mobileCode = reqVO.getAreaCode() + StrUtil.COLON + reqVO.getPhone();
throw exception(USER_ADDRESS_FIELD_ERROR,"phone number error"); paramValidatorApi.validatorMobile(mobileCode);
}
} }
private void updateIsDefault(UserAddressBaseVO updateReqVO, Long id) { private void updateIsDefault(UserAddressBaseVO updateReqVO, Long id) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment