| | |
| | | |
| | | import cn.hutool.core.util.IdUtil; |
| | | import com.oying.annotation.rest.AnonymousGetMapping; |
| | | import com.oying.utils.R; |
| | | import com.oying.utils.RedisUtils; |
| | | import com.oying.utils.SendMessageUtils; |
| | | import com.oying.utils.WinnerLookProperties; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | |
| | | private String key; |
| | | @Value("${sms.time}") |
| | | private Long time; |
| | | private final WinnerLookProperties properties; |
| | | |
| | | @AnonymousGetMapping("/{phone}") |
| | | @AnonymousGetMapping |
| | | @ApiOperation("短信验证码") |
| | | public ResponseEntity<Object> toPayAsPc(@PathVariable String phone) { |
| | | public ResponseEntity<Object> verification(@RequestParam String phone) { |
| | | String uuid = key + IdUtil.simpleUUID(); |
| | | System.out.println(phone); |
| | | //创建验证码 |
| | | String verification = (int) ((Math.random() * 9 + 1) * 100000) + ""; |
| | | SendMessageUtils.sendMsg(properties.getUrlSendMsg(), phone, SendMessageUtils.SIGN, |
| | | SendMessageUtils.MESSAGE.replace("{code}", verification), properties); |
| | | redisUtils.set(uuid, verification, time); |
| | | return ResponseEntity.ok(uuid); |
| | | return ResponseEntity.ok(R.success(uuid)); |
| | | } |
| | | } |