11 changed files with 81 additions and 29 deletions
@ -0,0 +1,68 @@ |
|||
package com.ccsens.cloudutil.feign; |
|||
|
|||
import com.ccsens.cloudutil.bean.tall.dto.LogDto; |
|||
import com.ccsens.cloudutil.bean.tall.dto.ProjectDto; |
|||
import com.ccsens.cloudutil.config.FeignTokenConfig; |
|||
import com.ccsens.util.JsonResponse; |
|||
import feign.hystrix.FallbackFactory; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
|
|||
/** |
|||
* @author 逗 |
|||
*/ |
|||
@FeignClient(name = "tall3", path = "v3.0",fallbackFactory = Tall3FeignClientFallBack.class) |
|||
public interface Tall3FeignClient { |
|||
/** |
|||
* 根据token获取userId |
|||
* |
|||
* @param token |
|||
* @return |
|||
*/ |
|||
@GetMapping("users/token") |
|||
JsonResponse getUserIdByToken(@RequestParam(required = true, name = "token") String token); |
|||
|
|||
/** |
|||
* 记录操作日志 |
|||
* |
|||
* @param logDto |
|||
* @return |
|||
*/ |
|||
@RequestMapping("/log/operation") |
|||
JsonResponse log(LogDto logDto); |
|||
|
|||
/** |
|||
* 在tall3内保存项目信息 |
|||
*/ |
|||
@RequestMapping("/project/save") |
|||
JsonResponse saveProjectList(ProjectDto.SaveProjectDto projectDto); |
|||
} |
|||
|
|||
@Slf4j |
|||
@Component |
|||
class Tall3FeignClientFallBack implements FallbackFactory<Tall3FeignClient> { |
|||
|
|||
@Override |
|||
public Tall3FeignClient create(Throwable cause) { |
|||
log.error("访问tall3异常", cause); |
|||
return new Tall3FeignClient() { |
|||
@Override |
|||
public JsonResponse getUserIdByToken(String token) { |
|||
return null; |
|||
} |
|||
@Override |
|||
public JsonResponse log(LogDto logDto) { |
|||
return null; |
|||
} |
|||
|
|||
@Override |
|||
public JsonResponse saveProjectList(ProjectDto.SaveProjectDto projectDto) { |
|||
return null; |
|||
} |
|||
}; |
|||
} |
|||
} |
@ -1,5 +1,5 @@ |
|||
spring: |
|||
profiles: |
|||
active: dev |
|||
include: util-dev,common |
|||
active: test |
|||
include: util-test,common |
|||
|
|||
|
Loading…
Reference in new issue