Browse Source

新增GovOrgOpenFeignClient

dev_shibei_match
yinzuomei 5 years ago
parent
commit
55b8aeaec8
  1. 34
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgFeignClient.java
  2. 27
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java
  3. 27
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java
  4. 13
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java

34
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgFeignClient.java

@ -1,34 +0,0 @@
package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.form.LatestGridFormDTO;
import com.epmet.dto.form.StaffInfoFromDTO;
import com.epmet.dto.result.CustomerGridByUserIdResultDTO;
import com.epmet.dto.result.LatestCustomerResultDTO;
import com.epmet.dto.result.MineResultDTO;
import com.epmet.feign.fallback.GovOrgFeignClientFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* @Description url = "localhost:8092"
* @Author sun
*/
@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallBack.class)
public interface GovOrgFeignClient {
/**
* 根据staffId查询所属的组织机构
* @param staffId
* @return
*/
@PostMapping("/gov/org/agency/agencybystaff/{staffId}")
Result<CustomerAgencyDTO> getAgencyByStaff(@PathVariable("staffId") String staffId);
}

27
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java

@ -1,23 +1,40 @@
package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.feign.callback.GovOrgOpenFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
//@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgOpenFeignClientFallback.class, url = "localhost:8092")
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.feign.fallback.GovOrgOpenFeignClientFallback;
/**
* 本服务对外开放的API,其他服务通过引用此client调用该服务
*
* @author yinzuomei@elink-cn.com
* @date 2020/6/4 13:37
*/
// @FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgOpenFeignClientFallback.class, url =
// "localhost:8092")
@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgOpenFeignClientFallback.class)
public interface GovOrgOpenFeignClient {
/**
* 根据Id查询agency
*
* @param agencyId
* @return
*/
@PostMapping("/gov/org/agency/agencybyid/{agencyId}")
Result<CustomerAgencyDTO> getAgencyById(@PathVariable("agencyId") String agencyId);
/**
* 根据staffId查询所属的组织机构
*
* @param staffId
* @return
*/
@PostMapping("/gov/org/agency/agencybystaff/{staffId}")
Result<CustomerAgencyDTO> getAgencyByStaff(@PathVariable("staffId") String staffId);
}

27
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java

@ -1,27 +0,0 @@
package com.epmet.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.form.LatestGridFormDTO;
import com.epmet.dto.form.StaffInfoFromDTO;
import com.epmet.dto.result.CustomerGridByUserIdResultDTO;
import com.epmet.dto.result.LatestCustomerResultDTO;
import com.epmet.dto.result.MineResultDTO;
import com.epmet.feign.GovOrgFeignClient;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @Description
* @Author sun
*/
@Component
public class GovOrgFeignClientFallBack implements GovOrgFeignClient {
@Override
public Result<CustomerAgencyDTO> getAgencyByStaff(String staffId) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getAgencyByStaff", staffId);
}
}

13
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/callback/GovOrgOpenFeignClientFallback.java → epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java

@ -1,4 +1,4 @@
package com.epmet.feign.callback;
package com.epmet.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils;
@ -7,10 +7,21 @@ import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.feign.GovOrgOpenFeignClient;
import org.springframework.stereotype.Component;
/**
* 本服务对外开放的API,其他服务通过引用此client调用该服务
*
* @author yinzuomei@elink-cn.com
* @date 2020/6/4 13:37
*/
@Component
public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient {
@Override
public Result<CustomerAgencyDTO> getAgencyById(String agencyId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getAgencyById", agencyId);
}
@Override
public Result<CustomerAgencyDTO> getAgencyByStaff(String staffId) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getAgencyByStaff", staffId);
}
}
Loading…
Cancel
Save