ValidateCode.java 1009 B

123456789101112131415161718192021222324252627282930
  1. package com.futu.goose.user.controller;
  2. import com.futu.goose.user.service.ValidateCodeService;
  3. import com.futu.goose.utils.RedisClient;
  4. import com.futu.goose.utils.Result;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.web.bind.annotation.RequestMapping;
  7. import org.springframework.web.bind.annotation.RequestParam;
  8. import org.springframework.web.bind.annotation.RestController;
  9. @RestController
  10. @RequestMapping("/validateCode")
  11. public class ValidateCode {
  12. @Autowired
  13. private ValidateCodeService validateCodeService;
  14. @Autowired
  15. private RedisClient redisClient;
  16. @RequestMapping("/send4Order")
  17. public Result send4Order(@RequestParam("telephone") String telephone) {
  18. Integer code = validateCodeService.send4Order(telephone);
  19. redisClient.set("CODE", code);
  20. redisClient.expire("CODE", 60);
  21. System.out.println("您的验证码为:------"+code);
  22. return new Result(true,"验证码发送成功");
  23. }
  24. }