- 调通 用户商品地址
This commit is contained in:
@@ -30,19 +30,19 @@ public class UserAddressController {
|
||||
|
||||
@PostMapping("add")
|
||||
@ApiOperation(value = "用户地址-添加")
|
||||
public CommonResult addAddress(@RequestBody @Validated UserAddressAddPO userAddressAddPO) {
|
||||
public CommonResult addAddress(@Validated UserAddressAddPO userAddressAddPO) {
|
||||
Integer userId = UserSecurityContextHolder.getContext().getUserId();
|
||||
UserAddressAddDTO userAddressAddDTO = UserAddressConvert.INSTANCE.convert(userAddressAddPO);
|
||||
userAddressAddDTO.setUserId(userId);
|
||||
userAddressAddDTO.setUserId(1);
|
||||
return userAddressService.addAddress(userAddressAddDTO);
|
||||
}
|
||||
|
||||
@PutMapping("update")
|
||||
@ApiOperation(value = "用户地址-更新")
|
||||
public CommonResult updateAddress(@RequestBody @Validated UserAddressUpdatePO userAddressUpdatePO) {
|
||||
public CommonResult updateAddress(@Validated UserAddressUpdatePO userAddressUpdatePO) {
|
||||
Integer userId = UserSecurityContextHolder.getContext().getUserId();
|
||||
UserAddressUpdateDTO userAddressUpdateDTO = UserAddressConvert.INSTANCE.convert(userAddressUpdatePO);
|
||||
userAddressUpdateDTO.setUserId(userId);
|
||||
userAddressUpdateDTO.setUserId(1);
|
||||
return userAddressService.updateAddress(userAddressUpdateDTO);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class UserAddressController {
|
||||
@ApiOperation(value = "用户地址-删除")
|
||||
public CommonResult removeAddress(@RequestParam("id") Integer id) {
|
||||
Integer userId = UserSecurityContextHolder.getContext().getUserId();
|
||||
return userAddressService.removeAddress(userId, id);
|
||||
return userAddressService.removeAddress(1, id);
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
@@ -59,4 +59,11 @@ public class UserAddressController {
|
||||
Integer userId = UserSecurityContextHolder.getContext().getUserId();
|
||||
return userAddressService.addressList(1);
|
||||
}
|
||||
|
||||
@GetMapping("address")
|
||||
@ApiOperation(value = "获取地址")
|
||||
public CommonResult getAddress(@RequestParam("id") Integer id) {
|
||||
Integer userId = UserSecurityContextHolder.getContext().getUserId();
|
||||
return userAddressService.getAddress(1, id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,4 +22,6 @@ public interface UserAddressService {
|
||||
CommonResult removeAddress(Integer userId, Integer addressId);
|
||||
|
||||
CommonResult<List<UserAddressBO>> addressList(Integer userId);
|
||||
|
||||
CommonResult<UserAddressBO> getAddress(Integer userId, Integer id);
|
||||
}
|
||||
|
||||
@@ -5,4 +5,96 @@ package cn.iocoder.mall.user.api.bo;
|
||||
* @time 2019-04-06 13:28
|
||||
*/
|
||||
public class UserAddressBO {
|
||||
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 收件区域编号
|
||||
*/
|
||||
private String areaNo;
|
||||
/**
|
||||
* 收件人名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 收件手机号
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 收件详细地址
|
||||
*/
|
||||
private String address;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserAddressBO{" +
|
||||
"id=" + id +
|
||||
", userId=" + userId +
|
||||
", areaNo='" + areaNo + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", mobile='" + mobile + '\'' +
|
||||
", address='" + address + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public UserAddressBO setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public UserAddressBO setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAreaNo() {
|
||||
return areaNo;
|
||||
}
|
||||
|
||||
public UserAddressBO setAreaNo(String areaNo) {
|
||||
this.areaNo = areaNo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public UserAddressBO setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public UserAddressBO setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public UserAddressBO setAddress(String address) {
|
||||
this.address = address;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ public interface UserAddressConvert {
|
||||
@Mappings({})
|
||||
UserAddressDO convert(UserAddressUpdateDTO userAddressUpdateDTO);
|
||||
|
||||
@Mappings({})
|
||||
UserAddressBO convert(UserAddressDO userAddressDO);
|
||||
|
||||
@Mappings({})
|
||||
List<UserAddressBO> convertUserAddressBOList(List<UserAddressDO> userAddressDOList);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class UserAddressServiceImpl implements UserAddressService {
|
||||
.selectByUserIdAndId(userAddressAddDTO.getUserId(), userAddressAddDTO.getId());
|
||||
|
||||
if (DeletedStatusEnum.DELETED_YES.getValue().equals(userAddress.getDeleted())) {
|
||||
return CommonResult.success(UserErrorCodeEnum.USER_ADDRESS_IS_DELETED.getCode());
|
||||
return ServiceExceptionUtil.error(UserErrorCodeEnum.USER_ADDRESS_IS_DELETED.getCode());
|
||||
}
|
||||
|
||||
if (userAddress == null) {
|
||||
@@ -89,4 +89,16 @@ public class UserAddressServiceImpl implements UserAddressService {
|
||||
|
||||
return CommonResult.success(userAddressBOList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<UserAddressBO> getAddress(Integer userId, Integer id) {
|
||||
UserAddressDO userAddress = userAddressMapper.selectByUserIdAndId(userId, id);
|
||||
|
||||
if (DeletedStatusEnum.DELETED_YES.getValue().equals(userAddress.getDeleted())) {
|
||||
return ServiceExceptionUtil.error(UserErrorCodeEnum.USER_ADDRESS_IS_DELETED.getCode());
|
||||
}
|
||||
|
||||
UserAddressBO userAddressBO = UserAddressConvert.INSTANCE.convert(userAddress);
|
||||
return CommonResult.success(userAddressBO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
|
||||
<insert id="insert" parameterType="UserAddressDO" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO user_address (
|
||||
user_id, area_no, `name`, mobile, address
|
||||
user_id, area_no, `name`, mobile, address,
|
||||
create_time, update_time, deleted
|
||||
) VALUES (
|
||||
#{userId}, #{areaNo}, #{name}, #{mobile}, #{address},
|
||||
#{createTime}, #{updateTime}, #{deleted}
|
||||
|
||||
Reference in New Issue
Block a user