|
|
@@ -2,6 +2,8 @@ package cc.iotkit.generator.controller;
|
|
|
|
|
|
import cc.iotkit.common.api.PageRequest;
|
|
|
import cc.iotkit.common.api.Paging;
|
|
|
+import cc.iotkit.common.api.Request;
|
|
|
+import cc.iotkit.generator.dto.bo.ImportTableBo;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.io.IoUtil;
|
|
|
|
|
|
@@ -13,6 +15,7 @@ import cc.iotkit.generator.domain.GenTable;
|
|
|
import cc.iotkit.generator.domain.GenTableColumn;
|
|
|
import cc.iotkit.generator.service.IGenTableService;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@@ -50,11 +53,12 @@ public class GenController extends BaseController {
|
|
|
/**
|
|
|
* 修改代码生成业务
|
|
|
*
|
|
|
- * @param tableId 表ID
|
|
|
*/
|
|
|
// @SaCheckPermission("tool:gen:query")
|
|
|
- @PostMapping(value = "/{tableId}")
|
|
|
- public Map<String, Object> getInfo(@PathVariable Long tableId) {
|
|
|
+ @ApiOperation(value = "修改代码生成业务", notes = "修改代码生成业务详情")
|
|
|
+ @PostMapping(value = "/getDetail")
|
|
|
+ public Map<String, Object> getInfo(@Validated @RequestBody Request<Long> bo) {
|
|
|
+ Long tableId = bo.getData();
|
|
|
GenTable table = genTableService.selectGenTableById(tableId);
|
|
|
List<GenTable> tables = genTableService.selectGenTableAll();
|
|
|
List<GenTableColumn> list = genTableService.selectGenTableColumnListByTableId(tableId);
|
|
|
@@ -69,6 +73,7 @@ public class GenController extends BaseController {
|
|
|
* 查询数据库列表
|
|
|
*/
|
|
|
// @SaCheckPermission("tool:gen:list")
|
|
|
+ @ApiOperation(value = "查询数据库列表", notes = "查询数据库列表")
|
|
|
@PostMapping("/db/list")
|
|
|
public Paging<GenTable> dataList(@RequestBody @Validated PageRequest<GenTable> pageQuery) {
|
|
|
return genTableService.selectPageDbTableList( pageQuery);
|
|
|
@@ -80,6 +85,7 @@ public class GenController extends BaseController {
|
|
|
* @param tableId 表ID
|
|
|
*/
|
|
|
// @SaCheckPermission("tool:gen:list")
|
|
|
+ @ApiOperation(value = "查询数据表字段列表", notes = "查询数据表字段列表")
|
|
|
@PostMapping(value = "/column/{tableId}")
|
|
|
public Paging<GenTableColumn> columnList(Long tableId) {
|
|
|
|
|
|
@@ -91,15 +97,16 @@ public class GenController extends BaseController {
|
|
|
/**
|
|
|
* 导入表结构(保存)
|
|
|
*
|
|
|
- * @param tables 表名串
|
|
|
*/
|
|
|
// @SaCheckPermission("tool:gen:import")
|
|
|
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
|
|
@PostMapping("/importTable")
|
|
|
- public void importTableSave(String tables) {
|
|
|
- String[] tableNames = Convert.toStrArray(tables);
|
|
|
+ @ApiOperation(value = "导入表结构(保存)", notes = "导入表结构(保存)")
|
|
|
+ public void importTableSave(@Validated @RequestBody Request<ImportTableBo> bo) {
|
|
|
+ List<String> tables = bo.getData().getTables();
|
|
|
+
|
|
|
// 查询表信息
|
|
|
- List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
|
|
|
+ List<GenTable> tableList = genTableService.selectDbTableListByNames(tables);
|
|
|
genTableService.importGenTable(tableList);
|
|
|
return;
|
|
|
}
|
|
|
@@ -108,9 +115,11 @@ public class GenController extends BaseController {
|
|
|
* 修改保存代码生成业务
|
|
|
*/
|
|
|
// @SaCheckPermission("tool:gen:edit")
|
|
|
+ @ApiOperation(value = "修改保存代码生成业务", notes = "修改保存代码生成业务")
|
|
|
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
|
|
- @PutMapping
|
|
|
- public void editSave(@Validated @RequestBody GenTable genTable) {
|
|
|
+ @PostMapping("/edit")
|
|
|
+ public void editSave(@Validated @RequestBody Request<GenTable> bo) {
|
|
|
+ GenTable genTable = bo.getData();
|
|
|
genTableService.validateEdit(genTable);
|
|
|
genTableService.updateGenTable(genTable);
|
|
|
return;
|
|
|
@@ -119,25 +128,26 @@ public class GenController extends BaseController {
|
|
|
/**
|
|
|
* 删除代码生成
|
|
|
*
|
|
|
- * @param tableIds 表ID串
|
|
|
+
|
|
|
*/
|
|
|
// @SaCheckPermission("tool:gen:remove")
|
|
|
@Log(title = "代码生成", businessType = BusinessType.DELETE)
|
|
|
- @DeleteMapping("/{tableIds}")
|
|
|
- public void remove(@PathVariable Long[] tableIds) {
|
|
|
- genTableService.deleteGenTableByIds(tableIds);
|
|
|
+ @PostMapping("/delete")
|
|
|
+ @ApiOperation(value = "删除代码生成", notes = "删除代码生成")
|
|
|
+ public void remove(@Validated @RequestBody Request<List<Long>> bo) {
|
|
|
+ genTableService.deleteGenTableByIds(bo.getData());
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 预览代码
|
|
|
*
|
|
|
- * @param tableId 表ID
|
|
|
*/
|
|
|
// @SaCheckPermission("tool:gen:preview")
|
|
|
- @PostMapping("/preview/{tableId}")
|
|
|
- public Map<String, String> preview(@PathVariable("tableId") Long tableId) throws IOException {
|
|
|
- Map<String, String> dataMap = genTableService.previewCode(tableId);
|
|
|
+ @ApiOperation(value = "预览代码", notes = "预览代码")
|
|
|
+ @PostMapping("/preview")
|
|
|
+ public Map<String, String> preview(@Validated @RequestBody Request<Long> bo) throws IOException {
|
|
|
+ Map<String, String> dataMap = genTableService.previewCode(bo.getData());
|
|
|
return dataMap;
|
|
|
}
|
|
|
|
|
|
@@ -161,6 +171,7 @@ public class GenController extends BaseController {
|
|
|
*/
|
|
|
// @SaCheckPermission("tool:gen:code")
|
|
|
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
|
|
+ @ApiOperation(value = "生成代码(自定义路径)", notes = "生成代码(自定义路径)")
|
|
|
@PostMapping("/genCode/{tableName}")
|
|
|
public void genCode(@PathVariable("tableName") String tableName) {
|
|
|
genTableService.generatorCode(tableName);
|
|
|
@@ -170,13 +181,13 @@ public class GenController extends BaseController {
|
|
|
/**
|
|
|
* 同步数据库
|
|
|
*
|
|
|
- * @param tableName 表名
|
|
|
*/
|
|
|
// @SaCheckPermission("tool:gen:edit")
|
|
|
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
|
|
- @PostMapping("/synchDb/{tableName}")
|
|
|
- public void synchDb(@PathVariable("tableName") String tableName) {
|
|
|
- genTableService.synchDb(tableName);
|
|
|
+ @ApiOperation(value = "同步数据库", notes = "同步数据库")
|
|
|
+ @PostMapping("/synchDb")
|
|
|
+ public void synchDb(@Validated @RequestBody Request<String> bo) {
|
|
|
+ genTableService.synchDb(bo.getData());
|
|
|
return ;
|
|
|
}
|
|
|
|
|
|
@@ -187,6 +198,7 @@ public class GenController extends BaseController {
|
|
|
*/
|
|
|
// @SaCheckPermission("tool:gen:code")
|
|
|
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
|
|
+ @ApiOperation(value = "批量生成代码", notes = "批量生成代码")
|
|
|
@PostMapping("/batchGenCode")
|
|
|
public void batchGenCode(HttpServletResponse response, String tables) throws IOException {
|
|
|
String[] tableNames = Convert.toStrArray(tables);
|