hubin 7 лет назад
Родитель
Сommit
2e5135e9bc

+ 2 - 3
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/AbstractWrapper.java

@@ -54,8 +54,8 @@ import com.baomidou.mybatisplus.core.conditions.interfaces.Nested;
 import com.baomidou.mybatisplus.core.enums.SqlKeyword;
 import com.baomidou.mybatisplus.core.enums.SqlKeyword;
 import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
 import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.core.toolkit.ISqlSegmentList;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.core.toolkit.sql.SqlSegmentList;
 
 
 
 
 /**
 /**
@@ -66,7 +66,6 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
  * @author hubin miemie HCL
  * @author hubin miemie HCL
  * @since 2017-05-26
  * @since 2017-05-26
  */
  */
-@SuppressWarnings("unchecked,serial")
 public abstract class AbstractWrapper<T, R, This extends AbstractWrapper<T, R, This>> extends Wrapper<T>
 public abstract class AbstractWrapper<T, R, This extends AbstractWrapper<T, R, This>> extends Wrapper<T>
     implements Compare<This, R>, Nested<This>, Join<This>, Func<This, R>, Serializable {
     implements Compare<This, R>, Nested<This>, Join<This>, Func<This, R>, Serializable {
 
 
@@ -91,7 +90,7 @@ public abstract class AbstractWrapper<T, R, This extends AbstractWrapper<T, R, T
      * 数据库表映射实体类
      * 数据库表映射实体类
      */
      */
     protected T entity;
     protected T entity;
-    private ISqlSegmentList expression = new ISqlSegmentList();
+    private SqlSegmentList expression = new SqlSegmentList();
 
 
     @Override
     @Override
     public T getEntity() {
     public T getEntity() {

+ 0 - 30
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/iSqlSegments/GroupByISqlSegment.java

@@ -1,30 +0,0 @@
-package com.baomidou.mybatisplus.core.toolkit.iSqlSegments;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import com.baomidou.mybatisplus.core.conditions.ISqlSegment;
-
-/**
- * @author miemie
- * @since 2018-06-27
- */
-public class GroupByISqlSegment extends ArrayList<ISqlSegment> implements ISqlSegment {
-
-    private static final long serialVersionUID = -4135938724727477310L;
-
-    @Override
-    public boolean addAll(Collection<? extends ISqlSegment> c) {
-        List<ISqlSegment> list = new ArrayList<>(c);
-        if (!isEmpty()) {
-            list.remove(0);
-        }
-        return super.addAll(list);
-    }
-
-    @Override
-    public String getSqlSegment() {
-        return null;
-    }
-}

+ 0 - 20
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/iSqlSegments/NormalISqlSegment.java

@@ -1,20 +0,0 @@
-package com.baomidou.mybatisplus.core.toolkit.iSqlSegments;
-
-import java.util.ArrayList;
-import java.util.stream.Collectors;
-
-import com.baomidou.mybatisplus.core.conditions.ISqlSegment;
-
-/**
- * @author miemie
- * @since 2018-06-27
- */
-public class NormalISqlSegment extends ArrayList<ISqlSegment> implements ISqlSegment {
-
-    private static final long serialVersionUID = -1991374407733611565L;
-
-    @Override
-    public String getSqlSegment() {
-        return this.stream().map(ISqlSegment::getSqlSegment).collect(Collectors.joining("and"));
-    }
-}

+ 0 - 20
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/iSqlSegments/OrderByISqlSegment.java

@@ -1,20 +0,0 @@
-package com.baomidou.mybatisplus.core.toolkit.iSqlSegments;
-
-import java.util.ArrayList;
-import java.util.stream.Collectors;
-
-import com.baomidou.mybatisplus.core.conditions.ISqlSegment;
-
-/**
- * @author miemie
- * @since 2018-06-27
- */
-public class OrderByISqlSegment extends ArrayList<ISqlSegment> implements ISqlSegment {
-
-    private static final long serialVersionUID = -294655105160779712L;
-
-    @Override
-    public String getSqlSegment() {
-        return this.stream().map(ISqlSegment::getSqlSegment).collect(Collectors.joining(","));
-    }
-}

+ 13 - 7
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/ISqlSegmentList.java → mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/sql/SqlSegmentList.java

@@ -13,7 +13,7 @@
  * License for the specific language governing permissions and limitations under
  * License for the specific language governing permissions and limitations under
  * the License.
  * the License.
  */
  */
-package com.baomidou.mybatisplus.core.toolkit;
+package com.baomidou.mybatisplus.core.toolkit.sql;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collection;
@@ -31,20 +31,26 @@ import com.baomidou.mybatisplus.core.enums.SqlKeyword;
  * @author miemie
  * @author miemie
  * @since 2018-06-26
  * @since 2018-06-26
  */
  */
-public class ISqlSegmentList extends ArrayList<ISqlSegment> {
+public class SqlSegmentList extends ArrayList<ISqlSegment> {
 
 
     private static final long serialVersionUID = 8205969915086959490L;
     private static final long serialVersionUID = 8205969915086959490L;
-    //开启优化 and
+    /**
+     * 开启优化 and
+     */
     private boolean automaticAnd = true;
     private boolean automaticAnd = true;
-    //最后一个值
+    /**
+     * 最后一个值
+     */
     private ISqlSegment lastValue = null;
     private ISqlSegment lastValue = null;
-    //是否启动过 order by
+    /**
+     * 是否启动过 order by
+     */
     private boolean didOrderBy = false;
     private boolean didOrderBy = false;
 
 
-    public ISqlSegmentList() {
+    public SqlSegmentList() {
     }
     }
 
 
-    public ISqlSegmentList(boolean automaticAnd) {
+    public SqlSegmentList(boolean automaticAnd) {
         this.automaticAnd = automaticAnd;
         this.automaticAnd = automaticAnd;
     }
     }
 
 

+ 45 - 0
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/sql/segments/GroupBySegment.java

@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011-2020, hubin (jobob@qq.com).
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.baomidou.mybatisplus.core.toolkit.sql.segments;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import com.baomidou.mybatisplus.core.conditions.ISqlSegment;
+
+/**
+ * @author miemie
+ * @since 2018-06-27
+ */
+public class GroupBySegment extends ArrayList<ISqlSegment> implements ISqlSegment {
+
+    private static final long serialVersionUID = -4135938724727477310L;
+
+    @Override
+    public boolean addAll(Collection<? extends ISqlSegment> c) {
+        List<ISqlSegment> list = new ArrayList<>(c);
+        if (!isEmpty()) {
+            list.remove(0);
+        }
+        return super.addAll(list);
+    }
+
+    @Override
+    public String getSqlSegment() {
+        return null;
+    }
+}

+ 24 - 9
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/iSqlSegments/JoinISqlSegment.java → mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/sql/segments/JoinSegment.java

@@ -1,4 +1,19 @@
-package com.baomidou.mybatisplus.core.toolkit.iSqlSegments;
+/*
+ * Copyright (c) 2011-2020, hubin (jobob@qq.com).
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.baomidou.mybatisplus.core.toolkit.sql.segments;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.List;
 import java.util.List;
@@ -11,23 +26,23 @@ import com.baomidou.mybatisplus.core.enums.SqlKeyword;
  * @author miemie
  * @author miemie
  * @since 2018-06-27
  * @since 2018-06-27
  */
  */
-public class JoinISqlSegment implements ISqlSegment {
+public class JoinSegment implements ISqlSegment {
 
 
     private static final long serialVersionUID = 8401728865419013555L;
     private static final long serialVersionUID = 8401728865419013555L;
 
 
-    private NormalISqlSegment normalISqlSegment = new NormalISqlSegment();
-    private GroupByISqlSegment groupByISqlSegment = new GroupByISqlSegment();
-    private OrderByISqlSegment orderByISqlSegment = new OrderByISqlSegment();
+    private NormalSegment normalSegment = new NormalSegment();
+    private GroupBySegment groupBySegment = new GroupBySegment();
+    private OrderBySegment orderBySegment = new OrderBySegment();
 
 
     public void add(ISqlSegment... iSqlSegments) {
     public void add(ISqlSegment... iSqlSegments) {
         List<ISqlSegment> list = Arrays.asList(iSqlSegments);
         List<ISqlSegment> list = Arrays.asList(iSqlSegments);
         ISqlSegment sqlSegment = list.get(0);
         ISqlSegment sqlSegment = list.get(0);
         if (match(PredicateStrategy.ORDER_BY, sqlSegment)) {
         if (match(PredicateStrategy.ORDER_BY, sqlSegment)) {
-            orderByISqlSegment.addAll(list);
+            orderBySegment.addAll(list);
         } else if (match(PredicateStrategy.GROUP_BY, sqlSegment)) {
         } else if (match(PredicateStrategy.GROUP_BY, sqlSegment)) {
-            groupByISqlSegment.addAll(list);
+            groupBySegment.addAll(list);
         } else {
         } else {
-            normalISqlSegment.addAll(list);
+            normalSegment.addAll(list);
         }
         }
     }
     }
 
 
@@ -37,7 +52,7 @@ public class JoinISqlSegment implements ISqlSegment {
 
 
     @Override
     @Override
     public String getSqlSegment() {
     public String getSqlSegment() {
-        return normalISqlSegment.getSqlSegment() + groupByISqlSegment.getSqlSegment() + orderByISqlSegment.getSqlSegment();
+        return normalSegment.getSqlSegment() + groupBySegment.getSqlSegment() + orderBySegment.getSqlSegment();
     }
     }
 
 
     /**
     /**

+ 35 - 0
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/sql/segments/NormalSegment.java

@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2011-2020, hubin (jobob@qq.com).
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.baomidou.mybatisplus.core.toolkit.sql.segments;
+
+import java.util.ArrayList;
+import java.util.stream.Collectors;
+
+import com.baomidou.mybatisplus.core.conditions.ISqlSegment;
+
+/**
+ * @author miemie
+ * @since 2018-06-27
+ */
+public class NormalSegment extends ArrayList<ISqlSegment> implements ISqlSegment {
+
+    private static final long serialVersionUID = -1991374407733611565L;
+
+    @Override
+    public String getSqlSegment() {
+        return this.stream().map(ISqlSegment::getSqlSegment).collect(Collectors.joining("and"));
+    }
+}

+ 35 - 0
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/sql/segments/OrderBySegment.java

@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2011-2020, hubin (jobob@qq.com).
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.baomidou.mybatisplus.core.toolkit.sql.segments;
+
+import java.util.ArrayList;
+import java.util.stream.Collectors;
+
+import com.baomidou.mybatisplus.core.conditions.ISqlSegment;
+
+/**
+ * @author miemie
+ * @since 2018-06-27
+ */
+public class OrderBySegment extends ArrayList<ISqlSegment> implements ISqlSegment {
+
+    private static final long serialVersionUID = -294655105160779712L;
+
+    @Override
+    public String getSqlSegment() {
+        return this.stream().map(ISqlSegment::getSqlSegment).collect(Collectors.joining(","));
+    }
+}