lihong 2 years ago
parent
commit
32a19aed6c

+ 36 - 0
src/main/java/cn/hnthyy/thmz/Utils/AssertUtil.java

@@ -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;
+    }
 }

+ 1 - 1
src/main/java/cn/hnthyy/thmz/controller/bb/ReportStaticController.java

@@ -38,7 +38,7 @@ public class ReportStaticController {
     @UserLoginToken
     @RequestMapping(value = "/selectDoctorIndexData", method = {RequestMethod.GET, RequestMethod.POST})
     public R selectDoctorIndexData(@RequestBody ReportVo vo, HttpServletRequest httpServletRequest){
-            AssertUtil.isNotBlank(vo.getReportId(),"报表id为空,查询报表数据失败");
+            AssertUtil.anyIsNotBlank("报表id为空,查询报表数据失败",vo.getReportId(),vo.getReportIds());
             User user = TokenUtil.getNewUser(httpServletRequest);
             vo.setDoctorId(user.getUserIdCode());
             Map<String, Object> map = reportStaticService.selectDoctorIndexData(vo);