From c68bf3dd4b6b2e839c2a68935199d2f461c6508a Mon Sep 17 00:00:00 2001 From: taojinlong Date: Tue, 21 Mar 2023 16:52:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=B2=BE=E7=AE=80=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=B8=8B=EF=BC=8C=E4=B8=8A=E4=BC=A0=20Excel=20=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=96=87=E4=BB=B6=E6=97=B6=EF=BC=8C=E7=A9=BA=E5=80=BC?= =?UTF-8?q?=E4=BC=9A=E8=A2=AB=E7=BD=AE=E4=B8=BA0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/mysql/MysqlDDLProvider.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlDDLProvider.java b/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlDDLProvider.java index 259169b614..cd9ff9f1b8 100644 --- a/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlDDLProvider.java +++ b/backend/src/main/java/io/dataease/provider/engine/mysql/MysqlDDLProvider.java @@ -4,9 +4,12 @@ import io.dataease.plugins.common.base.domain.DatasetTableField; import io.dataease.plugins.common.base.domain.Datasource; import io.dataease.commons.utils.TableUtils; import io.dataease.provider.DDLProviderImpl; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import java.util.Arrays; import java.util.List; +import java.util.UUID; /** * @Author gin @@ -25,6 +28,30 @@ public class MysqlDDLProvider extends DDLProviderImpl { return "CREATE or replace view " + name + " AS (" + viewSQL + ")"; } + @Override + public String insertSql(String name, List dataList, int page, int pageNumber) { + String insertSql = "INSERT INTO TABLE_NAME VALUES ".replace("TABLE_NAME", name); + StringBuffer values = new StringBuffer(); + + Integer realSize = page * pageNumber < dataList.size() ? page * pageNumber : dataList.size(); + for (String[] strings : dataList.subList((page - 1) * pageNumber, realSize)) { + String[] strings1 = new String[strings.length]; + for (int i = 0; i < strings.length; i++) { + if (StringUtils.isEmpty(strings[i])) { + strings1[i] = null; + } else { + strings1[i] = strings[i].replace("'", "\\'"); + } + } + values.append("('").append(UUID.randomUUID()) + .append("','").append(String.join("','", Arrays.asList(strings1))) + .append("'),"); + } + return (insertSql + values.substring(0, values.length() - 1)).replaceAll(",'null'", ",null"); + } + + + @Override public String dropTable(String name) { return "DROP TABLE IF EXISTS " + name; @@ -67,7 +94,7 @@ public class MysqlDDLProvider extends DDLProviderImpl { } break; case 2: - Column_Fields.append("varchar(100)").append(",`"); + Column_Fields.append("bigint(20)").append(",`"); break; case 3: Column_Fields.append("varchar(100)").append(",`");