From 5be90b09bd999cd380cf13acbbf09ed7246a9cc3 Mon Sep 17 00:00:00 2001 From: shikeyin <pxzsky@163.com> Date: 星期三, 17 一月 2024 14:40:13 +0800 Subject: [PATCH] 添加mybatis支持 2 --- iplatform-base-admin/src/main/java/com/iplatform/base/controller/GenController.java | 55 +++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 35 insertions(+), 20 deletions(-) diff --git a/iplatform-base-admin/src/main/java/com/iplatform/base/controller/GenController.java b/iplatform-base-admin/src/main/java/com/iplatform/base/controller/GenController.java index 9d59fed..1c557bc 100644 --- a/iplatform-base-admin/src/main/java/com/iplatform/base/controller/GenController.java +++ b/iplatform-base-admin/src/main/java/com/iplatform/base/controller/GenController.java @@ -1,17 +1,16 @@ package com.iplatform.base.controller; -import com.insurance.common.annotation.Log; -import com.insurance.common.core.domain.AjaxResult; -import com.insurance.common.core.page.TableDataInfo; -import com.insurance.common.enums.BusinessType; import com.iplatform.base.SystemController; import com.iplatform.core.util.Convert; import com.iplatform.mybatis.domain.GenTable; import com.iplatform.mybatis.domain.GenTableColumn; +import com.iplatform.mybatis.domain.TableDataInfo; import com.iplatform.mybatis.service.IGenTableColumnService; import com.iplatform.mybatis.service.IGenTableService; +import com.walker.web.ResponseValue; import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -41,7 +40,7 @@ */ //@Api(value = "浠g爜鐢熸垚绠$悊", tags = {"浠g爜鐢熸垚绠$悊"}) @RestController -@RequestMapping("/tool/gen") +@RequestMapping("/tool/generate") public class GenController extends SystemController { @Autowired @@ -67,7 +66,7 @@ */ // @PreAuthorize("@ss.hasPermi('tool:gen:query')") @GetMapping(value = "/{tableId}") - public AjaxResult getInfo(@PathVariable Long tableId) + public ResponseValue getInfo(@PathVariable Long tableId) { GenTable table = genTableService.selectGenTableById(tableId); List<GenTable> tables = genTableService.selectGenTableAll(); @@ -76,7 +75,8 @@ map.put("info", table); map.put("rows", list); map.put("tables", tables); - return success(map); +// return success(map); + return ResponseValue.success(map); } /** @@ -111,13 +111,13 @@ // @PreAuthorize("@ss.hasPermi('tool:gen:import')") // @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.IMPORT) @PostMapping("/importTable") - public AjaxResult importTableSave(String tables) + public ResponseValue importTableSave(String tables) { String[] tableNames = Convert.toStrArray(tables); // 鏌ヨ琛ㄤ俊鎭� List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames); genTableService.importGenTable(tableList); - return success(); + return ResponseValue.success(); } /** @@ -126,11 +126,11 @@ // @PreAuthorize("@ss.hasPermi('tool:gen:edit')") // @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult editSave(@Validated @RequestBody GenTable genTable) + public ResponseValue editSave(@Validated @RequestBody GenTable genTable) { genTableService.validateEdit(genTable); genTableService.updateGenTable(genTable); - return success(); + return ResponseValue.success(); } /** @@ -139,10 +139,10 @@ // @PreAuthorize("@ss.hasPermi('tool:gen:remove')") // @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.DELETE) @DeleteMapping("/{tableIds}") - public AjaxResult remove(@PathVariable Long[] tableIds) + public ResponseValue remove(@PathVariable Long[] tableIds) { genTableService.deleteGenTableByIds(tableIds); - return success(); + return ResponseValue.success(); } /** @@ -150,17 +150,17 @@ */ // @PreAuthorize("@ss.hasPermi('tool:gen:preview')") @GetMapping("/preview/{tableId}") - public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException + public ResponseValue preview(@PathVariable("tableId") Long tableId) throws IOException { Map<String, String> dataMap = genTableService.previewCode(tableId); - return success(dataMap); + return ResponseValue.success(dataMap); } /** * 鐢熸垚浠g爜锛堜笅杞芥柟寮忥級 */ // @PreAuthorize("@ss.hasPermi('tool:gen:code')") - @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.GENCODE) +// @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.GENCODE) @GetMapping("/download/{tableName}") public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException { @@ -174,10 +174,10 @@ // @PreAuthorize("@ss.hasPermi('tool:gen:code')") // @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.GENCODE) @GetMapping("/genCode/{tableName}") - public AjaxResult genCode(@PathVariable("tableName") String tableName) + public ResponseValue genCode(@PathVariable("tableName") String tableName) { genTableService.generatorCode(tableName); - return success(); + return ResponseValue.success(); } /** @@ -186,10 +186,10 @@ // @PreAuthorize("@ss.hasPermi('tool:gen:edit')") // @Log(title = "浠g爜鐢熸垚", businessType = BusinessType.UPDATE) @GetMapping("/synchDb/{tableName}") - public AjaxResult synchDb(@PathVariable("tableName") String tableName) + public ResponseValue synchDb(@PathVariable("tableName") String tableName) { genTableService.synchDb(tableName); - return success(); + return ResponseValue.success(); } /** @@ -218,4 +218,19 @@ response.setContentType("application/octet-stream; charset=UTF-8"); IOUtils.write(data, response.getOutputStream()); } + + /** + * 鍝嶅簲璇锋眰鍒嗛〉鏁版嵁 + */ + @SuppressWarnings({ "rawtypes"}) + protected TableDataInfo getDataTable(List<?> list) + { + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(HttpStatus.OK.value()); + rspData.setMsg("鏌ヨ鎴愬姛"); + rspData.setRows(list); +// rspData.setTotal(page.getTotal()); + rspData.setTotal(0); + return rspData; + } } -- Gitblit v1.9.1