diff --git a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoOrderController.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoOrderController.java index 96acbf79e..da6dd58ea 100644 --- a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoOrderController.java +++ b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoOrderController.java @@ -1,7 +1,7 @@ package cn.iocoder.mall.demo.application.controller; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.demo.application.convert.DemOrderConvert; +import cn.iocoder.mall.demo.application.convert.DemoOrderConvert; import cn.iocoder.mall.demo.application.dto.DemoOrderAddDTO; import cn.iocoder.mall.demo.business.api.DemoOrderService; import cn.iocoder.mall.demo.business.bo.order.DemoOrderAddBO; @@ -19,7 +19,7 @@ public class DemoOrderController { @PostMapping("/add") public CommonResult add(DemoOrderAddDTO addDTO) { - DemoOrderAddBO addBO = DemOrderConvert.INSTANCE.convert(addDTO); + DemoOrderAddBO addBO = DemoOrderConvert.INSTANCE.convert(addDTO); addBO.setUserId(10); // TODO 10 用户编号。 Integer orderId = demoOrderService.add(addBO); return CommonResult.success(orderId); diff --git a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoProductController.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoProductController.java index f5f717ee5..3dc6ebcf7 100644 --- a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoProductController.java +++ b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoProductController.java @@ -5,8 +5,6 @@ import cn.iocoder.mall.demo.application.convert.DemoProductConvert; import cn.iocoder.mall.demo.application.vo.DemoProductVO; import cn.iocoder.mall.demo.business.api.DemoProductService; import cn.iocoder.mall.demo.business.bo.product.DemoProductBO; -import cn.iocoder.mall.demo.rpc.api.DemoProductRpcService; -import org.apache.dubbo.config.annotation.Reference; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -20,20 +18,10 @@ public class DemoProductController { @Autowired private DemoProductService productService; - @Reference(validation = "true", version = "${dubbo.consumer.DemoProductRpcService.version}") - private DemoProductRpcService productRpcService; - @GetMapping("/get") public CommonResult get(@RequestParam("id") Integer id) { DemoProductBO product = productService.get(id); return CommonResult.success(DemoProductConvert.INSTANCE.convert(product)); } - // TODO 芋艿,这里只是做一个 demo 。实际一般不会这么玩,更多是内嵌的,像 {@link #get(Integer id)} 的情况。 - @GetMapping("/get2") - public CommonResult get2(@RequestParam("id") Integer id) { - cn.iocoder.mall.demo.rpc.vo.DemoProductVO product = productRpcService.get(id); - return null; - } - } diff --git a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoUserController.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoUserController.java new file mode 100644 index 000000000..0d74a44c4 --- /dev/null +++ b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/controller/DemoUserController.java @@ -0,0 +1,27 @@ +package cn.iocoder.mall.demo.application.controller; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.demo.application.convert.DemoUserConvert; +import cn.iocoder.mall.demo.application.vo.DemoUserVO; +import cn.iocoder.mall.demo.rpc.api.DemoUserRpcService; +import org.apache.dubbo.config.annotation.Reference; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/user") +public class DemoUserController { + + @Reference(validation = "true", version = "${dubbo.consumer.DemoUserRpcService.version}") + private DemoUserRpcService userRpcService; + + // TODO 芋艿,这里只是做一个 demo 。实际一般不会这么玩,更多是内嵌的,像 {@link #get(Integer id)} 的情况。 + @GetMapping("/get") + public CommonResult get(@RequestParam("id") Integer id) { + cn.iocoder.mall.demo.rpc.vo.DemoUserVO user = userRpcService.get(id); + return CommonResult.success(DemoUserConvert.INSTANCE.convert(user)); + } + +} diff --git a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemOrderConvert.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoOrderConvert.java similarity index 76% rename from demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemOrderConvert.java rename to demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoOrderConvert.java index 78dee01db..3c3797868 100644 --- a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemOrderConvert.java +++ b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoOrderConvert.java @@ -7,9 +7,9 @@ import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; @Mapper -public interface DemOrderConvert { +public interface DemoOrderConvert { - DemOrderConvert INSTANCE = Mappers.getMapper(DemOrderConvert.class); + DemoOrderConvert INSTANCE = Mappers.getMapper(DemoOrderConvert.class); @Mappings({}) DemoOrderAddBO convert(DemoOrderAddDTO addDTO); diff --git a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoUserConvert.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoUserConvert.java new file mode 100644 index 000000000..aa6fde944 --- /dev/null +++ b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/convert/DemoUserConvert.java @@ -0,0 +1,16 @@ +package cn.iocoder.mall.demo.application.convert; + +import cn.iocoder.mall.demo.application.vo.DemoUserVO; +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface DemoUserConvert { + + DemoUserConvert INSTANCE = Mappers.getMapper(DemoUserConvert.class); + + @Mappings({}) + DemoUserVO convert(cn.iocoder.mall.demo.rpc.vo.DemoUserVO vo); + +} diff --git a/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/vo/DemoUserVO.java b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/vo/DemoUserVO.java new file mode 100644 index 000000000..214f46c25 --- /dev/null +++ b/demo/demo-application/src/main/java/cn/iocoder/mall/demo/application/vo/DemoUserVO.java @@ -0,0 +1,23 @@ +package cn.iocoder.mall.demo.application.vo; + +import lombok.Data; +import lombok.experimental.Accessors; + +@Data +@Accessors(chain = true) +public class DemoUserVO { + + /** + * 用户编号 + */ + private Integer id; + /** + * 昵称 + */ + private String name; + /** + * 性别 + */ + private Integer gender; + +} diff --git a/demo/demo-application/src/main/resources/application-local.yaml b/demo/demo-application/src/main/resources/application-local.yaml index 7973f5c06..60380b557 100644 --- a/demo/demo-application/src/main/resources/application-local.yaml +++ b/demo/demo-application/src/main/resources/application-local.yaml @@ -11,3 +11,5 @@ dubbo: consumer: DemoProductRpcService: version: 1.0.0 + DemoUserRpcService: + version: 1.0.0 diff --git a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/api/DemoUserService.java b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/api/DemoUserService.java new file mode 100644 index 000000000..57b0f7c23 --- /dev/null +++ b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/api/DemoUserService.java @@ -0,0 +1,9 @@ +package cn.iocoder.mall.demo.business.api; + +import cn.iocoder.mall.demo.business.bo.user.DemoUserBO; + +public interface DemoUserService { + + DemoUserBO get(Integer id); + +} diff --git a/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/user/DemoUserBO.java b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/user/DemoUserBO.java new file mode 100644 index 000000000..b9a8db841 --- /dev/null +++ b/demo/demo-business-api/src/main/java/cn/iocoder/mall/demo/business/bo/user/DemoUserBO.java @@ -0,0 +1,26 @@ +package cn.iocoder.mall.demo.business.bo.user; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * Demo 用户 BO + */ +@Data +@Accessors(chain = true) +public class DemoUserBO { + + /** + * 用户编号 + */ + private Integer id; + /** + * 昵称 + */ + private String name; + /** + * 性别 + */ + private Integer gender; + +} diff --git a/demo/demo-business/pom.xml b/demo/demo-business/pom.xml index bb1fb8d83..4a4b1bc5d 100644 --- a/demo/demo-business/pom.xml +++ b/demo/demo-business/pom.xml @@ -43,6 +43,15 @@ mybatis-plus-boot-starter + + redis.clients + jedis + + + org.springframework.data + spring-data-redis + + com.google.guava diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/cacheobject/package-info.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/cacheobject/package-info.java new file mode 100644 index 000000000..b3e4bc271 --- /dev/null +++ b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/cacheobject/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.mall.demo.business.cacheobject; diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/cacheobject/user/DemoUserCacheObject.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/cacheobject/user/DemoUserCacheObject.java new file mode 100644 index 000000000..07248c575 --- /dev/null +++ b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/cacheobject/user/DemoUserCacheObject.java @@ -0,0 +1,26 @@ +package cn.iocoder.mall.demo.business.cacheobject.user; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 用户缓存对象 + */ +@Data +@Accessors(chain = true) +public class DemoUserCacheObject { + + /** + * 用户编号 + */ + private Integer id; + /** + * 昵称 + */ + private String name; + /** + * 性别 + */ + private Integer gender; + +} diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/convert/DemoUserConvert.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/convert/DemoUserConvert.java new file mode 100644 index 000000000..2e043b1ea --- /dev/null +++ b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/convert/DemoUserConvert.java @@ -0,0 +1,17 @@ +package cn.iocoder.mall.demo.business.convert; + +import cn.iocoder.mall.demo.business.bo.user.DemoUserBO; +import cn.iocoder.mall.demo.business.cacheobject.user.DemoUserCacheObject; +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface DemoUserConvert { + + DemoUserConvert INSTANCE = Mappers.getMapper(DemoUserConvert.class); + + @Mappings({}) + DemoUserBO convert(DemoUserCacheObject object); + +} diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/DemoOrderMapper.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/mysql/DemoOrderMapper.java similarity index 83% rename from demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/DemoOrderMapper.java rename to demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/mysql/DemoOrderMapper.java index 979e4e43e..0552f35bb 100644 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/DemoOrderMapper.java +++ b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/mysql/DemoOrderMapper.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.demo.business.dao; +package cn.iocoder.mall.demo.business.dao.mysql; import cn.iocoder.mall.demo.business.dataobject.order.DemoOrderDO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/DemoProductMapper.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/mysql/DemoProductMapper.java similarity index 89% rename from demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/DemoProductMapper.java rename to demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/mysql/DemoProductMapper.java index 83041b50e..59e167a66 100644 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/DemoProductMapper.java +++ b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/mysql/DemoProductMapper.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.demo.business.dao; +package cn.iocoder.mall.demo.business.dao.mysql; import cn.iocoder.mall.demo.business.dataobject.product.DemoProductDO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/redis/DemoUserCacheDao.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/redis/DemoUserCacheDao.java new file mode 100644 index 000000000..c3cb4b083 --- /dev/null +++ b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/dao/redis/DemoUserCacheDao.java @@ -0,0 +1,31 @@ +package cn.iocoder.mall.demo.business.dao.redis; + +import cn.iocoder.mall.demo.business.cacheobject.user.DemoUserCacheObject; +import com.alibaba.fastjson.JSON; +import org.springframework.data.redis.core.ValueOperations; +import org.springframework.stereotype.Repository; + +import javax.annotation.Resource; + +@Repository +public class DemoUserCacheDao { + + private static final String KEY_PREFIX = "user_"; + + @Resource(name = "redisTemplate") + @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") + private ValueOperations operations; + + private static String buildKey(Integer id) { + return KEY_PREFIX + id; + } + + public DemoUserCacheObject get(Integer id) { + return JSON.parseObject(operations.get(buildKey(id)), DemoUserCacheObject.class); + } + + public void set(Integer id, DemoUserCacheObject value) { + operations.set(buildKey(id), JSON.toJSONString(value)); + } + +} diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoOrderServiceImpl.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoOrderServiceImpl.java index 193e664d3..1cfa589a3 100644 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoOrderServiceImpl.java +++ b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoOrderServiceImpl.java @@ -10,7 +10,7 @@ import cn.iocoder.mall.demo.business.bo.product.DemoProductBO; import cn.iocoder.mall.demo.business.bo.product.DemoProductQuantityReduceBO; import cn.iocoder.mall.demo.business.constant.OrderStatusEnum; import cn.iocoder.mall.demo.business.convert.DemoOrderConvert; -import cn.iocoder.mall.demo.business.dao.DemoOrderMapper; +import cn.iocoder.mall.demo.business.dao.mysql.DemoOrderMapper; import cn.iocoder.mall.demo.business.dataobject.order.DemoOrderDO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoProductServiceImpl.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoProductServiceImpl.java index 6f35cedd1..cfdddbce3 100644 --- a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoProductServiceImpl.java +++ b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoProductServiceImpl.java @@ -5,7 +5,7 @@ import cn.iocoder.common.framework.vo.PageResult; import cn.iocoder.mall.demo.business.api.DemoProductService; import cn.iocoder.mall.demo.business.bo.product.*; import cn.iocoder.mall.demo.business.convert.DemoProductConvert; -import cn.iocoder.mall.demo.business.dao.DemoProductMapper; +import cn.iocoder.mall.demo.business.dao.mysql.DemoProductMapper; import cn.iocoder.mall.demo.business.dataobject.product.DemoProductDO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoUserServiceImpl.java b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoUserServiceImpl.java new file mode 100644 index 000000000..78680578e --- /dev/null +++ b/demo/demo-business/src/main/java/cn/iocoder/mall/demo/business/service/DemoUserServiceImpl.java @@ -0,0 +1,27 @@ +package cn.iocoder.mall.demo.business.service; + +import cn.iocoder.mall.demo.business.api.DemoUserService; +import cn.iocoder.mall.demo.business.bo.user.DemoUserBO; +import cn.iocoder.mall.demo.business.cacheobject.user.DemoUserCacheObject; +import cn.iocoder.mall.demo.business.convert.DemoUserConvert; +import cn.iocoder.mall.demo.business.dao.redis.DemoUserCacheDao; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class DemoUserServiceImpl implements DemoUserService { + + @Autowired + private DemoUserCacheDao userCacheDao; + + @Override + public DemoUserBO get(Integer id) { + DemoUserCacheObject userCacheObject = userCacheDao.get(id); + if (userCacheObject == null) { // TODO 芋艿,临时 + userCacheDao.set(id, new DemoUserCacheObject().setId(id) + .setName("芋艿").setGender(1)); + } + return DemoUserConvert.INSTANCE.convert(userCacheObject); + } + +} diff --git a/demo/demo-business/src/main/resources/business-local.yaml b/demo/demo-business/src/main/resources/business-local.yaml index 0daca8bcb..2ee552db3 100644 --- a/demo/demo-business/src/main/resources/business-local.yaml +++ b/demo/demo-business/src/main/resources/business-local.yaml @@ -5,6 +5,8 @@ spring: driver-class-name: com.mysql.jdbc.Driver username: testb5f4 password: F4df4db0ed86@11 + # redis + redis: # mybatis-plus mybatis-plus: @@ -17,3 +19,4 @@ mybatis-plus: logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) mapperLocations: classpath*:mapper/*.xml typeAliasesPackage: cn.iocoder.mall.demo.business.dataobject + diff --git a/demo/demo-business/src/main/resources/mapper/DemoProductMapper.xml b/demo/demo-business/src/main/resources/mapper/DemoProductMapper.xml index 81628eb3d..61ef03cd3 100644 --- a/demo/demo-business/src/main/resources/mapper/DemoProductMapper.xml +++ b/demo/demo-business/src/main/resources/mapper/DemoProductMapper.xml @@ -1,6 +1,6 @@ - + UPDATE product diff --git a/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/api/DemoUserRpcService.java b/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/api/DemoUserRpcService.java new file mode 100644 index 000000000..0aca7d3ca --- /dev/null +++ b/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/api/DemoUserRpcService.java @@ -0,0 +1,9 @@ +package cn.iocoder.mall.demo.rpc.api; + +import cn.iocoder.mall.demo.rpc.vo.DemoUserVO; + +public interface DemoUserRpcService { + + DemoUserVO get(Integer id); + +} diff --git a/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/vo/DemoUserVO.java b/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/vo/DemoUserVO.java new file mode 100644 index 000000000..e8212f2df --- /dev/null +++ b/demo/demo-rpc-service-api/src/main/java/cn/iocoder/mall/demo/rpc/vo/DemoUserVO.java @@ -0,0 +1,23 @@ +package cn.iocoder.mall.demo.rpc.vo; + +import lombok.Data; +import lombok.experimental.Accessors; + +@Data +@Accessors(chain = true) +public class DemoUserVO { + + /** + * 用户编号 + */ + private Integer id; + /** + * 昵称 + */ + private String name; + /** + * 性别 + */ + private Integer gender; + +} diff --git a/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/convert/DemoUserConvert.java b/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/convert/DemoUserConvert.java new file mode 100644 index 000000000..f9d4352cc --- /dev/null +++ b/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/convert/DemoUserConvert.java @@ -0,0 +1,17 @@ +package cn.iocoder.mall.demo.rpc.convert; + +import cn.iocoder.mall.demo.business.bo.user.DemoUserBO; +import cn.iocoder.mall.demo.rpc.vo.DemoUserVO; +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface DemoUserConvert { + + DemoUserConvert INSTANCE = Mappers.getMapper(DemoUserConvert.class); + + @Mappings({}) + DemoUserVO convert(DemoUserBO object); + +} diff --git a/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/service/DemoUserRpcServiceImpl.java b/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/service/DemoUserRpcServiceImpl.java new file mode 100644 index 000000000..776f92ded --- /dev/null +++ b/demo/demo-rpc-service/src/main/java/cn/iocoder/mall/demo/rpc/service/DemoUserRpcServiceImpl.java @@ -0,0 +1,23 @@ +package cn.iocoder.mall.demo.rpc.service; + +import cn.iocoder.mall.demo.business.api.DemoUserService; +import cn.iocoder.mall.demo.business.bo.user.DemoUserBO; +import cn.iocoder.mall.demo.rpc.api.DemoUserRpcService; +import cn.iocoder.mall.demo.rpc.convert.DemoUserConvert; +import cn.iocoder.mall.demo.rpc.vo.DemoUserVO; +import org.apache.dubbo.config.annotation.Service; +import org.springframework.beans.factory.annotation.Autowired; + +@Service(validation = "true", version = "${dubbo.provider.DemoUserRpcService.version}") +public class DemoUserRpcServiceImpl implements DemoUserRpcService { + + @Autowired + private DemoUserService demoUserService; + + @Override + public DemoUserVO get(Integer id) { + DemoUserBO userBO = demoUserService.get(id); + return DemoUserConvert.INSTANCE.convert(userBO); + } + +} diff --git a/demo/demo-rpc-service/src/main/resources/rpc-local.yaml b/demo/demo-rpc-service/src/main/resources/rpc-local.yaml index 6f49e31e7..91477b775 100644 --- a/demo/demo-rpc-service/src/main/resources/rpc-local.yaml +++ b/demo/demo-rpc-service/src/main/resources/rpc-local.yaml @@ -16,3 +16,5 @@ dubbo: # filter: -exception DemoProductRpcService: version: 1.0.0 + DemoUserRpcService: + version: 1.0.0