浏览代码

优化代码

miemie 6 年之前
父节点
当前提交
0082382007
共有 1 个文件被更改,包括 8 次插入10 次删除
  1. 8 10
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/metadata/TableInfo.java

+ 8 - 10
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/metadata/TableInfo.java

@@ -198,13 +198,13 @@ public class TableInfo {
      *
      * @return sql 脚本片段
      */
-    public String getKeyInsertSqlProperty(final String prefix, final String delimiter) {
+    public String getKeyInsertSqlProperty(final String prefix) {
         final String newPrefix = prefix == null ? StringPool.EMPTY : prefix;
         if (StringUtils.isNotEmpty(keyProperty)) {
             if (idType == IdType.AUTO) {
                 return StringPool.EMPTY;
             }
-            return SqlScriptUtils.safeParam(newPrefix + keyProperty) + StringPool.COMMA + delimiter;
+            return SqlScriptUtils.safeParam(newPrefix + keyProperty) + StringPool.COMMA + StringPool.NEWLINE;
         }
         return StringPool.EMPTY;
     }
@@ -216,12 +216,12 @@ public class TableInfo {
      *
      * @return sql 脚本片段
      */
-    public String getKeyInsertSqlColumn(final String delimiter) {
+    public String getKeyInsertSqlColumn() {
         if (StringUtils.isNotEmpty(keyColumn)) {
             if (idType == IdType.AUTO) {
                 return StringPool.EMPTY;
             }
-            return keyColumn + StringPool.COMMA + delimiter;
+            return keyColumn + StringPool.COMMA + StringPool.NEWLINE;
         }
         return StringPool.EMPTY;
     }
@@ -236,9 +236,8 @@ public class TableInfo {
      */
     public String getAllInsertSqlProperty(boolean isAll, final String prefix) {
         final String newPrefix = prefix == null ? StringPool.EMPTY : prefix;
-        final String delimiter = isAll ? StringPool.EMPTY : StringPool.NEWLINE;
-        return getKeyInsertSqlProperty(newPrefix, delimiter) + fieldList.stream()
-            .map(i -> i.getInsertSqlProperty(isAll, newPrefix)).collect(joining(delimiter));
+        return getKeyInsertSqlProperty(newPrefix) + fieldList.stream()
+            .map(i -> i.getInsertSqlProperty(isAll, newPrefix)).collect(joining(StringPool.NEWLINE));
     }
 
     /**
@@ -249,9 +248,8 @@ public class TableInfo {
      * @return sql 脚本片段
      */
     public String getAllInsertSqlColumn(boolean isAll) {
-        final String delimiter = isAll ? StringPool.EMPTY : StringPool.NEWLINE;
-        return getKeyInsertSqlColumn(delimiter) + fieldList.stream().map(i -> i.getInsertSqlColumn(isAll))
-            .collect(joining(delimiter));
+        return getKeyInsertSqlColumn() + fieldList.stream().map(i -> i.getInsertSqlColumn(isAll))
+            .collect(joining(StringPool.NEWLINE));
     }
 
     /**