File tree Expand file tree Collapse file tree 5 files changed +37
-3
lines changed
src/main/java/com/yanglb/codegen Expand file tree Collapse file tree 5 files changed +37
-3
lines changed Original file line number Diff line number Diff line change 16
16
package com .yanglb .codegen .core .parser .impl ;
17
17
18
18
import com .yanglb .codegen .core .parser .BaseParser ;
19
+ import org .apache .commons .cli .Option ;
20
+ import org .apache .commons .cli .Options ;
19
21
20
22
public class DmlParser extends BaseParser {
23
+ @ Override
24
+ protected Options options () {
25
+ Options options = super .options ();
26
+
27
+ Option target = Option .builder ()
28
+ .longOpt ("target" )
29
+ .hasArg ()
30
+ .desc ("指定生成目标,可选 mysql/mssql/sqlite,默认为mysql" )
31
+ .build ();
32
+ options .addOption (target );
33
+ return options ;
34
+ }
35
+
21
36
@ Override
22
37
protected boolean headerHelp () {
23
38
System .out .println ("生成初始数据SQL脚本,用于向数据添加初始数据。" );
Original file line number Diff line number Diff line change 17
17
18
18
import java .util .List ;
19
19
20
- import com .yanglb .codegen .exceptions .CodeGenException ;
21
-
22
20
public class BaseSqlTranslator <T > extends BaseTranslator <List <T >> {
23
21
// 列引号字符,如:SQL Server为[], MySQL为`等
24
22
protected String sqlColumnStart = "\" " ;
Original file line number Diff line number Diff line change 28
28
29
29
public class DdlSqliteTranslatorImpl extends BaseDdlTranslator {
30
30
31
+ public DdlSqliteTranslatorImpl () {
32
+ this .sqlColumnStart = "\" " ;
33
+ this .sqlColumnEnd = "\" " ;
34
+ }
35
+
31
36
@ Override
32
37
protected void onBeforeTranslate () throws CodeGenException {
33
38
super .onBeforeTranslate ();
Original file line number Diff line number Diff line change @@ -41,6 +41,22 @@ protected void onBeforeTranslate() throws CodeGenException {
41
41
fileName = fileName .substring (0 , index );
42
42
}
43
43
this .writableModel .setFileName (fileName );
44
+
45
+ String target = parameterModel .getOptions ().getOptionValue ("target" , "mysql" );
46
+ switch (target ) {
47
+ case "mysql" :
48
+ sqlColumnStart = "`" ;
49
+ sqlColumnEnd = "`" ;
50
+ break ;
51
+ case "mssql" :
52
+ sqlColumnStart = "[" ;
53
+ sqlColumnEnd = "[" ;
54
+ break ;
55
+ case "sqlite" :
56
+ sqlColumnStart = "\" " ;
57
+ sqlColumnEnd = "\" " ;
58
+ break ;
59
+ }
44
60
}
45
61
46
62
@ Override
Original file line number Diff line number Diff line change 17
17
18
18
public class Infos {
19
19
public static final String Name = "Code Generator" ;
20
- public static final String Version = "4.0.3 " ;
20
+ public static final String Version = "4.1.0 " ;
21
21
public static final String Copyright = "Copyright 2015-2020 yanglb.com All Rights Reserved." ;
22
22
public static final String Author = "me@yanglb.com" ;
23
23
public static final String Website = "https://yanglb.com" ;
You can’t perform that action at this time.
0 commit comments