SmsController.java 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package com.yihu.base.security.sms.controller;
  2. import com.yihu.base.security.properties.SecurityProperties;
  3. import com.yihu.base.security.sms.process.SmsValidateCodeProcessor;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.web.bind.annotation.GetMapping;
  6. import org.springframework.web.bind.annotation.PathVariable;
  7. import org.springframework.web.bind.annotation.RestController;
  8. import org.springframework.web.context.request.ServletWebRequest;
  9. import javax.servlet.http.HttpServletRequest;
  10. import javax.servlet.http.HttpServletResponse;
  11. /**
  12. * Created by chenweida on 2017/12/5.
  13. */
  14. @RestController
  15. public class SmsController {
  16. @Autowired
  17. private SmsValidateCodeProcessor smsValidateCodeProcessor;
  18. /**
  19. * 创建验证码
  20. *
  21. * @param request
  22. * @param response
  23. * @throws Exception
  24. */
  25. @GetMapping(SecurityProperties.mobileSendSms)
  26. public void createCode(
  27. HttpServletRequest request,
  28. HttpServletResponse response)
  29. throws Exception {
  30. //获取手机号
  31. String mobile = request.getParameter(SecurityProperties.mobileLoginAccountKey);
  32. //发送短信验证码并且保存到redis中
  33. smsValidateCodeProcessor.create(new ServletWebRequest(request, response));
  34. }
  35. }