@@ -80,34 +80,12 @@ func (s *autoCodeHistory) RollBack(ctx context.Context, info request.SysAutoHist
80
80
if err != nil {
81
81
global .GVA_LOG .Error ("ClearTag DeleteApiByIds:" , zap .Error (err ))
82
82
}
83
- localPath := path .Join (global .GVA_CONFIG .AutoCode .Root , global .GVA_CONFIG .AutoCode .Server , "resource" , "lang" )
84
- files , err := s .readJSONFiles (localPath )
85
- if err != nil {
86
- return err
87
- }
88
- for _ , file := range files {
89
- err := s .reWriteI18nJson (file , "api" , history .Package , history .StructName )
90
- if err != nil {
91
- return err
92
- }
93
- }
94
83
} // 清除API表
95
84
if info .DeleteMenu {
96
85
err = BaseMenuServiceApp .DeleteBaseMenu (int (history .MenuID ))
97
86
if err != nil {
98
87
return errors .Wrap (err , "删除菜单失败!" )
99
88
}
100
- localPath := path .Join (global .GVA_CONFIG .AutoCode .Root , global .GVA_CONFIG .AutoCode .Server , "resource" , "lang" )
101
- files , err := s .readJSONFiles (localPath )
102
- if err != nil {
103
- return err
104
- }
105
- for _ , file := range files {
106
- err := s .reWriteI18nJson (file , "menu" , history .Package , history .StructName )
107
- if err != nil {
108
- return err
109
- }
110
- }
111
89
} // 清除菜单表
112
90
if info .DeleteTable {
113
91
err = s .DropTable (history .BusinessDB , history .Table )
@@ -197,15 +175,40 @@ func (s *autoCodeHistory) RollBack(ctx context.Context, info request.SysAutoHist
197
175
return errors .Wrapf (err , "[src:%s][dst:%s]文件移动失败!" , value , removePath )
198
176
}
199
177
} // 移动文件
178
+
200
179
err = global .GVA_DB .WithContext (ctx ).Model (& model.SysAutoCodeHistory {}).Where ("id = ?" , info .ID ).Update ("flag" , 1 ).Error
201
180
if err != nil {
202
181
return errors .Wrap (err , "更新失败!" )
203
182
}
204
- localPath := path .Join (global .GVA_CONFIG .AutoCode .Root , global .GVA_CONFIG .AutoCode .Web , "locales" )
183
+
184
+ localPath := path .Join (global .GVA_CONFIG .AutoCode .Root , global .GVA_CONFIG .AutoCode .Server , "resource" , "lang" )
205
185
files , err := s .readJSONFiles (localPath )
206
186
if err != nil {
207
187
return err
208
188
}
189
+ if info .DeleteMenu {
190
+ for _ , file := range files {
191
+ err := s .reWriteI18nJson (file , "menu" , history .Package , history .StructName )
192
+ if err != nil {
193
+ return err
194
+ }
195
+ }
196
+ }
197
+
198
+ if info .DeleteApi {
199
+ for _ , file := range files {
200
+ err := s .reWriteI18nJson (file , "api" , history .Package , history .StructName )
201
+ if err != nil {
202
+ return err
203
+ }
204
+ }
205
+ }
206
+
207
+ localPath = path .Join (global .GVA_CONFIG .AutoCode .Root , global .GVA_CONFIG .AutoCode .Web , "locales" )
208
+ files , err = s .readJSONFiles (localPath )
209
+ if err != nil {
210
+ return err
211
+ }
209
212
for _ , file := range files {
210
213
err := s .reWriteI18nJson (file , "web" , history .Package , history .StructName )
211
214
if err != nil {
0 commit comments