@@ -31,6 +31,16 @@ protected void onBeforeTranslate() throws CodeGenException {
3131 this .writableModel .setExtension ("json" );
3232 }
3333
34+ private void tblModel2Json (JSONObject json , TableModel tblModel ) {
35+ for (Map <String , String > itm : tblModel .toList ()) {
36+ String id = itm .get ("id" );
37+ String value = itm .get (this .msgLang );
38+ if (StringUtil .isNullOrEmpty (id )) continue ;
39+
40+ json .put (id , value );
41+ }
42+ }
43+
3444 @ Override
3545 protected void onTranslate () throws CodeGenException {
3646 super .onTranslate ();
@@ -40,25 +50,14 @@ protected void onTranslate() throws CodeGenException {
4050 if (this .paramaModel .getOptions ().hasOption ("combine" )) {
4151 // 合并输出
4252 for (TableModel tblModel : this .model ) {
43- for (Map <String , String > itm : tblModel .toList ()) {
44- String id = itm .get ("id" );
45- String value = itm .get (this .msgLang );
46- if (StringUtil .isNullOrEmpty (id )) continue ;
47-
48- json .put (id , value );
49- }
53+ tblModel2Json (json , tblModel );
5054 }
5155 } else {
5256 // 分组输出
5357 for (TableModel tblModel : this .model ) {
5458 JSONObject sub = new JSONObject ();
55- for (Map <String , String > itm : tblModel .toList ()) {
56- String id = itm .get ("id" );
57- String value = itm .get (this .msgLang );
58- if (StringUtil .isNullOrEmpty (id )) continue ;
59+ tblModel2Json (sub , tblModel );
5960
60- sub .put (id , value );
61- }
6261 String sheetName = tblModel .getSheetName ();
6362 json .put (sheetName , sub );
6463 }
0 commit comments