修改了数据源的相关方法

This commit is contained in:
root 2025-04-02 14:30:18 +08:00
parent 0d5adf9d8e
commit 5128489bd7
6 changed files with 13 additions and 5 deletions

View File

@ -76,7 +76,6 @@ public class ApplicationServiceImpl extends ServiceImpl<ApplicationMapper, Appli
throw new RuntimeException("创建应用失败", e); throw new RuntimeException("创建应用失败", e);
} }
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean removeById(String id) { public boolean removeById(String id) {

View File

@ -13,6 +13,8 @@ public class DataSourceNodePO implements Serializable {
@TableId @TableId
private Long id; private Long id;
private String appId;
private Long pid; private Long pid;
private String name; private String name;

View File

@ -20,6 +20,7 @@ public class DatasourceNodeBO implements TreeBaseModel<DatasourceNodeBO> {
@JsonSerialize(using = ToStringSerializer.class) @JsonSerialize(using = ToStringSerializer.class)
private Long id; private Long id;
private String appId;
private String name; private String name;
private Boolean leaf; private Boolean leaf;
private Integer weight = 3; private Integer weight = 3;

View File

@ -41,8 +41,8 @@ public class DataSourceManage {
private CoreDatasourceExtMapper coreDatasourceExtMapper; private CoreDatasourceExtMapper coreDatasourceExtMapper;
@Resource @Resource
private CoreOptRecentManage coreOptRecentManage; private CoreOptRecentManage coreOptRecentManage;
private DatasourceNodeBO rootNode() { private DatasourceNodeBO rootNode(String appId) {
return new DatasourceNodeBO(0L, "root", false, 7, -1L, 0, "mysql"); return new DatasourceNodeBO(0L,appId, "root", false, 7, -1L, 0, "mysql");
} }
private DatasourceNodeBO convert(DataSourceNodePO po) { private DatasourceNodeBO convert(DataSourceNodePO po) {
@ -52,7 +52,7 @@ public class DataSourceManage {
} }
Integer flag = dataSourceType.getFlag(); Integer flag = dataSourceType.getFlag();
int extraFlag = StringUtils.equalsIgnoreCase("error", po.getStatus()) ? Math.negateExact(flag) : flag; int extraFlag = StringUtils.equalsIgnoreCase("error", po.getStatus()) ? Math.negateExact(flag) : flag;
return new DatasourceNodeBO(po.getId(), po.getName(), !StringUtils.equals(po.getType(), "folder"), 9, po.getPid(), extraFlag, dataSourceType.name()); return new DatasourceNodeBO(po.getId(), po.getAppId(), po.getName(), !StringUtils.equals(po.getType(), "folder"), 9, po.getPid(), extraFlag, dataSourceType.name());
} }
@ -62,6 +62,9 @@ public class DataSourceManage {
if (ObjectUtils.isNotEmpty(request.getLeaf()) && !request.getLeaf()) { if (ObjectUtils.isNotEmpty(request.getLeaf()) && !request.getLeaf()) {
queryWrapper.eq("type", "folder"); queryWrapper.eq("type", "folder");
} }
if (ObjectUtils.isNotEmpty(request.getAppId())) {
queryWrapper.eq("app_id", request.getAppId());
}
String info = CommunityUtils.getInfo(); String info = CommunityUtils.getInfo();
if (StringUtils.isNotBlank(info)) { if (StringUtils.isNotBlank(info)) {
queryWrapper.notExists(String.format(info, "core_datasource.id")); queryWrapper.notExists(String.format(info, "core_datasource.id"));
@ -69,7 +72,7 @@ public class DataSourceManage {
queryWrapper.orderByDesc("create_time"); queryWrapper.orderByDesc("create_time");
List<DatasourceNodeBO> nodes = new ArrayList<>(); List<DatasourceNodeBO> nodes = new ArrayList<>();
List<DataSourceNodePO> pos = dataSourceExtMapper.selectList(queryWrapper); List<DataSourceNodePO> pos = dataSourceExtMapper.selectList(queryWrapper);
if (ObjectUtils.isEmpty(request.getLeaf()) || !request.getLeaf()) nodes.add(rootNode()); if (ObjectUtils.isEmpty(request.getLeaf()) || !request.getLeaf()) nodes.add(rootNode(request.getAppId()));
if (CollectionUtils.isNotEmpty(pos)) { if (CollectionUtils.isNotEmpty(pos)) {
nodes.addAll(pos.stream().map(this::convert).toList()); nodes.addAll(pos.stream().map(this::convert).toList());
} }

View File

@ -243,6 +243,7 @@ public class DatasourceServer implements DatasourceApi {
} }
preCheckDs(dataSourceDTO); preCheckDs(dataSourceDTO);
dataSourceDTO.setId(IDUtils.snowID()); dataSourceDTO.setId(IDUtils.snowID());
dataSourceDTO.setAppId(busiDsRequest.getAppId()); //补充了项目ID
dataSourceDTO.setCreateTime(System.currentTimeMillis()); dataSourceDTO.setCreateTime(System.currentTimeMillis());
dataSourceDTO.setUpdateTime(System.currentTimeMillis()); dataSourceDTO.setUpdateTime(System.currentTimeMillis());
try { try {

View File

@ -14,6 +14,8 @@ public class BusiNodeRequest implements Serializable {
private String id; private String id;
private String appId;
private Boolean leaf; private Boolean leaf;
private Integer weight; private Integer weight;