Browse Source

列表筛选条件优化,避免OR导致筛选范围出问题

rainco 7 years ago
parent
commit
af6d41c3eb

+ 5 - 5
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/dto/ListReqDTO.java

@@ -112,22 +112,22 @@ public class ListReqDTO implements Serializable {
                     }
                     if ("between".equals(operation)) {
                         String[] vals = value.toString().split(",");
-                        con = " " + field + " " + operation + " '" + vals[0] + "' and '" + vals[1] + "' and";
+                        con = " ( " + field + " " + operation + " '" + vals[0] + "' and '" + vals[1] + "' ) and";
                     } else if ("startsWith".equals(operation)) {
                         con = " " + field + "  like '" + value + "%' and";
                     } else if ("endsWith".equals(operation)) {
                         con = " " + field + " like '%" + value + "' and";
                     } else if ("in".equals(operation) || "not in".equals(operation)) {
-                        con = " " + field + " " + operation + " (" + value + ") and";
+                        con = " ( " + field + " " + operation + " (" + value + ") ) and";
                     } else {
                         //字符串默认是模糊查询
                         if ("string".equals(type)) {
-                            con = " " + field + " like '%" + value + "%' and";
+                            con = " (" + field + " like '%" + value + "%') and";
                         } else if ("condition".equals(type)) {
                             //type为condition为前端拼的条件
-                            con = " " + value + " and";
+                            con = " (" + value + ") and";
                         } else {
-                            con = " " + field + " " + operation + " '" + value + "' and";
+                            con = " (" + field + " " + operation + " '" + value + "') and";
                         }
 
                     }