mirror of
https://gitee.com/jzsw-it/yexuejc-base.git
synced 2025-06-06 22:04:04 +08:00
1.1.3
修改正则RegexUtils.java 修改正则StrUtil.java->扩展genUUID()
This commit is contained in:
parent
ccf87e5a57
commit
b284ec4a84
@ -1,6 +1,14 @@
|
||||
yexuejc-base 更新记录
|
||||
------------------
|
||||
|
||||
#### version :1.1.3
|
||||
**time:** <br/>
|
||||
**branch:** master <br/>
|
||||
**update:** <br/>
|
||||
>1.修改正则RegexUtils.java
|
||||
>1.修改正则StrUtil.java->扩展genUUID()
|
||||
|
||||
#
|
||||
#### version :1.1.2
|
||||
**time:** 2018-5-16 15:03:28<br/>
|
||||
**branch:** master <br/>
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.yexuejc.base</groupId>
|
||||
<artifactId>yexuejc-base</artifactId>
|
||||
<version>1.1.2</version>
|
||||
<version>1.1.3</version>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
|
||||
|
@ -18,6 +18,9 @@ public class ApiVO implements Serializable {
|
||||
public ApiVO() {
|
||||
}
|
||||
|
||||
public ApiVO(STATUS status) {
|
||||
this.status = status;
|
||||
}
|
||||
public ApiVO(STATUS status, String code, String msg) {
|
||||
this.status = status;
|
||||
this.code = code;
|
||||
|
@ -2,6 +2,7 @@ package com.yexuejc.base.util;
|
||||
|
||||
/**
|
||||
* excel 格式验证工具
|
||||
*
|
||||
* @ClassName: ExcelImportUtils
|
||||
* @Description:
|
||||
* @author: maxf
|
||||
|
@ -32,6 +32,56 @@ public class RegexUtils {
|
||||
* cvn2:3位数字
|
||||
*/
|
||||
public static final String REGEX_NUM3 = "^$|^\\d{3}$";
|
||||
/**
|
||||
* ID用 正则表达式(32位 16进制小写编码)
|
||||
*/
|
||||
public static final String REGEX_ID = "^$|^[a-f0-9]{32}$";
|
||||
/**
|
||||
* 手机用 正则表达式(首位为1,共11位数字)
|
||||
*/
|
||||
public static final String REGEX_MOBILE = "^$|^1\\d{10}$";
|
||||
/**
|
||||
* 验证是否是Json数据 正则表达式(首尾是{})
|
||||
*/
|
||||
public static final String REGEX_JSON = "^$|^\\{.*\\}$";
|
||||
/**
|
||||
* 验证预约日期时间 正则表达式(精确到半小时)
|
||||
*/
|
||||
public static final String REGEX_DATE_APPOINTMENT = "^$|^\\d{4}-[01]\\d-[0-3]\\d [0-2]\\d:(0|3)0$";
|
||||
/**
|
||||
* 日期 正则表达式
|
||||
*/
|
||||
public static final String REGEX_DATE = "^$|^\\d{4}-[01]\\d-[0-3]\\d$";
|
||||
|
||||
/**
|
||||
* 6位数字
|
||||
*/
|
||||
public static final String REGEX_NUM6 = "^$|^\\d{6}$";
|
||||
/**
|
||||
* 两位以内正整数
|
||||
*/
|
||||
public static final String REGEX_PINT2 = "^$|^[1-9]\\d{0,1}$";
|
||||
/**
|
||||
* 五位以内正整数
|
||||
*/
|
||||
public static final String REGEX_PINT5 = "^$|^[1-9]\\d{0,4}$";
|
||||
/**
|
||||
* 十位以内正整数
|
||||
*/
|
||||
public static final String REGEX_PINT10 = "^$|^[1-9]\\d{0,9}$";
|
||||
/**
|
||||
* 十位以内正整或0
|
||||
*/
|
||||
public static final String REGEX_INT10 = "^$|^[1-9]\\d{0,9}$|^0$";
|
||||
/**
|
||||
* 可有8位整数,2位小数
|
||||
*/
|
||||
public static final String REGEX_PFLOAT10_2 = "^$|^(\\d\\.\\d{1})|([1-9]\\d{0,7}(\\.\\d{1,2})?)$";
|
||||
|
||||
/**
|
||||
* STS RoleSessionName
|
||||
*/
|
||||
public static final String REGEX_STS_ROLE_SESSION_NAME = "^[a-zA-Z0-9\\.@\\-_]+$";
|
||||
|
||||
/**
|
||||
* 正则:入参验证
|
||||
|
@ -57,7 +57,7 @@ public final class StrUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成UUID
|
||||
* 生成32位UUID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ -65,6 +65,29 @@ public final class StrUtil {
|
||||
return UUID.randomUUID().toString().replaceAll("-", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成指定位数UUID
|
||||
*
|
||||
* @param length
|
||||
* @return
|
||||
*/
|
||||
public static String genUUID(int length) {
|
||||
if (length <= 32) {
|
||||
return genUUID().substring(0, length);
|
||||
} else if (length < 1) {
|
||||
return "";
|
||||
} else {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < length / 32; i++) {
|
||||
sb.append(genUUID());
|
||||
}
|
||||
if (length % 32 > 0) {
|
||||
sb.append(genUUID().substring(0, length % 32));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成11位编号,可以用作订单号,有很小几率出现重复,需要做异常处理<br/>
|
||||
* 左边第一位为正负标识:正数1 负数0<br/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user