diff --git a/user/user-rpc-api/src/main/java/cn/iocoder/mall/user/rpc/api/UserAddressRPC.java b/user/user-rpc-api/src/main/java/cn/iocoder/mall/user/rpc/api/UserAddressRPC.java index 409d76d74..700f39be1 100644 --- a/user/user-rpc-api/src/main/java/cn/iocoder/mall/user/rpc/api/UserAddressRPC.java +++ b/user/user-rpc-api/src/main/java/cn/iocoder/mall/user/rpc/api/UserAddressRPC.java @@ -1,11 +1,8 @@ package cn.iocoder.mall.user.rpc.api; -import cn.iocoder.mall.user.rpc.request.user.UserAddressAddRequest; -import cn.iocoder.mall.user.rpc.request.user.UserAddressUpdateRequest; +import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.user.rpc.response.user.UserAddressResponse; -import java.util.List; - /** * 用户地址 RPC * @@ -14,15 +11,19 @@ import java.util.List; */ public interface UserAddressRPC { - void addAddress(UserAddressAddRequest userAddressAddRequest); + /** + * 获取 - 根据id获取用户地址 + * + * @param id + * @return + */ + CommonResult getAddress(Integer id); - void updateAddress(UserAddressUpdateRequest userAddressUpdateRequest); - - void removeAddress(Integer userId, Integer addressId); - - List addressList(Integer userId); - - UserAddressResponse getAddress(Integer id); - - UserAddressResponse getDefaultAddress(Integer userId); + /** + * 获取 - 获取用户默认地址 + * + * @param userId + * @return + */ + CommonResult getDefaultAddress(Integer userId); } diff --git a/user/user-rpc/src/main/java/cn/iocoder/mall/user/rpc/convert/user/UserAddressRPCConvert.java b/user/user-rpc/src/main/java/cn/iocoder/mall/user/rpc/convert/user/UserAddressRPCConvert.java index 5539d02a0..6bda9b153 100644 --- a/user/user-rpc/src/main/java/cn/iocoder/mall/user/rpc/convert/user/UserAddressRPCConvert.java +++ b/user/user-rpc/src/main/java/cn/iocoder/mall/user/rpc/convert/user/UserAddressRPCConvert.java @@ -1,17 +1,11 @@ package cn.iocoder.mall.user.rpc.convert.user; import cn.iocoder.mall.user.biz.bo.user.UserAddressBO; -import cn.iocoder.mall.user.biz.dto.user.UserAddressAddDTO; -import cn.iocoder.mall.user.biz.dto.user.UserAddressUpdateDTO; -import cn.iocoder.mall.user.rpc.request.user.UserAddressAddRequest; -import cn.iocoder.mall.user.rpc.request.user.UserAddressUpdateRequest; import cn.iocoder.mall.user.rpc.response.user.UserAddressResponse; import org.mapstruct.Mapper; import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; -import java.util.List; - /** * user address convert * @@ -23,19 +17,7 @@ public interface UserAddressRPCConvert { UserAddressRPCConvert INSTANCE = Mappers.getMapper(UserAddressRPCConvert.class); - - // TODO FROM 芋艿 to 小范:如果不用映射,可以不用 @Mappings 哈 - @Mappings({}) - UserAddressAddDTO convert(UserAddressAddRequest userAddressAddRequest); - - @Mappings({}) - UserAddressUpdateDTO convert(UserAddressUpdateRequest userAddressUpdateRequest); - + // TODO DONE FROM 芋艿 to 小范:如果不用映射,可以不用 @Mappings 哈 @Mappings({}) UserAddressResponse convert(UserAddressBO userAddressBO); - - @Mappings({}) - List convert(List addressBOS); - - } diff --git a/user/user-rpc/src/main/java/cn/iocoder/mall/user/rpc/rpc/user/UserAddressRPCImpl.java b/user/user-rpc/src/main/java/cn/iocoder/mall/user/rpc/rpc/user/UserAddressRPCImpl.java index 60dea4528..fcd85b991 100644 --- a/user/user-rpc/src/main/java/cn/iocoder/mall/user/rpc/rpc/user/UserAddressRPCImpl.java +++ b/user/user-rpc/src/main/java/cn/iocoder/mall/user/rpc/rpc/user/UserAddressRPCImpl.java @@ -1,16 +1,19 @@ package cn.iocoder.mall.user.rpc.rpc.user; +import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.user.biz.service.user.UserAddressService; import cn.iocoder.mall.user.rpc.api.UserAddressRPC; import cn.iocoder.mall.user.rpc.convert.user.UserAddressRPCConvert; -import cn.iocoder.mall.user.rpc.request.user.UserAddressAddRequest; -import cn.iocoder.mall.user.rpc.request.user.UserAddressUpdateRequest; import cn.iocoder.mall.user.rpc.response.user.UserAddressResponse; import org.apache.dubbo.config.annotation.Service; import org.springframework.beans.factory.annotation.Autowired; -import java.util.List; - +/** + * 用户地址 RPC + * + * author: sin + * time: 2020/5/1 10:26 上午 + */ @Service(version = "${dubbo.provider.UserAddressRPC.version}", validation = "true") public class UserAddressRPCImpl implements UserAddressRPC { @@ -18,32 +21,12 @@ public class UserAddressRPCImpl implements UserAddressRPC { private UserAddressService userAddressService; @Override - public void addAddress(UserAddressAddRequest userAddressAddRequest) { - userAddressService.addAddress(UserAddressRPCConvert.INSTANCE.convert(userAddressAddRequest)); + public CommonResult getAddress(Integer id) { + return CommonResult.success(UserAddressRPCConvert.INSTANCE.convert(userAddressService.getAddress(id))); } @Override - public void updateAddress(UserAddressUpdateRequest userAddressUpdateRequest) { - userAddressService.updateAddress(UserAddressRPCConvert.INSTANCE.convert(userAddressUpdateRequest)); - } - - @Override - public void removeAddress(Integer userId, Integer addressId) { - userAddressService.removeAddress(userId, addressId); - } - - @Override - public List addressList(Integer userId) { - return UserAddressRPCConvert.INSTANCE.convert(userAddressService.listAddress(userId)); - } - - @Override - public UserAddressResponse getAddress(Integer id) { - return UserAddressRPCConvert.INSTANCE.convert(userAddressService.getAddress(id)); - } - - @Override - public UserAddressResponse getDefaultAddress(Integer userId) { - return UserAddressRPCConvert.INSTANCE.convert(userAddressService.getDefaultAddress(userId)); + public CommonResult getDefaultAddress(Integer userId) { + return CommonResult.success(UserAddressRPCConvert.INSTANCE.convert(userAddressService.getDefaultAddress(userId))); } }