Commit df1a30a9 authored by zhangfeng's avatar zhangfeng

客户端地址管理

parent 0904f244
......@@ -3,8 +3,10 @@ package cn.iocoder.yudao.module.member.service.address;
import java.util.*;
import javax.annotation.Resource;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
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.dal.dataobject.address.UserAddressDO;
import cn.iocoder.yudao.module.member.dal.mysql.address.UserAddressMapper;
......@@ -35,9 +37,12 @@ public class UserAddressServiceImpl extends AbstractService<UserAddressMapper, U
private UserAddressMapper userAddressMapper;
@Resource
private MemberUserService userService;
@Resource
private ParamValidatorApi paramValidatorApi;
@Override
public Long createUserAddress(UserAddressCreateReqVO createReqVO) {
verifyUserAddress(createReqVO);
// 插入
UserAddressDO userAddress = UserAddressConvert.INSTANCE.convert(createReqVO);
updateIsDefault(createReqVO, 0L);
......@@ -48,6 +53,7 @@ public class UserAddressServiceImpl extends AbstractService<UserAddressMapper, U
@Override
public void updateUserAddress(UserAddressUpdateReqVO updateReqVO) {
verifyUserAddress(updateReqVO);
// 校验存在
this.validateUserAddressExists(updateReqVO.getId());
updateIsDefault(updateReqVO, updateReqVO.getId());
......@@ -67,9 +73,8 @@ public class UserAddressServiceImpl extends AbstractService<UserAddressMapper, U
throw exception(USER_ADDRESS_FIELD_ERROR,"Address,AreaCode,Name,Phone must not null");
}
// 校验手机号格式
if (!reqVO.getPhone().matches("^1[3-9]\\d{9}$")) {
throw exception(USER_ADDRESS_FIELD_ERROR,"phone number error");
}
String mobileCode = reqVO.getAreaCode() + StrUtil.COLON + reqVO.getPhone();
paramValidatorApi.validatorMobile(mobileCode);
}
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