mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 04:39:00 +08:00
♻️ 代码生成后端API调整
(cherry picked from commit a3b8798eb39537a32f89371a949a0a80b37110b9)
This commit is contained in:
1 parent
b4db53891d
commit
2e06c03e57
3 files changed
+76
No files matched your search
+34
@@ -25,6 +25,7 @@ import com.pig4cloud.pigx.codegen.service.GenTableColumnService;
|
||||
import com.pig4cloud.pigx.codegen.service.GenTableService;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -76,6 +77,16 @@ public class GenTableController {
|
||||
return R.ok(tableService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据源所有表
|
||||
*
|
||||
* @param dsName 数据源
|
||||
*/
|
||||
@GetMapping("/list/{dsName}")
|
||||
public R listTable(@PathVariable("dsName") String dsName) {
|
||||
return R.ok(tableService.queryTableList(dsName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表信息
|
||||
*
|
||||
@@ -94,6 +105,17 @@ public class GenTableController {
|
||||
* @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));
|
||||
}
|
||||
@@ -117,6 +139,18 @@ public class GenTableController {
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改表字段数据
|
||||
*
|
||||
|
||||
+15
@@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.pig4cloud.pigx.codegen.entity.GenTable;
|
||||
import org.anyline.metadata.Table;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -66,4 +67,18 @@ public interface GenTableService extends IService<GenTable> {
|
||||
*/
|
||||
String queryTableDdl(String dsName, String tableName) throws Exception;
|
||||
|
||||
/**
|
||||
* 查询数据源里面的全部表
|
||||
* @param dsName 数据源名称
|
||||
* @return table
|
||||
*/
|
||||
List<String> queryTableList(String dsName);
|
||||
|
||||
/**
|
||||
* 查询表的全部字段
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
* @return column
|
||||
*/
|
||||
List<String> queryTableColumn(String dsName, String tableName);
|
||||
}
|
||||
+27
@@ -99,6 +99,20 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> i
|
||||
return table.getDdl();// 返回创建表的DDL
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询表的全部字段
|
||||
*
|
||||
* @param dsName 数据源
|
||||
* @param tableName 表名称
|
||||
* @return column
|
||||
*/
|
||||
@Override
|
||||
public List<String> queryTableColumn(String dsName, String tableName) {
|
||||
// 手动切换数据源
|
||||
DynamicDataSourceContextHolder.push(dsName);
|
||||
return ServiceProxy.metadata().columns(tableName).values().stream().map(Column::getName).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询对应数据源的表
|
||||
*
|
||||
@@ -125,6 +139,19 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> i
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据源里面的全部表
|
||||
*
|
||||
* @param dsName 数据源名称
|
||||
* @return table
|
||||
*/
|
||||
@Override
|
||||
public List<String> queryTableList(String dsName) {
|
||||
// 手动切换数据源
|
||||
DynamicDataSourceContextHolder.push(dsName);
|
||||
return ServiceProxy.metadata().tables().values().stream().map(Table::getName).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询表信息(列),然后插入到中间表中
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user