15 changed files with 205 additions and 7 deletions
@ -0,0 +1,41 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.epmet.feign; |
|||
|
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.security.user.UserDetail; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.feign.fallback.AdminFeignClientFallback; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
|
|||
/** |
|||
* 用户接口 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
@FeignClient(name = ServiceConstant.EPMET_ADMIN_SERVER, fallback = AdminFeignClientFallback.class) |
|||
public interface AdminFeignClient { |
|||
|
|||
/** |
|||
* 根据用户ID,获取用户信息 |
|||
*/ |
|||
@GetMapping("sys/user/getById") |
|||
Result<UserDetail> getById(@RequestParam("id") Long id); |
|||
|
|||
/** |
|||
* 根据用户名,获取用户信息 |
|||
* @param username 用户名 |
|||
*/ |
|||
@GetMapping("sys/user/getByUsername") |
|||
Result<UserDetail> getByUsername(@RequestParam("username") String username); |
|||
|
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.epmet.feign; |
|||
|
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.feign.fallback.EpmetUserFeignClientFallback; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author yinzuomei |
|||
* @Date 2020/3/16 14:48 |
|||
*/ |
|||
@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserFeignClientFallback.class) |
|||
public interface EpmetUserFeignClient { |
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.epmet.feign; |
|||
|
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.CustomerGridDTO; |
|||
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; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author yinzuomei |
|||
* @Date 2020/3/18 11:11 |
|||
*/ |
|||
@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallBack.class) |
|||
public interface GovOrgFeignClient { |
|||
@GetMapping("gov/org/customergrid/getcustomergrid/{id}") |
|||
Result<CustomerGridDTO> getcustomergrid(@PathVariable("id") String id); |
|||
} |
@ -0,0 +1,34 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.epmet.feign.fallback; |
|||
|
|||
import com.epmet.commons.tools.security.user.UserDetail; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.feign.AdminFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 用户接口 Fallback |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
@Component |
|||
public class AdminFeignClientFallback implements AdminFeignClient { |
|||
|
|||
@Override |
|||
public Result<UserDetail> getById(Long id) { |
|||
return new Result<>(); |
|||
} |
|||
|
|||
@Override |
|||
public Result<UserDetail> getByUsername(String username) { |
|||
return new Result<>(); |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
package com.epmet.feign.fallback; |
|||
|
|||
import com.epmet.feign.EpmetUserFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author yinzuomei |
|||
* @Date 2020/3/16 14:53 |
|||
*/ |
|||
@Component |
|||
public class EpmetUserFeignClientFallback implements EpmetUserFeignClient { |
|||
|
|||
|
|||
} |
@ -0,0 +1,21 @@ |
|||
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.CustomerGridDTO; |
|||
import com.epmet.feign.GovOrgFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author yinzuomei |
|||
* @Date 2020/3/18 11:13 |
|||
*/ |
|||
@Component |
|||
public class GovOrgFeignClientFallBack implements GovOrgFeignClient { |
|||
@Override |
|||
public Result<CustomerGridDTO> getcustomergrid(String id) { |
|||
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getcustomergrid",id); |
|||
} |
|||
} |
@ -1,4 +1,4 @@ |
|||
package com.epmet.feign.impl; |
|||
package com.epmet.feign.fallback; |
|||
|
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.utils.ModuleUtils; |
Loading…
Reference in new issue