parent
5445c9f346
commit
52d6e00b17
@ -0,0 +1,28 @@
|
||||
package com.mashibing.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author kezhen
|
||||
* @date 2023/7/12
|
||||
* @description
|
||||
*/
|
||||
@RestController
|
||||
public class NumberCodeController {
|
||||
|
||||
@GetMapping("/numberCode/{size}")
|
||||
public String numberCode(@PathVariable("size") int size) {
|
||||
System.out.println("size = " + size);
|
||||
|
||||
// 获取随机数生成验证码
|
||||
double mathRandom = (Math.random() * 9 + 1) * (Math.pow(10, size - 1));
|
||||
System.out.println("mathRandom = " + mathRandom);
|
||||
int resultInt = (int) mathRandom;
|
||||
System.out.println("resultInt = " + resultInt);
|
||||
|
||||
return Integer.toString(resultInt);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue