forked from rongchao/epmet-cloud-rizhao
7 changed files with 111 additions and 6 deletions
@ -0,0 +1,24 @@ |
|||
package com.epmet.feign; |
|||
|
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.SysSmsDTO; |
|||
import com.epmet.feign.fallback.MessageFeignClientFallback; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
|
|||
@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallback = MessageFeignClientFallback.class, url = "http://localhost:8085") |
|||
public interface MessageFeignClient { |
|||
|
|||
/** |
|||
* 发送短信 |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "message/sms/send") |
|||
Result send(@RequestBody SysSmsDTO smsDTO); |
|||
|
|||
//@PostMapping(value = "message/sms/send", consumes = "application/x-www-form-urlencoded")
|
|||
//Result send(Map<String, String> entityBody);
|
|||
|
|||
} |
@ -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.SysSmsDTO; |
|||
import com.epmet.feign.MessageFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 消息服务降级 |
|||
*/ |
|||
@Component |
|||
public class MessageFeignClientFallback implements MessageFeignClient { |
|||
|
|||
|
|||
@Override |
|||
public Result send(SysSmsDTO smsDTO) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "send", smsDTO); |
|||
} |
|||
} |
Loading…
Reference in new issue