Skip to content

Commit a5fc04f

Browse files
committed
调整代码
1 parent 2269bc9 commit a5fc04f

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/main/java/com/example/controller/DataBaseController.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ public ResponseBean list(@RequestParam(defaultValue = "1") Integer page,
101101
public ResponseBean all() {
102102
// 获取所有表名
103103
List<Map<String, Object>> list = generatorDao.queryList(null);
104-
for (Map<String, Object> map : list) {
105-
if (StringUtils.isNoneBlank(map.get("tableComment").toString())) {
106-
map.put("label", map.get("tableName") + "---" + map.get("tableComment") + "---" + map.get("engine"));
104+
for (Map<String, Object> table : list) {
105+
if (StringUtils.isNoneBlank(table.get("tableComment").toString())) {
106+
table.put("label", table.get("tableName") + "---" + table.get("tableComment") + "---" + table.get("engine"));
107107
} else {
108-
map.put("label", map.get("tableName") + "---" + map.get("engine"));
108+
table.put("label", table.get("tableName") + "---" + table.get("engine"));
109109
}
110-
map.put("value", map.get("tableName"));
110+
table.put("value", table.get("tableName"));
111111
}
112112
return new ResponseBean(HttpStatus.OK.value(), "查询成功", list);
113113
}
@@ -196,6 +196,8 @@ public void genTableToZip(@PathVariable("tableName") String tableName,
196196
IOUtils.write(data, response.getOutputStream());
197197
// 删除临时路径下所有临时文件
198198
FileUtils.deleteDirectory(tempDir);
199+
} else {
200+
throw new SystemException("生成失败,请检查数据库是否连接正常及表名是否正确以及权限是否缺失");
199201
}
200202
}
201203

@@ -227,7 +229,7 @@ public ResponseBean open() {
227229
* @date 2019-04-05 18:00:26
228230
*/
229231
@PutMapping("/config")
230-
public ResponseBean config(@RequestBody Map<String, String> map) {
232+
public ResponseBean config(@RequestBody Map<String, String> config) {
231233
try {
232234
final Enumeration urls = DataBaseController.class.getClassLoader().getResources("config/generator.properties");
233235
while (urls.hasMoreElements()) {
@@ -239,15 +241,15 @@ public ResponseBean config(@RequestBody Map<String, String> map) {
239241
con.setUseCaches(false);
240242
input = con.getInputStream();
241243
SafeProperties safeProperties = new SafeProperties();
242-
if (Boolean.parseBoolean(map.get("isRead"))) {
244+
if (Boolean.parseBoolean(config.get("isRead"))) {
243245
// 读
244246
safeProperties.load(input);
245-
map = (Map) safeProperties;
247+
config = (Map) safeProperties;
246248
} else {
247249
// 写
248250
safeProperties.load(input);
249251
// 遍历map写入
250-
Iterator<Map.Entry<String, String>> entries = map.entrySet().iterator();
252+
Iterator<Map.Entry<String, String>> entries = config.entrySet().iterator();
251253
while (entries.hasNext()) {
252254
Map.Entry<String, String> entry = entries.next();
253255
if (Constant.TEMPLATE.equals(entry.getKey())) {
@@ -277,7 +279,7 @@ public ResponseBean config(@RequestBody Map<String, String> map) {
277279
} catch (IOException e) {
278280
throw new SystemException("操作失败");
279281
}
280-
return new ResponseBean(HttpStatus.OK.value(), "操作成功", map);
282+
return new ResponseBean(HttpStatus.OK.value(), "操作成功", config);
281283
}
282284

283285
/**

src/main/java/com/example/util/SafeProperties.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ public synchronized Object put(Object key, Object value, String line) {
307307
return super.put(key, value);
308308
}
309309

310-
311310
@Override
312311
public synchronized Object remove(Object key) {
313312
context.remove(key.toString());
@@ -418,7 +417,6 @@ public String toString() {
418417
}
419418
}
420419

421-
422420
public void addComment(String comment) {
423421
if (comment != null) {
424422
context.addCommentLine("#" + comment);

0 commit comments

Comments
 (0)