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 5a03d48..9d106b4 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 @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; @@ -38,8 +39,7 @@ import jakarta.servlet.http.HttpServletResponse; */ @RestController @RequestMapping("/tool/gen") -public class GenController extends BaseController -{ +public class GenController extends BaseController { @Autowired private IGenTableService genTableService; @@ -51,8 +51,7 @@ public class GenController extends BaseController */ @PreAuthorize("@ss.hasPermi('tool:gen:list')") @GetMapping("/list") - public TableDataInfo genList(GenTable genTable) - { + public TableDataInfo genList(GenTable genTable) { startPage(); List list = genTableService.selectGenTableList(genTable); return getDataTable(list); @@ -63,8 +62,7 @@ public class GenController extends BaseController */ @PreAuthorize("@ss.hasPermi('tool:gen:query')") @GetMapping(value = "/{tableId}") - public AjaxResult getInfo(@PathVariable( name = "tableId" ) Long tableId) - { + public AjaxResult getInfo(@PathVariable(name = "tableId") Long tableId) { GenTable table = genTableService.selectGenTableById(tableId); List tables = genTableService.selectGenTableAll(); List list = genTableColumnService.selectGenTableColumnListByTableId(tableId); @@ -80,8 +78,7 @@ public class GenController extends BaseController */ @PreAuthorize("@ss.hasPermi('tool:gen:list')") @GetMapping("/db/list") - public TableDataInfo dataList(GenTable genTable) - { + public TableDataInfo dataList(GenTable genTable) { startPage(); List list = genTableService.selectDbTableList(genTable); return getDataTable(list); @@ -92,8 +89,7 @@ public class GenController extends BaseController */ @PreAuthorize("@ss.hasPermi('tool:gen:list')") @GetMapping(value = "/column/{tableId}") - public TableDataInfo columnList(Long tableId) - { + public TableDataInfo columnList(@PathVariable(name = "tableId") Long tableId) { TableDataInfo dataInfo = new TableDataInfo(); List list = genTableColumnService.selectGenTableColumnListByTableId(tableId); dataInfo.setRows(list); @@ -107,8 +103,7 @@ public class GenController extends BaseController @PreAuthorize("@ss.hasPermi('tool:gen:import')") @Log(title = "代码生成", businessType = BusinessType.IMPORT) @PostMapping("/importTable") - public AjaxResult importTableSave(String tables) - { + public AjaxResult importTableSave(@RequestParam("tables") String tables) { String[] tableNames = Convert.toStrArray(tables); // 查询表信息 List tableList = genTableService.selectDbTableListByNames(tableNames); @@ -122,8 +117,7 @@ public class GenController extends BaseController @PreAuthorize("@ss.hasPermi('tool:gen:edit')") @Log(title = "代码生成", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult editSave(@Validated @RequestBody GenTable genTable) - { + public AjaxResult editSave(@Validated @RequestBody GenTable genTable) { genTableService.validateEdit(genTable); genTableService.updateGenTable(genTable); return success(); @@ -135,8 +129,7 @@ public class GenController extends BaseController @PreAuthorize("@ss.hasPermi('tool:gen:remove')") @Log(title = "代码生成", businessType = BusinessType.DELETE) @DeleteMapping("/{tableIds}") - public AjaxResult remove(@PathVariable( name = "tableIds" ) Long[] tableIds) - { + public AjaxResult remove(@PathVariable(name = "tableIds") Long[] tableIds) { genTableService.deleteGenTableByIds(tableIds); return success(); } @@ -146,8 +139,7 @@ public class GenController extends BaseController */ @PreAuthorize("@ss.hasPermi('tool:gen:preview')") @GetMapping("/preview/{tableId}") - public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException - { + public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException { Map dataMap = genTableService.previewCode(tableId); return success(dataMap); } @@ -158,8 +150,7 @@ public class GenController extends BaseController @PreAuthorize("@ss.hasPermi('tool:gen:code')") @Log(title = "代码生成", 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); } @@ -170,8 +161,7 @@ public class GenController extends BaseController @PreAuthorize("@ss.hasPermi('tool:gen:code')") @Log(title = "代码生成", businessType = BusinessType.GENCODE) @GetMapping("/genCode/{tableName}") - public AjaxResult genCode(@PathVariable("tableName") String tableName) - { + public AjaxResult genCode(@PathVariable("tableName") String tableName) { genTableService.generatorCode(tableName); return success(); } @@ -182,8 +172,7 @@ public class GenController extends BaseController @PreAuthorize("@ss.hasPermi('tool:gen:edit')") @Log(title = "代码生成", businessType = BusinessType.UPDATE) @GetMapping("/synchDb/{tableName}") - public AjaxResult synchDb(@PathVariable("tableName") String tableName) - { + public AjaxResult synchDb(@PathVariable("tableName") String tableName) { genTableService.synchDb(tableName); return success(); } @@ -194,8 +183,8 @@ public class GenController extends BaseController @PreAuthorize("@ss.hasPermi('tool:gen:code')") @Log(title = "代码生成", businessType = BusinessType.GENCODE) @GetMapping("/batchGenCode") - public void batchGenCode(HttpServletResponse response, String tables) throws IOException - { + public void batchGenCode(HttpServletResponse response, @RequestParam(name = "tables") String tables) + throws IOException { String[] tableNames = Convert.toStrArray(tables); byte[] data = genTableService.downloadCode(tableNames); genCode(response, data); @@ -204,8 +193,7 @@ public class GenController extends BaseController /** * 生成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");