Przeglądaj źródła

修改业务Business 对象排序错误的问题

wuxw 7 lat temu
rodzic
commit
0d5344423c

+ 2 - 2
Api/src/main/java/com/java110/api/listener/store/SaveStoreServiceListener.java

@@ -125,7 +125,7 @@ public class SaveStoreServiceListener extends AbstractServiceApiDataFlowListener
     private JSONObject addStore(JSONObject paramInJson){
         JSONObject business = JSONObject.parseObject("{}");
         business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_STORE_INFO);
-        business.put(CommonConstant.HTTP_SEQ,2);
+        business.put(CommonConstant.HTTP_SEQ,1);
         business.put(CommonConstant.HTTP_INVOKE_MODEL,CommonConstant.HTTP_INVOKE_MODEL_S);
 
         business.put(CommonConstant.HTTP_BUSINESS_DATAS,refreshParamIn(paramInJson));
@@ -143,7 +143,7 @@ public class SaveStoreServiceListener extends AbstractServiceApiDataFlowListener
 
         JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
         business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_STORE_USER);
-        business.put(CommonConstant.HTTP_SEQ,1);
+        business.put(CommonConstant.HTTP_SEQ,2);
         business.put(CommonConstant.HTTP_INVOKE_MODEL,CommonConstant.HTTP_INVOKE_MODEL_S);
         JSONArray businessStoreUsers = new JSONArray();
         JSONObject businessStoreUser = new JSONObject();

+ 1 - 1
java110-bean/src/main/java/com/java110/entity/order/Business.java

@@ -78,7 +78,7 @@ public class Business extends BusinessPlus implements Comparable{
     @Override
     public int compareTo(Object o) {
         Business otherBusiness = (Business)o;
-        if(this.getSeq() > otherBusiness.getSeq()) {
+        if(this.getSeq() < otherBusiness.getSeq()) {
             return -1;
         }
         return 0;

+ 41 - 0
java110-bean/src/test/java/com/java110/entity/order/BusinessTest.java

@@ -0,0 +1,41 @@
+package com.java110.entity.order;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Created by Administrator on 2019/3/30.
+ */
+public class BusinessTest extends TestCase {
+
+    public void testCompareTo() throws Exception {
+        Business business1 = new Business();
+        business1.setSeq(1);
+
+        Business business2 = new Business();
+        business2.setSeq(2);
+
+        Business business3 = new Business();
+        business3.setSeq(3);
+
+        List<Business> businesses = new ArrayList<Business>();
+        businesses.add(business1);
+        businesses.add(business3);
+        businesses.add(business2);
+        System.out.println("--------------------排序前");
+        for(Business business :businesses){
+            System.out.println(business.getSeq());
+        }
+
+        System.out.println("--------------------排序后");
+
+        Collections.sort(businesses);
+        for(Business business :businesses){
+            System.out.println(business.getSeq());
+        }
+    }
+
+}