- demo 项目,增加 RPC 接口

This commit is contained in:
YunaiV
2019-09-23 22:45:06 +08:00
parent 683b9a7a19
commit 580b23885d
21 changed files with 202 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
package cn.iocoder.mall.demo.rpc.convert;
import cn.iocoder.mall.demo.business.bo.product.DemoProductBO;
import cn.iocoder.mall.demo.rpc.vo.DemoProductVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
@Mapper
public interface DemoProductConvert {
DemoProductConvert INSTANCE = Mappers.getMapper(DemoProductConvert.class);
@Mappings({})
DemoProductVO convert(DemoProductBO object);
}

View File

@@ -0,0 +1 @@
package cn.iocoder.mall.demo.rpc;

View File

@@ -0,0 +1,23 @@
package cn.iocoder.mall.demo.rpc.service;
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 cn.iocoder.mall.demo.rpc.convert.DemoProductConvert;
import cn.iocoder.mall.demo.rpc.vo.DemoProductVO;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
@Service(validation = "true", version = "${dubbo.provider.DemoProductRpcService.version}")
public class DemoProductRpcServiceImpl implements DemoProductRpcService {
@Autowired
private DemoProductService productService;
@Override
public DemoProductVO get(Integer id) {
DemoProductBO product = productService.get(id);
return DemoProductConvert.INSTANCE.convert(product);
}
}

View File

@@ -0,0 +1,18 @@
# dubbo
dubbo:
application:
name: demo-service
registry:
address: zookeeper://127.0.0.1:2181
protocol:
port: -1
name: dubbo
scan:
base-packages: cn.iocoder.mall.demo.rpc.service
# consumer:
# ProductSpuService:
# version: 1.0.0
provider:
# filter: -exception
DemoProductRpcService:
version: 1.0.0