mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 20:49:00 +08:00
feat(gen-table): 批量代码生成支持复用单表的配置信息
This commit is contained in:
1 parent
5123e3f116
commit
0b939f3d57
1 file changed
+122
-107
+122
-107
@@ -48,123 +48,138 @@ import java.util.List;
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class GenTableController {
|
||||
|
||||
private final GenTableColumnService tableColumnService;
|
||||
private final GenTableColumnService tableColumnService;
|
||||
|
||||
private final GenTableService tableService;
|
||||
private final GenTableService tableService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param table 列属性
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
public R getTablePage(Page page, GenTable table) {
|
||||
return R.ok(tableService.queryTablePage(page, table));
|
||||
}
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param table 列属性
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
public R getTablePage(Page page, GenTable table) {
|
||||
return R.ok(tableService.queryTablePage(page, table));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询表信息(代码生成设置 + 表 + 字段设置)
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
public R getTable(@PathVariable("id") Long id) {
|
||||
return R.ok(tableService.getById(id));
|
||||
}
|
||||
/**
|
||||
* 通过id查询表信息(代码生成设置 + 表 + 字段设置)
|
||||
*
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
public R getTable(@PathVariable("id") Long id) {
|
||||
return R.ok(tableService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据源所有表
|
||||
* @param dsName 数据源
|
||||
*/
|
||||
@GetMapping("/list/{dsName}")
|
||||
public R listTable(@PathVariable("dsName") String dsName) {
|
||||
return R.ok(tableService.queryTableList(dsName));
|
||||
}
|
||||
/**
|
||||
* 查询数据源所有表
|
||||
*
|
||||
* @param dsName 数据源
|
||||
*/
|
||||
@GetMapping("/list/{dsName}")
|
||||
public R listTable(@PathVariable("dsName") String dsName) {
|
||||
return R.ok(tableService.queryTableList(dsName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表信息
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
*/
|
||||
@GetMapping("/{dsName}/{tableName}")
|
||||
public R<GenTable> getTable(@PathVariable("dsName") String dsName, @PathVariable String tableName) {
|
||||
return R.ok(tableService.queryOrBuildTable(dsName, tableName));
|
||||
}
|
||||
/**
|
||||
* 获取表信息
|
||||
*
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
*/
|
||||
@GetMapping("/{dsName}/{tableName}")
|
||||
public R<GenTable> getTable(@PathVariable("dsName") String dsName, @PathVariable String tableName) {
|
||||
return R.ok(tableService.queryOrBuildTable(dsName, tableName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询表DDL语句
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
*/
|
||||
@GetMapping("/column/{dsName}/{tableName}")
|
||||
public R getColumn(@PathVariable("dsName") String dsName, @PathVariable String tableName) throws Exception {
|
||||
return R.ok(tableService.queryTableColumn(dsName, tableName));
|
||||
}
|
||||
/**
|
||||
* 查询表DDL语句
|
||||
*
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
*/
|
||||
@GetMapping("/column/{dsName}/{tableName}")
|
||||
public R getColumn(@PathVariable("dsName") String dsName, @PathVariable String tableName) throws Exception {
|
||||
return R.ok(tableService.queryTableColumn(dsName, tableName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询表DDL语句
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
*/
|
||||
@GetMapping("/ddl/{dsName}/{tableName}")
|
||||
public R getDdl(@PathVariable("dsName") String dsName, @PathVariable String tableName) throws Exception {
|
||||
return R.ok(tableService.queryTableDdl(dsName, tableName));
|
||||
}
|
||||
/**
|
||||
* 查询表DDL语句
|
||||
*
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
*/
|
||||
@GetMapping("/ddl/{dsName}/{tableName}")
|
||||
public R getDdl(@PathVariable("dsName") String dsName, @PathVariable String tableName) throws Exception {
|
||||
return R.ok(tableService.queryTableDdl(dsName, tableName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步表信息
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
*/
|
||||
@GetMapping("/sync/{dsName}/{tableName}")
|
||||
public R<GenTable> syncTable(@PathVariable("dsName") String dsName, @PathVariable String tableName) {
|
||||
// 表配置删除
|
||||
tableService.remove(
|
||||
Wrappers.<GenTable>lambdaQuery().eq(GenTable::getDsName, dsName).eq(GenTable::getTableName, tableName));
|
||||
// 字段配置删除
|
||||
tableColumnService.remove(Wrappers.<GenTableColumnEntity>lambdaQuery()
|
||||
.eq(GenTableColumnEntity::getDsName, dsName)
|
||||
.eq(GenTableColumnEntity::getTableName, tableName));
|
||||
return R.ok(tableService.queryOrBuildTable(dsName, tableName));
|
||||
}
|
||||
/**
|
||||
* 同步表信息
|
||||
*
|
||||
* @param dsName 数据源名称
|
||||
* @param tableName 表名称
|
||||
* @param isBatch 是否批量操作
|
||||
* @return 操作结果
|
||||
*/
|
||||
@GetMapping("/sync/{dsName}/{tableName}")
|
||||
public R<GenTable> syncTable(@PathVariable("dsName") String dsName, @PathVariable String tableName, @RequestParam(required = false) boolean isBatch) {
|
||||
// 批量操作同步的时候,不需要删除
|
||||
if (!isBatch) {
|
||||
// 表配置删除
|
||||
tableService.remove(
|
||||
Wrappers.<GenTable>lambdaQuery().eq(GenTable::getDsName, dsName).eq(GenTable::getTableName, tableName));
|
||||
// 字段配置删除
|
||||
tableColumnService.remove(Wrappers.<GenTableColumnEntity>lambdaQuery()
|
||||
.eq(GenTableColumnEntity::getDsName, dsName)
|
||||
.eq(GenTableColumnEntity::getTableName, tableName));
|
||||
}
|
||||
return R.ok(tableService.queryOrBuildTable(dsName, tableName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改列属性
|
||||
* @param table 列属性
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改列属性", description = "修改列属性")
|
||||
@SysLog("修改列属性")
|
||||
@PutMapping
|
||||
public R updateById(@RequestBody GenTable table) {
|
||||
return R.ok(tableService.updateById(table));
|
||||
}
|
||||
/**
|
||||
* 修改列属性
|
||||
*
|
||||
* @param table 列属性
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改列属性", description = "修改列属性")
|
||||
@SysLog("修改列属性")
|
||||
@PutMapping
|
||||
public R updateById(@RequestBody GenTable table) {
|
||||
return R.ok(tableService.updateById(table));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改表字段数据
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
* @param tableFieldList 字段列表
|
||||
*/
|
||||
@PutMapping("/field/{dsName}/{tableName}")
|
||||
public R<String> updateTableField(@PathVariable("dsName") String dsName, @PathVariable String tableName,
|
||||
@RequestBody List<GenTableColumnEntity> tableFieldList) {
|
||||
tableColumnService.updateTableField(dsName, tableName, tableFieldList);
|
||||
return R.ok();
|
||||
}
|
||||
/**
|
||||
* 修改表字段数据
|
||||
*
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
* @param tableFieldList 字段列表
|
||||
*/
|
||||
@PutMapping("/field/{dsName}/{tableName}")
|
||||
public R<String> updateTableField(@PathVariable("dsName") String dsName, @PathVariable String tableName,
|
||||
@RequestBody List<GenTableColumnEntity> tableFieldList) {
|
||||
tableColumnService.updateTableField(dsName, tableName, tableFieldList);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param table 查询条件
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
public List<GenTable> export(GenTable table) {
|
||||
return tableService.list(Wrappers.query(table));
|
||||
}
|
||||
/**
|
||||
* 导出excel 表格
|
||||
*
|
||||
* @param table 查询条件
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
public List<GenTable> export(GenTable table) {
|
||||
return tableService.list(Wrappers.query(table));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user