18 changed files with 162 additions and 63 deletions
@ -0,0 +1,34 @@ |
|||
package com.elink.esua.epdc.controller; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.service.MessageService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* @author yujintao |
|||
* @email yujintao@elink-cn.com |
|||
* @date 2019/9/11 20:56 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("message") |
|||
public class ApiMessageController { |
|||
|
|||
@Autowired |
|||
private MessageService messageService; |
|||
|
|||
/** |
|||
* 发送短信验证码 |
|||
* |
|||
* @param mobile |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @author yujintao |
|||
* @date 2019/9/11 21:03 |
|||
*/ |
|||
@GetMapping("sms/sendCode") |
|||
public Result sendSmsCode(String mobile) { |
|||
return messageService.sendSmsCode(mobile); |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
package com.elink.esua.epdc.feign; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.feign.fallback.MessageFeignClientFallback; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
|
|||
/** |
|||
* 文件对象模块 |
|||
* |
|||
* @Author LC |
|||
* @Date 2019/9/8 18:24 |
|||
*/ |
|||
@FeignClient(name = ServiceConstant.EPDC_MESSAGE_SERVER, fallback = MessageFeignClientFallback.class, url = "http://127.0.0.1:9062") |
|||
public interface MessageFeignClient { |
|||
|
|||
/** |
|||
* 发送短信验证码 |
|||
* |
|||
* @param mobile |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @author yujintao |
|||
* @date 2019/9/11 20:59 |
|||
*/ |
|||
@GetMapping(value = "message/sms/sendCode") |
|||
Result sendCode(String mobile); |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
package com.elink.esua.epdc.feign.fallback; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
|||
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.feign.MessageFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 文件对象模块 |
|||
* |
|||
* @Author LC |
|||
* @Date 2019/9/8 18:25 |
|||
*/ |
|||
@Component |
|||
public class MessageFeignClientFallback implements MessageFeignClient { |
|||
|
|||
@Override |
|||
public Result sendCode(String mobile) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPDC_MESSAGE_SERVER, "sendCode", mobile); |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
package com.elink.esua.epdc.service; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
|
|||
/** |
|||
* @author yujintao |
|||
* @email yujintao@elink-cn.com |
|||
* @date 2019/9/11 21:01 |
|||
*/ |
|||
public interface MessageService { |
|||
/** |
|||
* 发送短信验证码 |
|||
* |
|||
* @param mobile |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @author yujintao |
|||
* @date 2019/9/11 21:04 |
|||
*/ |
|||
Result sendSmsCode(String mobile); |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
package com.elink.esua.epdc.service.impl; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.feign.MessageFeignClient; |
|||
import com.elink.esua.epdc.service.MessageService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* @author yujintao |
|||
* @email yujintao@elink-cn.com |
|||
* @date 2019/9/11 21:03 |
|||
*/ |
|||
@Service |
|||
public class MessageServiceImpl implements MessageService { |
|||
|
|||
@Autowired |
|||
private MessageFeignClient messageFeignClient; |
|||
|
|||
/** |
|||
* 发送六位短信验证码 |
|||
* |
|||
* @param mobile |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
* @author yujintao |
|||
* @date 2019/9/12 09:21 |
|||
*/ |
|||
@Override |
|||
public Result sendSmsCode(String mobile) { |
|||
return messageFeignClient.sendCode(mobile); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue