260612_01_ENH: length로 uuid 생성하는 유틸 추가
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.kri.common.feature.util;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class CommonUtil {
|
||||
@@ -10,4 +11,15 @@ public final class CommonUtil {
|
||||
public static String uuid32() {
|
||||
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