Ver Fonte

更新!

TRX há 1 ano atrás
pai
commit
02577e2200

+ 30 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/util/CommonUtil.java

@@ -7,6 +7,7 @@ import com.google.zxing.BarcodeFormat;
 import com.google.zxing.client.j2se.MatrixToImageWriter;
 import com.google.zxing.common.BitMatrix;
 import com.google.zxing.qrcode.QRCodeWriter;
+import com.zhongshu.card.client.model.base.SuperModel;
 import com.zhongshu.card.client.model.operLogs.OperationLogsAddParam;
 import com.zhongshu.card.client.type.Sex;
 import com.zhongshu.card.client.type.school.CardType;
@@ -626,7 +627,6 @@ public class CommonUtil {
     /**
      * 计算环比,如:83.2 (最多保留2未小数)
      *
-     *
      * @param currentNumber 当期的值
      * @param preNumber     上期的值
      * @return
@@ -664,4 +664,33 @@ public class CommonUtil {
         return BigDecimal.ZERO;
     }
 
+    /**
+     * 返回一个 sort 升序排序的 Comparator
+     *
+     * @return
+     */
+    public static Comparator orderBySortAscSuperMain() {
+        return new Comparator<SuperMain>() {
+            @Override
+            public int compare(SuperMain o1, SuperMain o2) {
+                if (o1.getSort() == null || o2.getSort() == null) {
+                    return 0;
+                }
+                return (int) (o1.getSort() - o2.getSort());
+            }
+        };
+    }
+
+    public static Comparator orderBySortAscSuperModel() {
+        return new Comparator<SuperModel>() {
+            @Override
+            public int compare(SuperModel o1, SuperModel o2) {
+                if (o1.getSort() == null || o2.getSort() == null) {
+                    return 0;
+                }
+                return (int) (o1.getSort() - o2.getSort());
+            }
+        };
+    }
+
 }