File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
src/main/java/com/yanglb/codegen/core Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 2929import com .yanglb .codegen .utils .Resources ;
3030
3131import java .util .ArrayList ;
32+ import java .util .Arrays ;
3233import java .util .List ;
3334
3435
@@ -49,7 +50,7 @@ protected void onGeneration() throws CodeGenException {
4950 List <String > langList = new ArrayList <>();
5051 TableModel tableModel = list .get (0 );
5152 for (String key : tableModel .getColumns ()) {
52- if (! "id" . equals (key )) {
53+ if (needOutput (key )) {
5354 langList .add (key );
5455
5556 settingMap .put ("MsgLang" , key );
@@ -69,4 +70,12 @@ protected void onGeneration() throws CodeGenException {
6970 }
7071 }
7172 }
73+
74+ private boolean needOutput (String key ) {
75+ if ("id" .equals (key )) return false ;
76+ if ("default" .equals (key )) return true ;
77+ String [] lang = parameterModel .getOptions ().getOptionValues ("lang" );
78+ if (lang == null || lang .length == 0 ) return true ;
79+ return Arrays .asList (lang ).contains (key );
80+ }
7281}
Original file line number Diff line number Diff line change 1616package com .yanglb .codegen .core .parser .impl ;
1717
1818import com .yanglb .codegen .core .parser .BaseParser ;
19+ import org .apache .commons .cli .Option ;
20+ import org .apache .commons .cli .Options ;
1921
2022public class MsgParser extends BaseParser {
23+ @ Override
24+ protected Options options () {
25+ Options options = super .options ();
26+
27+ Option lang = Option .builder ()
28+ .longOpt ("lang" )
29+ .argName ("lang" )
30+ .desc ("待处理语言列表,无需填写默认语言(default),默认为全部" )
31+ .hasArg (true )
32+ .hasArgs ()
33+ .build ();
34+ options .addOption (lang );
35+
36+ return options ;
37+ }
38+
2139 @ Override
2240 protected boolean headerHelp () {
2341 System .out .println ("生成多语言资源信息" );
You can’t perform that action at this time.
0 commit comments