xiaochan 7 месяцев назад
Родитель
Сommit
8a22e51e8e

+ 3 - 3
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/YiZhuPublicService.java

@@ -25,13 +25,13 @@ public class YiZhuPublicService {
         this.publicServer = publicServer;
     }
 
-    public ResultVo<List<CodeName>> getAllWards() {
+    public ResultVo<List<CodeName>> getAllWards()
+
+    {
         if (publicServer.needRule(2, 8, 52)) {
             return ResultVoUtil.success(dao.getAllWards());
         } else {
             return ResultVoUtil.success(dao.getDoctorWards(TokenUtil.getInstance().getTokenUserId()));
         }
     }
-
-
 }

+ 52 - 0
src/main/java/thyyxxk/webserver/utils/TryUtil.java

@@ -0,0 +1,52 @@
+package thyyxxk.webserver.utils;
+
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.function.Supplier;
+
+@Slf4j
+public class TryUtil {
+
+    @FunctionalInterface
+    public interface TryRunnable {
+        void apply();
+    }
+
+    public TryUtil() {
+
+    }
+
+    private final List<Supplier<Object>> predicates = new LinkedList<>();
+
+    public static TryUtil create() {
+        return new TryUtil();
+    }
+
+    public TryUtil fun(Supplier<Object> predicate) {
+        this.predicates.add(predicate);
+        return this;
+    }
+
+    public Object execute() {
+        for (Supplier<Object> predicate : predicates) {
+            try {
+                return predicate.get();
+            } catch (Exception ignore) {
+
+            }
+        }
+        return null;
+    }
+
+    public static void ignoreErr(TryRunnable runnable) {
+        try {
+            runnable.apply();
+        } catch (Exception ignore) {
+        }
+    }
+
+
+}