From 695cb6d76b838b1e4cb161bae335faa948dca12a Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期三, 27 十月 2021 13:16:19 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into satoken

---
 ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java |  100 +++++++++++++++++++++++++------------------------
 1 files changed, 51 insertions(+), 49 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 5343834..55c93d8 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
@@ -1,5 +1,6 @@
 package com.ruoyi.generator.controller;
 
+import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.convert.Convert;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.controller.BaseController;
@@ -10,9 +11,11 @@
 import com.ruoyi.generator.domain.GenTableColumn;
 import com.ruoyi.generator.service.IGenTableColumnService;
 import com.ruoyi.generator.service.IGenTableService;
+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.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -24,36 +27,36 @@
 
 /**
  * 浠g爜鐢熸垚 鎿嶄綔澶勭悊
- * 
- * @author ruoyi
+ *
+ * @author Lion Li
  */
+@Validated
+@Api(value = "浠g爜鐢熸垚", tags = {"浠g爜鐢熸垚绠$悊"})
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
 @RestController
 @RequestMapping("/tool/gen")
-public class GenController extends BaseController
-{
-    @Autowired
-    private IGenTableService genTableService;
+public class GenController extends BaseController {
 
-    @Autowired
-    private IGenTableColumnService genTableColumnService;
+    private final IGenTableService genTableService;
+    private final IGenTableColumnService genTableColumnService;
 
     /**
      * 鏌ヨ浠g爜鐢熸垚鍒楄〃
      */
-    @PreAuthorize("@ss.hasPermi('tool:gen:list')")
+    @ApiOperation("鏌ヨ浠g爜鐢熸垚鍒楄〃")
+    @SaCheckPermission("tool:gen:list")
     @GetMapping("/list")
-    public TableDataInfo genList(GenTable genTable)
-    {
+    public TableDataInfo<GenTable> genList(GenTable genTable) {
         return genTableService.selectPageGenTableList(genTable);
     }
 
     /**
      * 淇敼浠g爜鐢熸垚涓氬姟
      */
-    @PreAuthorize("@ss.hasPermi('tool:gen:query')")
+    @ApiOperation("淇敼浠g爜鐢熸垚涓氬姟")
+    @SaCheckPermission("tool:gen:query")
     @GetMapping(value = "/{talbleId}")
-    public AjaxResult getInfo(@PathVariable Long talbleId)
-    {
+    public AjaxResult<Map<String, Object>> getInfo(@PathVariable Long talbleId) {
         GenTable table = genTableService.selectGenTableById(talbleId);
         List<GenTable> tables = genTableService.selectGenTableAll();
         List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId);
@@ -67,21 +70,21 @@
     /**
      * 鏌ヨ鏁版嵁搴撳垪琛�
      */
-    @PreAuthorize("@ss.hasPermi('tool:gen:list')")
+    @ApiOperation("鏌ヨ鏁版嵁搴撳垪琛�")
+    @SaCheckPermission("tool:gen:list")
     @GetMapping("/db/list")
-    public TableDataInfo dataList(GenTable genTable)
-    {
+    public TableDataInfo<GenTable> dataList(GenTable genTable) {
         return genTableService.selectPageDbTableList(genTable);
     }
 
     /**
      * 鏌ヨ鏁版嵁琛ㄥ瓧娈靛垪琛�
      */
-    @PreAuthorize("@ss.hasPermi('tool:gen:list')")
+    @ApiOperation("鏌ヨ鏁版嵁琛ㄥ瓧娈靛垪琛�")
+    @SaCheckPermission("tool:gen:list")
     @GetMapping(value = "/column/{talbleId}")
-    public TableDataInfo columnList(Long tableId)
-    {
-        TableDataInfo dataInfo = new TableDataInfo();
+    public TableDataInfo<GenTableColumn> columnList(Long tableId) {
+        TableDataInfo<GenTableColumn> dataInfo = new TableDataInfo<>();
         List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
         dataInfo.setRows(list);
         dataInfo.setTotal(list.size());
@@ -91,11 +94,11 @@
     /**
      * 瀵煎叆琛ㄧ粨鏋勶紙淇濆瓨锛�
      */
-    @PreAuthorize("@ss.hasPermi('tool:gen:import')")
+    @ApiOperation("瀵煎叆琛ㄧ粨鏋勶紙淇濆瓨锛�")
+    @SaCheckPermission("tool:gen:import")
     @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.IMPORT)
     @PostMapping("/importTable")
-    public AjaxResult importTableSave(String tables)
-    {
+    public AjaxResult<Void> importTableSave(String tables) {
         String[] tableNames = Convert.toStrArray(tables);
         // 鏌ヨ琛ㄤ俊鎭�
         List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
@@ -106,11 +109,11 @@
     /**
      * 淇敼淇濆瓨浠g爜鐢熸垚涓氬姟
      */
-    @PreAuthorize("@ss.hasPermi('tool:gen:edit')")
+    @ApiOperation("淇敼淇濆瓨浠g爜鐢熸垚涓氬姟")
+    @SaCheckPermission("tool:gen:edit")
     @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult editSave(@Validated @RequestBody GenTable genTable)
-    {
+    public AjaxResult<Void> editSave(@Validated @RequestBody GenTable genTable) {
         genTableService.validateEdit(genTable);
         genTableService.updateGenTable(genTable);
         return AjaxResult.success();
@@ -119,11 +122,11 @@
     /**
      * 鍒犻櫎浠g爜鐢熸垚
      */
-    @PreAuthorize("@ss.hasPermi('tool:gen:remove')")
+    @ApiOperation("鍒犻櫎浠g爜鐢熸垚")
+    @SaCheckPermission("tool:gen:remove")
     @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.DELETE)
     @DeleteMapping("/{tableIds}")
-    public AjaxResult remove(@PathVariable Long[] tableIds)
-    {
+    public AjaxResult<Void> remove(@PathVariable Long[] tableIds) {
         genTableService.deleteGenTableByIds(tableIds);
         return AjaxResult.success();
     }
@@ -131,10 +134,10 @@
     /**
      * 棰勮浠g爜
      */
-    @PreAuthorize("@ss.hasPermi('tool:gen:preview')")
+    @ApiOperation("棰勮浠g爜")
+    @SaCheckPermission("tool:gen:preview")
     @GetMapping("/preview/{tableId}")
-    public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException
-    {
+    public AjaxResult<Map<String, String>> preview(@PathVariable("tableId") Long tableId) throws IOException {
         Map<String, String> dataMap = genTableService.previewCode(tableId);
         return AjaxResult.success(dataMap);
     }
@@ -142,11 +145,11 @@
     /**
      * 鐢熸垚浠g爜锛堜笅杞芥柟寮忥級
      */
-    @PreAuthorize("@ss.hasPermi('tool:gen:code')")
+    @ApiOperation("鐢熸垚浠g爜锛堜笅杞芥柟寮忥級")
+    @SaCheckPermission("tool:gen:code")
     @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.GENCODE)
     @GetMapping("/download/{tableName}")
-    public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException
-    {
+    public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException {
         byte[] data = genTableService.downloadCode(tableName);
         genCode(response, data);
     }
@@ -154,11 +157,11 @@
     /**
      * 鐢熸垚浠g爜锛堣嚜瀹氫箟璺緞锛�
      */
-    @PreAuthorize("@ss.hasPermi('tool:gen:code')")
+    @ApiOperation("鐢熸垚浠g爜锛堣嚜瀹氫箟璺緞锛�")
+    @SaCheckPermission("tool:gen:code")
     @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.GENCODE)
     @GetMapping("/genCode/{tableName}")
-    public AjaxResult genCode(@PathVariable("tableName") String tableName)
-    {
+    public AjaxResult<Void> genCode(@PathVariable("tableName") String tableName) {
         genTableService.generatorCode(tableName);
         return AjaxResult.success();
     }
@@ -166,11 +169,11 @@
     /**
      * 鍚屾鏁版嵁搴�
      */
-    @PreAuthorize("@ss.hasPermi('tool:gen:edit')")
+    @ApiOperation("鍚屾鏁版嵁搴�")
+    @SaCheckPermission("tool:gen:edit")
     @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.UPDATE)
     @GetMapping("/synchDb/{tableName}")
-    public AjaxResult synchDb(@PathVariable("tableName") String tableName)
-    {
+    public AjaxResult<Void> synchDb(@PathVariable("tableName") String tableName) {
         genTableService.synchDb(tableName);
         return AjaxResult.success();
     }
@@ -178,11 +181,11 @@
     /**
      * 鎵归噺鐢熸垚浠g爜
      */
-    @PreAuthorize("@ss.hasPermi('tool:gen:code')")
+    @ApiOperation("鎵归噺鐢熸垚浠g爜")
+    @SaCheckPermission("tool:gen:code")
     @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.GENCODE)
     @GetMapping("/batchGenCode")
-    public void batchGenCode(HttpServletResponse response, String tables) throws IOException
-    {
+    public void batchGenCode(HttpServletResponse response, String tables) throws IOException {
         String[] tableNames = Convert.toStrArray(tables);
         byte[] data = genTableService.downloadCode(tableNames);
         genCode(response, data);
@@ -191,8 +194,7 @@
     /**
      * 鐢熸垚zip鏂囦欢
      */
-    private void genCode(HttpServletResponse response, byte[] data) throws IOException
-    {
+    private void genCode(HttpServletResponse response, byte[] data) throws IOException {
         response.reset();
         response.addHeader("Access-Control-Allow-Origin", "*");
         response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");
@@ -201,4 +203,4 @@
         response.setContentType("application/octet-stream; charset=UTF-8");
         IOUtils.write(data, response.getOutputStream());
     }
-}
\ No newline at end of file
+}

--
Gitblit v1.9.3