feat: 实时数据更真实一点
This commit is contained in:
@@ -22,10 +22,13 @@ public class RandomNumberUtil {
|
||||
}
|
||||
|
||||
public static int getRandomInt() {
|
||||
// 生成一个在0到100之间,小数点后有2位的随机浮点数
|
||||
return faker.number().randomDigit();
|
||||
}
|
||||
|
||||
public static int getRandomIntBetween(int min, int max) {
|
||||
return faker.number().numberBetween(min, max);
|
||||
}
|
||||
|
||||
// 生成指定大小和类型的列表,填充伪随机数据
|
||||
public static <T> List<T> generateFakeDataList(int size, Class<T> type) {
|
||||
List<T> resultList = new ArrayList<>();
|
||||
@@ -33,7 +36,7 @@ public class RandomNumberUtil {
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (type.equals(Double.class)) {
|
||||
// 对于 Double 类型,生成伪随机双精度值
|
||||
resultList.add(type.cast(faker.number().randomDouble(2, 1, 100)));
|
||||
resultList.add(type.cast(faker.number().randomDouble(2, 50, 100)));
|
||||
} else if (type.equals(Integer.class)) {
|
||||
// 对于 Integer 类型,生成伪随机整数值
|
||||
resultList.add(type.cast(faker.number().numberBetween(1, 100)));
|
||||
|
||||
Reference in New Issue
Block a user