diff --git a/epmet-module/epmet-demo/epmet-demo-server/pom.xml b/epmet-module/epmet-demo/epmet-demo-server/pom.xml index d331612129..8e5d67e67c 100644 --- a/epmet-module/epmet-demo/epmet-demo-server/pom.xml +++ b/epmet-module/epmet-demo/epmet-demo-server/pom.xml @@ -55,6 +55,12 @@ 2.0.0 compile + + com.epmet + gov-org-client + 2.0.0 + compile + diff --git a/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/controller/DemoController.java index e3d1f43721..8ea90173df 100644 --- a/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/controller/DemoController.java +++ b/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/controller/DemoController.java @@ -32,7 +32,6 @@ import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.excel.DemoExcel; import com.epmet.service.DemoService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; @@ -115,4 +114,10 @@ public class DemoController { ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); return demoService.saveCustomerInfo(dto); } + + @PostMapping("/testDemoToGov") + public String testDemoToGov(){ + + return demoService.testDemo2Gov(); + } } diff --git a/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java b/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java new file mode 100644 index 0000000000..c955830654 --- /dev/null +++ b/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java @@ -0,0 +1,25 @@ +package com.epmet.feign; + + + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerGridDTO; +import com.epmet.feign.impl.GovOrgFeignClientFallBack; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; + +/** + * Created by 11 on 2020/3/18. + */ +@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallBack.class, url="http://localhost:8092") +public interface GovOrgFeignClient { + + + @GetMapping("gov/org/customergrid/page") + Result> page(); + + + +} diff --git a/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/feign/impl/GovOrgFeignClientFallBack.java b/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/feign/impl/GovOrgFeignClientFallBack.java new file mode 100644 index 0000000000..eab629cec6 --- /dev/null +++ b/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/feign/impl/GovOrgFeignClientFallBack.java @@ -0,0 +1,25 @@ +package com.epmet.feign.impl;/** + * Created by 11 on 2020/3/18. + */ + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerGridDTO; +import com.epmet.feign.GovOrgFeignClient; +import org.springframework.stereotype.Component; + +/** + * @Description + * @ClassName GovOrgFeignClientFallBack + * @Author wangc + * @date 2020.03.18 14:52 + */ +@Component +public class GovOrgFeignClientFallBack implements GovOrgFeignClient{ + @Override + public Result> page() { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "page"); + } +} diff --git a/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/service/DemoService.java b/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/service/DemoService.java index ab5a997da0..a9331a78e7 100644 --- a/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/service/DemoService.java +++ b/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/service/DemoService.java @@ -104,4 +104,6 @@ public interface DemoService extends BaseService { Result queryCustomerInfo(String customerId); Result saveCustomerInfo(SaveCustomerFormDTO dto); + + String testDemo2Gov(); } diff --git a/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/service/impl/DemoServiceImpl.java b/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/service/impl/DemoServiceImpl.java index 9299b20ddd..a75132488b 100644 --- a/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/service/impl/DemoServiceImpl.java +++ b/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/service/impl/DemoServiceImpl.java @@ -26,10 +26,12 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.DemoDao; import com.epmet.dto.CustomerDTO; +import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.DemoDTO; import com.epmet.dto.form.SaveCustomerFormDTO; import com.epmet.dto.result.ValidCustomerResultDTO; import com.epmet.entity.DemoEntity; +import com.epmet.feign.GovOrgFeignClient; import com.epmet.feign.OperCrmFeignClient; import com.epmet.redis.DemoRedis; import com.epmet.service.DemoService; @@ -58,6 +60,8 @@ public class DemoServiceImpl extends BaseServiceImpl implem private DemoRedis demoRedis; @Autowired private OperCrmFeignClient operCrmFeignClient; + @Autowired + private GovOrgFeignClient govOrgFeignClient; @Override public PageData page(Map params) { IPage page = baseDao.selectPage( @@ -147,4 +151,16 @@ public class DemoServiceImpl extends BaseServiceImpl implem return operCrmFeignClient.saveCustomerInfo(dto); } + @Override + public String testDemo2Gov() { + Result> testResult = + govOrgFeignClient.page(); + if(testResult.success()){ + return "成功了"; + }else{ + return "失败了"; + } + + } + } diff --git a/epmet-module/gov-org/gov-org-client/pom.xml b/epmet-module/gov-org/gov-org-client/pom.xml index 59518f86e2..e9c924f60d 100644 --- a/epmet-module/gov-org/gov-org-client/pom.xml +++ b/epmet-module/gov-org/gov-org-client/pom.xml @@ -10,7 +10,7 @@ gov-org-client - jar + diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/GovOrgApplication.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/GovOrgApplication.java index 7f1f254652..d4cafe7020 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/GovOrgApplication.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/GovOrgApplication.java @@ -10,6 +10,8 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; /** * @@ -18,6 +20,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; * @since 1.0.0 */ @SpringBootApplication +@EnableDiscoveryClient +@EnableFeignClients public class GovOrgApplication { public static void main(String[] args) {