10 changed files with 195 additions and 9 deletions
@ -0,0 +1,32 @@ |
|||
package com.epmet.auth.feign; |
|||
|
|||
import com.epmet.auth.feign.fallback.EpmetAuthOpenFeignClientFallbackFactory; |
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
|
|||
/** |
|||
* 本服务对外开放的API,其他服务通过引用此client调用该服务 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/6/4 13:25 |
|||
*/ |
|||
//@FeignClient(name = ServiceConstant.EPMET_AUTH_SERVER, fallbackFactory = EpmetAuthOpenFeignClientFallbackFactory.class)
|
|||
@FeignClient(name = ServiceConstant.EPMET_AUTH_SERVER, fallbackFactory = EpmetAuthOpenFeignClientFallbackFactory.class, url = "http://localhost:8081") |
|||
public interface EpmetAuthOpenFeignClient { |
|||
|
|||
/** |
|||
* @Description 根据客户Id查询志愿者用户Id集合 |
|||
* @param uuid |
|||
* @param userId |
|||
* @param customerId |
|||
* @return |
|||
* @author wangc |
|||
* @date 2020.08.13 10:22 |
|||
**/ |
|||
@PostMapping("/auth/govweb/generateTokenBySSOKey/{uuid}/{userId}") |
|||
Result<String> generateTokenBySSOKey(@PathVariable(value = "uuid")String uuid, @PathVariable String userId, @RequestParam String customerId); |
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.epmet.auth.feign.fallback; |
|||
|
|||
import com.epmet.auth.feign.EpmetAuthOpenFeignClient; |
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.utils.ModuleUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
|
|||
/** |
|||
* 本服务对外开放的API,其他服务通过引用此client调用该服务 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/6/4 13:26 |
|||
*/ |
|||
public class EpmetAuthOpenFeignClientFallback implements EpmetAuthOpenFeignClient { |
|||
@Override |
|||
public Result<String> generateTokenBySSOKey(String uuid, String userId, String customerId) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPMET_AUTH_SERVER, "generateTokenBySSOKey", uuid, userId,customerId); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.epmet.auth.feign.fallback; |
|||
|
|||
import com.epmet.auth.feign.EpmetAuthOpenFeignClient; |
|||
import com.epmet.commons.tools.exception.ExceptionUtils; |
|||
import feign.hystrix.FallbackFactory; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
@Component |
|||
@Slf4j |
|||
public class EpmetAuthOpenFeignClientFallbackFactory implements FallbackFactory<EpmetAuthOpenFeignClient> { |
|||
|
|||
private EpmetAuthOpenFeignClientFallback fallback = new EpmetAuthOpenFeignClientFallback(); |
|||
|
|||
@Override |
|||
public EpmetAuthOpenFeignClient create(Throwable cause) { |
|||
log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); |
|||
return fallback; |
|||
} |
|||
} |
Loading…
Reference in new issue