|
@@ -4,6 +4,7 @@ import cn.hnthyy.thmz.common.exception.BizException;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -38,4 +39,39 @@ public class AssertUtil {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * @description:至少有一个不能为空
|
|
|
+ * @author: lihong
|
|
|
+ * @date: 2023/8/15 16:07
|
|
|
+ * @param: message
|
|
|
+ * @param: o
|
|
|
+ **/
|
|
|
+ public static void anyIsNotBlank(String message,Object... o){
|
|
|
+ if(o == null){
|
|
|
+ throw new BizException(message,R.ERR_CODE);
|
|
|
+ }
|
|
|
+ if(Arrays.stream(o).allMatch(o1 -> !isNotBlank(o1))){
|
|
|
+ throw new BizException(message,R.ERR_CODE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private static boolean isNotBlank(Object object){
|
|
|
+ if (object == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else if (object instanceof Collection) {
|
|
|
+ if(CollUtil.isEmpty((Collection)object)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (object instanceof Map) {
|
|
|
+ if(CollUtil.isEmpty((Map)object)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (StrUtil.isBlank(object.toString())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|