From 83ccd6729f956f0d1ca352eeefe8d69e2114b524 Mon Sep 17 00:00:00 2001 From: cherishsince Date: Thu, 14 May 2020 14:07:30 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E9=87=8D=E6=96=B0=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=9ARPC=20=E8=B0=83=E7=94=A8=EF=BC=8C=E6=9A=82=E6=97=B6?= =?UTF-8?q?=E5=8F=AA=E5=85=AC=E5=BC=80=20getAddress=20=E5=92=8C=20getDefau?= =?UTF-8?q?ltAddress?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mall/user/rpc/api/UserAddressRPC.java | 29 +++++++------- .../convert/user/UserAddressRPCConvert.java | 20 +--------- .../user/rpc/rpc/user/UserAddressRPCImpl.java | 39 ++++++------------- 3 files changed, 27 insertions(+), 61 deletions(-) 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))); } }