bug 修改

This commit is contained in:
D 2024-01-12 01:13:35 +08:00
parent 66fdc286de
commit 1d2a8c608d

View File

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