forked from luyan/epmet-cloud-lingshan
Browse Source
# Conflicts: # epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.javamaster
15 changed files with 171 additions and 59 deletions
@ -0,0 +1,24 @@ |
|||||
|
package com.epmet.modules.feign; |
||||
|
|
||||
|
import com.epmet.commons.tools.constant.ServiceConstant; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.modules.feign.fallback.EpmetMessageFeignClientFallback; |
||||
|
import org.springframework.cloud.openfeign.FeignClient; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PathVariable; |
||||
|
|
||||
|
/** |
||||
|
* @author kamui |
||||
|
*/ |
||||
|
@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallback = EpmetMessageFeignClientFallback.class) |
||||
|
public interface EpmetMessageFeignClient { |
||||
|
|
||||
|
/** |
||||
|
* 发送短信验证码 |
||||
|
* @param mobile 手机号 |
||||
|
* @return Result |
||||
|
*/ |
||||
|
@GetMapping(value = "message/sms/captcha/{mobile}") |
||||
|
Result sendSmsCaptcha(@PathVariable String mobile); |
||||
|
|
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
package com.epmet.modules.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.modules.feign.EpmetMessageFeignClient; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 消息服务降级 |
||||
|
* @author zhaoqifeng |
||||
|
*/ |
||||
|
@Component |
||||
|
public class EpmetMessageFeignClientFallback implements EpmetMessageFeignClient { |
||||
|
|
||||
|
@Override |
||||
|
public Result sendSmsCaptcha(String mobile) { |
||||
|
return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "sendSmsCaptcha", mobile); |
||||
|
} |
||||
|
|
||||
|
} |
@ -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.feign.fallback.MessageFeignClientFallback; |
||||
|
import org.springframework.cloud.openfeign.FeignClient; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
|
||||
|
@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallback = MessageFeignClientFallback.class) |
||||
|
public interface MessageFeignClient { |
||||
|
|
||||
|
/** |
||||
|
* 发送短信验证码 |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping(value = "message/sms/captcha/{mobile}") |
||||
|
Result sendSmsCaptcha(@RequestParam("mobile") String mobile); |
||||
|
|
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
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.feign.MessageFeignClient; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 消息服务降级 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class MessageFeignClientFallback implements MessageFeignClient { |
||||
|
|
||||
|
@Override |
||||
|
public Result sendSmsCaptcha(String mobile) { |
||||
|
return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "sendSmsCaptcha", mobile); |
||||
|
} |
||||
|
|
||||
|
} |
Loading…
Reference in new issue