From 29e7c5dc41a841c9e324b0e076d7980e28ebd266 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期三, 09 八月 2023 10:48:05 +0800
Subject: [PATCH] update 优化 全局异常处理器 业务异常不输出具体堆栈信息 减少无用日志存储
---
ruoyi-modules/ruoyi-generator/src/main/java/org/dromara/generator/controller/GenController.java | 50 ++++++++++++++++++++++++++++++--------------------
1 files changed, 30 insertions(+), 20 deletions(-)
diff --git a/ruoyi-modules/ruoyi-generator/src/main/java/org/dromara/generator/controller/GenController.java b/ruoyi-modules/ruoyi-generator/src/main/java/org/dromara/generator/controller/GenController.java
index 32133c1..a4509b2 100644
--- a/ruoyi-modules/ruoyi-generator/src/main/java/org/dromara/generator/controller/GenController.java
+++ b/ruoyi-modules/ruoyi-generator/src/main/java/org/dromara/generator/controller/GenController.java
@@ -4,6 +4,7 @@
import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.IoUtil;
import org.dromara.common.core.domain.R;
+import org.dromara.common.mybatis.helper.DataBaseHelper;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -55,7 +56,7 @@
GenTable table = genTableService.selectGenTableById(tableId);
List<GenTable> tables = genTableService.selectGenTableAll();
List<GenTableColumn> list = genTableService.selectGenTableColumnListByTableId(tableId);
- Map<String, Object> map = new HashMap<String, Object>();
+ Map<String, Object> map = new HashMap<>(3);
map.put("info", table);
map.put("rows", list);
map.put("tables", tables);
@@ -94,11 +95,11 @@
@SaCheckPermission("tool:gen:import")
@Log(title = "浠g爜鐢熸垚", businessType = BusinessType.IMPORT)
@PostMapping("/importTable")
- public R<Void> importTableSave(String tables) {
+ public R<Void> importTableSave(String tables, String dataName) {
String[] tableNames = Convert.toStrArray(tables);
// 鏌ヨ琛ㄤ俊鎭�
- List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
- genTableService.importGenTable(tableList);
+ List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames, dataName);
+ genTableService.importGenTable(tableList, dataName);
return R.ok();
}
@@ -142,53 +143,53 @@
/**
* 鐢熸垚浠g爜锛堜笅杞芥柟寮忥級
*
- * @param tableName 琛ㄥ悕
+ * @param tableId 琛↖D
*/
@SaCheckPermission("tool:gen:code")
@Log(title = "浠g爜鐢熸垚", businessType = BusinessType.GENCODE)
- @GetMapping("/download/{tableName}")
- public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException {
- byte[] data = genTableService.downloadCode(tableName);
+ @GetMapping("/download/{tableId}")
+ public void download(HttpServletResponse response, @PathVariable("tableId") Long tableId) throws IOException {
+ byte[] data = genTableService.downloadCode(tableId);
genCode(response, data);
}
/**
* 鐢熸垚浠g爜锛堣嚜瀹氫箟璺緞锛�
*
- * @param tableName 琛ㄥ悕
+ * @param tableId 琛↖D
*/
@SaCheckPermission("tool:gen:code")
@Log(title = "浠g爜鐢熸垚", businessType = BusinessType.GENCODE)
- @GetMapping("/genCode/{tableName}")
- public R<Void> genCode(@PathVariable("tableName") String tableName) {
- genTableService.generatorCode(tableName);
+ @GetMapping("/genCode/{tableId}")
+ public R<Void> genCode(@PathVariable("tableId") Long tableId) {
+ genTableService.generatorCode(tableId);
return R.ok();
}
/**
* 鍚屾鏁版嵁搴�
*
- * @param tableName 琛ㄥ悕
+ * @param tableId 琛↖D
*/
@SaCheckPermission("tool:gen:edit")
@Log(title = "浠g爜鐢熸垚", businessType = BusinessType.UPDATE)
- @GetMapping("/synchDb/{tableName}")
- public R<Void> synchDb(@PathVariable("tableName") String tableName) {
- genTableService.synchDb(tableName);
+ @GetMapping("/synchDb/{tableId}")
+ public R<Void> synchDb(@PathVariable("tableId") Long tableId) {
+ genTableService.synchDb(tableId);
return R.ok();
}
/**
* 鎵归噺鐢熸垚浠g爜
*
- * @param tables 琛ㄥ悕涓�
+ * @param tableIdStr 琛↖D涓�
*/
@SaCheckPermission("tool:gen:code")
@Log(title = "浠g爜鐢熸垚", businessType = BusinessType.GENCODE)
@GetMapping("/batchGenCode")
- public void batchGenCode(HttpServletResponse response, String tables) throws IOException {
- String[] tableNames = Convert.toStrArray(tables);
- byte[] data = genTableService.downloadCode(tableNames);
+ public void batchGenCode(HttpServletResponse response, String tableIdStr) throws IOException {
+ String[] tableIds = Convert.toStrArray(tableIdStr);
+ byte[] data = genTableService.downloadCode(tableIds);
genCode(response, data);
}
@@ -204,4 +205,13 @@
response.setContentType("application/octet-stream; charset=UTF-8");
IoUtil.write(response.getOutputStream(), false, data);
}
+
+ /**
+ * 鏌ヨ鏁版嵁婧愬悕绉板垪琛�
+ */
+ @SaCheckPermission("tool:gen:list")
+ @GetMapping(value = "/getDataNames")
+ public R<Object> getCurrentDataSourceNameList(){
+ return R.ok(DataBaseHelper.getDataSourceNameList());
+ }
}
--
Gitblit v1.9.3