- 重新优化:RPC 调用,暂时只公开 getAddress 和 getDefaultAddress
This commit is contained in:
parent
5733a56e68
commit
83ccd6729f
@ -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<UserAddressResponse> getAddress(Integer id);
|
||||
|
||||
void updateAddress(UserAddressUpdateRequest userAddressUpdateRequest);
|
||||
|
||||
void removeAddress(Integer userId, Integer addressId);
|
||||
|
||||
List<UserAddressResponse> addressList(Integer userId);
|
||||
|
||||
UserAddressResponse getAddress(Integer id);
|
||||
|
||||
UserAddressResponse getDefaultAddress(Integer userId);
|
||||
/**
|
||||
* 获取 - 获取用户默认地址
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
CommonResult<UserAddressResponse> getDefaultAddress(Integer userId);
|
||||
}
|
||||
|
@ -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<UserAddressResponse> convert(List<UserAddressBO> addressBOS);
|
||||
|
||||
|
||||
}
|
||||
|
@ -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<UserAddressResponse> 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<UserAddressResponse> 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<UserAddressResponse> getDefaultAddress(Integer userId) {
|
||||
return CommonResult.success(UserAddressRPCConvert.INSTANCE.convert(userAddressService.getDefaultAddress(userId)));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user