Ver código fonte

fix 数据迁移 导出脚本文件 处理数据中含有 ’ 导致sql执行失败

lvxianyun 2 anos atrás
pai
commit
9bd3776fb7

+ 1 - 1
adm-business/adm-middleware/src/main/java/com/persagy/proxy/migration/controller/DataMigrationController.java

@@ -160,7 +160,7 @@ public class DataMigrationController {
         String encode = StandardCharsets.UTF_8.name();
         response.setCharacterEncoding(encode);
         // 防止中文乱码
-        String fileName = context.getProjectId()+"_迁移sql";
+        String fileName = context.getProjectId()+"_迁移sql脚本";
 
         try {
             fileName = URLEncoder.encode(fileName, encode);

+ 3 - 3
adm-business/adm-middleware/src/main/java/com/persagy/proxy/migration/service/Impl/ObjectDigitalMigration.java

@@ -130,18 +130,18 @@ public class ObjectDigitalMigration extends MigrationAbstractServiceImpl<ObjectD
             if (objectDigital.getName() == null) {
                 sqls.append(objectDigital.getName()).append(",");
             } else {
-                sqls.append("'").append(objectDigital.getName()).append("',");
+                sqls.append("'").append(objectDigital.getName().replaceAll("\\'","\\\\'")).append("',");
             }
 
             if (objectDigital.getLocalId() == null) {
                 sqls.append(objectDigital.getLocalId()).append(",");
             } else {
-                sqls.append("'").append(objectDigital.getLocalId()).append("',");
+                sqls.append("'").append(objectDigital.getLocalId().replaceAll("\\'","\\\\'")).append("',");
             }
             if (objectDigital.getLocalName() == null) {
                 sqls.append(objectDigital.getLocalName()).append(",");
             } else {
-                sqls.append("'").append(objectDigital.getLocalName()).append("',");
+                sqls.append("'").append(objectDigital.getLocalName().replaceAll("\\'","\\\\'")).append("',");
             }
             sqls.append("'").append(objectDigital.getGroupCode()).append("',");
             sqls.append("'").append(objectDigital.getProjectId()).append("',");