Browse Source

插入支持List

张泳健 5 years ago
parent
commit
98bdae6d9d

+ 6 - 0
README.md View File

11
 ```
11
 ```
12
 参数说明:
12
 参数说明:
13
 1. `-t=` / `--table=` 这两个指定导出的表名.
13
 1. `-t=` / `--table=` 这两个指定导出的表名.
14
+2. `--size`: 指定分页大小
15
+3. `--truncate=true`: 插入数据前清空表
16
+4. `--type=mysql` 类型
17
+    - mysql: 拼语句
18
+    - mysqlps: 不拼语句
19
+    - csv: 导出到csv文件
14
 
20
 
15
 
21
 
16
 
22
 

+ 17 - 0
src/main/java/com/vcarecity/cvs/FileExporterApp.java View File

54
             properties = basePath;
54
             properties = basePath;
55
         }
55
         }
56
 
56
 
57
+        final int pageCount = getPageCount(args);
58
+
57
 
59
 
58
         injector = Guice.createInjector(new PropertiesModule(appProperties), new SQLModule(type));
60
         injector = Guice.createInjector(new PropertiesModule(appProperties), new SQLModule(type));
59
 
61
 
60
         final SQLStarter instance = injector.getInstance(SQLStarter.class);
62
         final SQLStarter instance = injector.getInstance(SQLStarter.class);
63
+        instance.setPageCount(pageCount);
64
+
61
         instance.exportDataAndConvert(table, properties, tableClass, isTruncate);
65
         instance.exportDataAndConvert(table, properties, tableClass, isTruncate);
62
     }
66
     }
63
 
67
 
85
         return null;
89
         return null;
86
     }
90
     }
87
 
91
 
92
+    private static int getPageCount(String[] args) {
93
+        for (String arg : args) {
94
+            if (arg.startsWith("--size=")) {
95
+                try {
96
+                    return Integer.parseInt(arg.substring("--size=".length()));
97
+                } catch (RuntimeException e) {
98
+
99
+                }
100
+            }
101
+        }
102
+        return 10000;
103
+    }
104
+
88
 
105
 
89
     private static boolean jdbcArgs(String[] args, AppProperties properties) {
106
     private static boolean jdbcArgs(String[] args, AppProperties properties) {
90
         final DbProperties database = properties.getFromDb();
107
         final DbProperties database = properties.getFromDb();

+ 3 - 0
src/main/java/com/vcarecity/cvs/starter/SQLStarter.java View File

20
 @Slf4j
20
 @Slf4j
21
 public class SQLStarter {
21
 public class SQLStarter {
22
 
22
 
23
+    /**
24
+     * default
25
+     */
23
     private static final int PAGE_COUNT = 10000;
26
     private static final int PAGE_COUNT = 10000;
24
 
27
 
25
     private int pageCount = PAGE_COUNT;
28
     private int pageCount = PAGE_COUNT;