From 54f5b59c8c70c52645ee1c4b2d65f6ff1ff54a0c Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期二, 15 二月 2022 12:07:56 +0800
Subject: [PATCH] update 优化代码生成 使用新 JsonUtils.parseMap 方法

---
 ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java
index 55c93d8..09bf1ae 100644
--- a/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java
+++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java
@@ -2,9 +2,11 @@
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.convert.Convert;
+import cn.hutool.core.io.IoUtil;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.controller.BaseController;
-import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.domain.PageQuery;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.generator.domain.GenTable;
@@ -14,8 +16,6 @@
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
-import org.apache.commons.io.IOUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -32,7 +32,7 @@
  */
 @Validated
 @Api(value = "浠g爜鐢熸垚", tags = {"浠g爜鐢熸垚绠$悊"})
-@RequiredArgsConstructor(onConstructor_ = @Autowired)
+@RequiredArgsConstructor
 @RestController
 @RequestMapping("/tool/gen")
 public class GenController extends BaseController {
@@ -46,8 +46,8 @@
     @ApiOperation("鏌ヨ浠g爜鐢熸垚鍒楄〃")
     @SaCheckPermission("tool:gen:list")
     @GetMapping("/list")
-    public TableDataInfo<GenTable> genList(GenTable genTable) {
-        return genTableService.selectPageGenTableList(genTable);
+    public TableDataInfo<GenTable> genList(GenTable genTable, PageQuery pageQuery) {
+        return genTableService.selectPageGenTableList(genTable, pageQuery);
     }
 
     /**
@@ -56,7 +56,7 @@
     @ApiOperation("淇敼浠g爜鐢熸垚涓氬姟")
     @SaCheckPermission("tool:gen:query")
     @GetMapping(value = "/{talbleId}")
-    public AjaxResult<Map<String, Object>> getInfo(@PathVariable Long talbleId) {
+    public R<Map<String, Object>> getInfo(@PathVariable Long talbleId) {
         GenTable table = genTableService.selectGenTableById(talbleId);
         List<GenTable> tables = genTableService.selectGenTableAll();
         List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId);
@@ -64,7 +64,7 @@
         map.put("info", table);
         map.put("rows", list);
         map.put("tables", tables);
-        return AjaxResult.success(map);
+        return R.ok(map);
     }
 
     /**
@@ -73,8 +73,8 @@
     @ApiOperation("鏌ヨ鏁版嵁搴撳垪琛�")
     @SaCheckPermission("tool:gen:list")
     @GetMapping("/db/list")
-    public TableDataInfo<GenTable> dataList(GenTable genTable) {
-        return genTableService.selectPageDbTableList(genTable);
+    public TableDataInfo<GenTable> dataList(GenTable genTable, PageQuery pageQuery) {
+        return genTableService.selectPageDbTableList(genTable, pageQuery);
     }
 
     /**
@@ -98,12 +98,12 @@
     @SaCheckPermission("tool:gen:import")
     @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.IMPORT)
     @PostMapping("/importTable")
-    public AjaxResult<Void> importTableSave(String tables) {
+    public R<Void> importTableSave(String tables) {
         String[] tableNames = Convert.toStrArray(tables);
         // 鏌ヨ琛ㄤ俊鎭�
         List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
         genTableService.importGenTable(tableList);
-        return AjaxResult.success();
+        return R.ok();
     }
 
     /**
@@ -113,10 +113,10 @@
     @SaCheckPermission("tool:gen:edit")
     @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult<Void> editSave(@Validated @RequestBody GenTable genTable) {
+    public R<Void> editSave(@Validated @RequestBody GenTable genTable) {
         genTableService.validateEdit(genTable);
         genTableService.updateGenTable(genTable);
-        return AjaxResult.success();
+        return R.ok();
     }
 
     /**
@@ -126,9 +126,9 @@
     @SaCheckPermission("tool:gen:remove")
     @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.DELETE)
     @DeleteMapping("/{tableIds}")
-    public AjaxResult<Void> remove(@PathVariable Long[] tableIds) {
+    public R<Void> remove(@PathVariable Long[] tableIds) {
         genTableService.deleteGenTableByIds(tableIds);
-        return AjaxResult.success();
+        return R.ok();
     }
 
     /**
@@ -137,9 +137,9 @@
     @ApiOperation("棰勮浠g爜")
     @SaCheckPermission("tool:gen:preview")
     @GetMapping("/preview/{tableId}")
-    public AjaxResult<Map<String, String>> preview(@PathVariable("tableId") Long tableId) throws IOException {
+    public R<Map<String, String>> preview(@PathVariable("tableId") Long tableId) throws IOException {
         Map<String, String> dataMap = genTableService.previewCode(tableId);
-        return AjaxResult.success(dataMap);
+        return R.ok(dataMap);
     }
 
     /**
@@ -161,9 +161,9 @@
     @SaCheckPermission("tool:gen:code")
     @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.GENCODE)
     @GetMapping("/genCode/{tableName}")
-    public AjaxResult<Void> genCode(@PathVariable("tableName") String tableName) {
+    public R<Void> genCode(@PathVariable("tableName") String tableName) {
         genTableService.generatorCode(tableName);
-        return AjaxResult.success();
+        return R.ok();
     }
 
     /**
@@ -173,9 +173,9 @@
     @SaCheckPermission("tool:gen:edit")
     @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.UPDATE)
     @GetMapping("/synchDb/{tableName}")
-    public AjaxResult<Void> synchDb(@PathVariable("tableName") String tableName) {
+    public R<Void> synchDb(@PathVariable("tableName") String tableName) {
         genTableService.synchDb(tableName);
-        return AjaxResult.success();
+        return R.ok();
     }
 
     /**
@@ -201,6 +201,6 @@
         response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\"");
         response.addHeader("Content-Length", "" + data.length);
         response.setContentType("application/octet-stream; charset=UTF-8");
-        IOUtils.write(data, response.getOutputStream());
+        IoUtil.write(response.getOutputStream(), false, data);
     }
 }

--
Gitblit v1.9.3