260612_01_ENH: length로 uuid 생성하는 유틸 추가
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 버전 변경은 여기서
|
// 버전 변경은 여기서
|
||||||
def commonVer = "beta.1.1.24"
|
def commonVer = "beta.1.1.25"
|
||||||
|
|
||||||
group = 'com.kri.common'
|
group = 'com.kri.common'
|
||||||
version = commonVer
|
version = commonVer
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.kri.common.feature.util;
|
package com.kri.common.feature.util;
|
||||||
|
|
||||||
|
import com.kri.common.feature.web.BusinessException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public final class CommonUtil {
|
public final class CommonUtil {
|
||||||
@@ -10,4 +11,15 @@ public final class CommonUtil {
|
|||||||
public static String uuid32() {
|
public static String uuid32() {
|
||||||
return UUID.randomUUID().toString().replace("-", "");
|
return UUID.randomUUID().toString().replace("-", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String uuid(int length) {
|
||||||
|
if (length <= 0) {
|
||||||
|
throw BusinessException.badRequest("length must be greater than 0");
|
||||||
|
}
|
||||||
|
if (length > 32) {
|
||||||
|
throw BusinessException.badRequest("length must be less than 32");
|
||||||
|
}
|
||||||
|
|
||||||
|
return UUID.randomUUID().toString().substring(0, length).replace("-", "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user