Browse Source

改为 StringBuilder

hubin 7 years ago
parent
commit
fa8e53ca73

+ 9 - 9
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/AbstractMethod.java

@@ -315,15 +315,15 @@ public abstract class AbstractMethod {
      * </p>
      */
     protected String sqlWhereByMap(TableInfo table) {
-        return "<if test=\"cm!=null and !cm.isEmpty\">" +
-            "<where>" +
-            "<foreach collection=\"cm\" index=\"k\" item=\"v\" separator=\"AND\">" +
-            "<if test=\"v != null\">" +
-            "${k} = #{v}" +
-            "</if>" +
-            "</foreach>" +
-            "</where>" +
-            "</if>";
+        StringBuilder where = new StringBuilder();
+        where.append("<if test=\"cm!=null and !cm.isEmpty\">");
+        where.append("<where>");
+        where.append("<foreach collection=\"cm\" index=\"k\" item=\"v\" separator=\"AND\">");
+        where.append("<if test=\"v != null\">${k}=#{v}</if>");
+        where.append("</foreach>");
+        where.append("</where>");
+        where.append("</if>");
+        return where.toString();
     }
 
     /**