yingp 6 лет назад
Родитель
Сommit
ea5d847b6d
1 измененных файлов с 11 добавлено и 0 удалено
  1. 11 0
      uas-office-core/src/main/java/com/usoftchina/uas/office/jdbc/SchemaUtils.java

+ 11 - 0
uas-office-core/src/main/java/com/usoftchina/uas/office/jdbc/SchemaUtils.java

@@ -1,6 +1,8 @@
 package com.usoftchina.uas.office.jdbc;
 package com.usoftchina.uas.office.jdbc;
 
 
 import com.usoftchina.uas.office.util.StringUtils;
 import com.usoftchina.uas.office.util.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.JdbcTemplate;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
@@ -13,6 +15,8 @@ import java.util.stream.Collectors;
  */
  */
 public class SchemaUtils {
 public class SchemaUtils {
 
 
+    private final static Logger logger = LoggerFactory.getLogger(SchemaUtils.class);
+
     public static TableBuilder newTable(String tableName) {
     public static TableBuilder newTable(String tableName) {
         return new TableBuilder(tableName);
         return new TableBuilder(tableName);
     }
     }
@@ -44,8 +48,10 @@ public class SchemaUtils {
     }
     }
 
 
     public static void create(Table table, JdbcTemplate jdbcTemplate) {
     public static void create(Table table, JdbcTemplate jdbcTemplate) {
+        logger.debug("SchemaUtils create(Table table, JdbcTemplate jdbcTemplate)");
         TableBuilder builder = newTable(table.name);
         TableBuilder builder = newTable(table.name);
         table.getColumns().forEach(column -> {
         table.getColumns().forEach(column -> {
+            logger.debug("SchemaUtils create(Table table, JdbcTemplate jdbcTemplate) forEach columns");
             builder.add(newColumn(column.getName())
             builder.add(newColumn(column.getName())
                     .type(column.getType())
                     .type(column.getType())
                     .notNull(column.isNotNull())
                     .notNull(column.isNotNull())
@@ -90,6 +96,7 @@ public class SchemaUtils {
         }
         }
 
 
         public void create(JdbcTemplate jdbcTemplate) {
         public void create(JdbcTemplate jdbcTemplate) {
+            logger.debug("SchemaUtils create(JdbcTemplate jdbcTemplate)");
             SchemaUtils.create(this, jdbcTemplate);
             SchemaUtils.create(this, jdbcTemplate);
         }
         }
     }
     }
@@ -117,10 +124,13 @@ public class SchemaUtils {
 
 
         public void create(JdbcTemplate jdbcTemplate) {
         public void create(JdbcTemplate jdbcTemplate) {
             if (isTableExists(name, jdbcTemplate)) {
             if (isTableExists(name, jdbcTemplate)) {
+                logger.debug("SchemaUtils create(JdbcTemplate jdbcTemplate) table exists " + name);
                 columnBuilderList.forEach(builder -> {
                 columnBuilderList.forEach(builder -> {
                     if (isColumnExists(name, builder.name, jdbcTemplate)) {
                     if (isColumnExists(name, builder.name, jdbcTemplate)) {
+                        logger.debug("SchemaUtils create(JdbcTemplate jdbcTemplate) column exists " + builder.name);
                         builder.modify(this, jdbcTemplate);
                         builder.modify(this, jdbcTemplate);
                     } else {
                     } else {
+                        logger.debug("SchemaUtils create(JdbcTemplate jdbcTemplate) column add " + builder.name);
                         builder.add(this, jdbcTemplate);
                         builder.add(this, jdbcTemplate);
                     }
                     }
                 });
                 });
@@ -129,6 +139,7 @@ public class SchemaUtils {
                 statement.append(name).append(" (");
                 statement.append(name).append(" (");
                 statement.append(columnBuilderList.stream().map(ColumnBuilder::toString).collect(Collectors.joining(",")));
                 statement.append(columnBuilderList.stream().map(ColumnBuilder::toString).collect(Collectors.joining(",")));
                 statement.append(")");
                 statement.append(")");
+                logger.debug("SchemaUtils create(JdbcTemplate jdbcTemplate) create table " + statement);
                 jdbcTemplate.execute(statement.toString());
                 jdbcTemplate.execute(statement.toString());
             }
             }