Merge pull request #11555 from dataease/pr@dev-v2@feat_relation

feat(组织管理中心): 新增血缘关系分析
This commit is contained in:
Junjun 2024-08-14 16:41:21 +08:00 committed by GitHub
commit 715573c256
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 127 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
import io.dataease.api.dataset.union.DatasetGroupInfoDTO; import io.dataease.api.dataset.union.DatasetGroupInfoDTO;
import io.dataease.api.dataset.union.UnionDTO; import io.dataease.api.dataset.union.UnionDTO;
import io.dataease.api.dataset.vo.DataSetBarVO; import io.dataease.api.dataset.vo.DataSetBarVO;
import io.dataease.api.permissions.relation.api.RelationApi;
import io.dataease.commons.constants.OptConstants; import io.dataease.commons.constants.OptConstants;
import io.dataease.dataset.dao.auto.entity.CoreDatasetGroup; import io.dataease.dataset.dao.auto.entity.CoreDatasetGroup;
import io.dataease.dataset.dao.auto.entity.CoreDatasetTable; import io.dataease.dataset.dao.auto.entity.CoreDatasetTable;
@ -35,6 +36,7 @@ import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -43,6 +45,8 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static io.dataease.result.ResultCode.DV_RESOURCE_UNCHECKED;
/** /**
* @Author Junjun * @Author Junjun
*/ */
@ -75,6 +79,9 @@ public class DatasetGroupManage {
@Resource @Resource
private CoreOptRecentManage coreOptRecentManage; private CoreOptRecentManage coreOptRecentManage;
@Autowired(required = false)
private RelationApi relationManage;
private static final String leafType = "dataset"; private static final String leafType = "dataset";
private Lock lock = new ReentrantLock(); private Lock lock = new ReentrantLock();
@ -176,6 +183,21 @@ public class DatasetGroupManage {
return datasetGroupInfoDTO; return datasetGroupInfoDTO;
} }
public boolean perDelete(Long id) {
if (LicenseUtil.licenseValid()) {
try {
relationManage.checkAuth();
} catch (Exception e) {
return false;
}
Long count = relationManage.getDatasetResource(id);
if (count > 0) {
return true;
}
}
return false;
}
@XpackInteract(value = "authResourceTree", before = false) @XpackInteract(value = "authResourceTree", before = false)
public void delete(Long id) { public void delete(Long id) {
CoreDatasetGroup coreDatasetGroup = coreDatasetGroupMapper.selectById(id); CoreDatasetGroup coreDatasetGroup = coreDatasetGroupMapper.selectById(id);

View File

@ -49,6 +49,11 @@ public class DatasetTreeServer implements DatasetTreeApi {
return datasetGroupManage.move(dto); return datasetGroupManage.move(dto);
} }
@Override
public boolean perDelete(Long id) {
return datasetGroupManage.perDelete(id);
}
@DeLog(id = "#p0", ot = LogOT.DELETE, st = LogST.DATASET) @DeLog(id = "#p0", ot = LogOT.DELETE, st = LogST.DATASET)
@Override @Override
public void delete(Long id) { public void delete(Long id) {

View File

@ -13,6 +13,7 @@ import io.dataease.api.ds.vo.ApiDefinition;
import io.dataease.api.ds.vo.CoreDatasourceTaskLogDTO; import io.dataease.api.ds.vo.CoreDatasourceTaskLogDTO;
import io.dataease.api.ds.vo.ExcelFileData; import io.dataease.api.ds.vo.ExcelFileData;
import io.dataease.api.ds.vo.ExcelSheetData; import io.dataease.api.ds.vo.ExcelSheetData;
import io.dataease.api.permissions.relation.api.RelationApi;
import io.dataease.commons.constants.TaskStatus; import io.dataease.commons.constants.TaskStatus;
import io.dataease.constant.LogOT; import io.dataease.constant.LogOT;
import io.dataease.constant.LogST; import io.dataease.constant.LogST;
@ -69,6 +70,7 @@ import java.util.stream.Collectors;
import static io.dataease.datasource.server.DatasourceTaskServer.ScheduleType.MANUAL; import static io.dataease.datasource.server.DatasourceTaskServer.ScheduleType.MANUAL;
import static io.dataease.datasource.server.DatasourceTaskServer.ScheduleType.RIGHTNOW; import static io.dataease.datasource.server.DatasourceTaskServer.ScheduleType.RIGHTNOW;
import static io.dataease.result.ResultCode.DS_RESOURCE_UNCHECKED;
@RestController @RestController
@ -106,6 +108,8 @@ public class DatasourceServer implements DatasourceApi {
@Autowired(required = false) @Autowired(required = false)
private PluginManageApi pluginManage; private PluginManageApi pluginManage;
@Autowired(required = false)
private RelationApi relationManage;
@Override @Override
public List<DatasourceDTO> query(String keyWord) { public List<DatasourceDTO> query(String keyWord) {
@ -627,6 +631,22 @@ public class DatasourceServer implements DatasourceApi {
return datasourceDTO; return datasourceDTO;
} }
@Override
public boolean perDelete(Long id) {
if (LicenseUtil.licenseValid()) {
try {
relationManage.checkAuth();
} catch (Exception e) {
return false;
}
Long count = relationManage.getDsResource(id);
if (count > 0) {
return true;
}
}
return false;
}
@Transactional @Transactional
@DeLog(id = "#p0", ot = LogOT.DELETE, st = LogST.DATASOURCE) @DeLog(id = "#p0", ot = LogOT.DELETE, st = LogST.DATASOURCE)
@Override @Override

View File

@ -94,4 +94,6 @@ public class SQLConstants {
public static final String QUARTER = "QUARTER(%s)"; public static final String QUARTER = "QUARTER(%s)";
public static final String EMPTY_SIGN = "_empty_$"; public static final String EMPTY_SIGN = "_empty_$";
public static final String CONCAT = "CONCAT(%s, %s)";
} }

View File

@ -60,6 +60,10 @@ public interface DatasetTreeApi {
@PostMapping("move") @PostMapping("move")
DatasetNodeDTO move(@RequestBody DatasetGroupInfoDTO dto) throws Exception; DatasetNodeDTO move(@RequestBody DatasetGroupInfoDTO dto) throws Exception;
@DePermit({"#p0+':manage'"})
@PostMapping("perDelete/{id}")
boolean perDelete(@PathVariable("id") Long id);
@Operation(summary = "删除数据集") @Operation(summary = "删除数据集")
@DePermit({"#p0+':manage'"}) @DePermit({"#p0+':manage'"})
@PostMapping("delete/{id}") @PostMapping("delete/{id}")

View File

@ -66,6 +66,10 @@ public interface DatasourceApi {
@GetMapping("/validate/{datasourceId}") @GetMapping("/validate/{datasourceId}")
DatasourceDTO validate(@PathVariable("datasourceId") Long datasourceId) throws DEException; DatasourceDTO validate(@PathVariable("datasourceId") Long datasourceId) throws DEException;
@DePermit({"#p0+':manage'"})
@PostMapping("/perDelete/{datasourceId}")
boolean perDelete(@PathVariable("datasourceId") Long datasourceId);
@DePermit({"#p0+':manage'"}) @DePermit({"#p0+':manage'"})
@GetMapping("/delete/{datasourceId}") @GetMapping("/delete/{datasourceId}")
void delete(@PathVariable("datasourceId") Long datasourceId) throws DEException; void delete(@PathVariable("datasourceId") Long datasourceId) throws DEException;

View File

@ -0,0 +1,14 @@
package io.dataease.api.permissions.relation.api;
import io.dataease.exception.DEException;
/**
* @Author Junjun
*/
public interface RelationApi {
Long getDsResource(Long id);
Long getDatasetResource(Long id);
void checkAuth() throws DEException;
}

View File

@ -0,0 +1,22 @@
package io.dataease.api.permissions.relation.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import java.util.List;
/**
* @Author Junjun
*/
@Data
public class RelationDTO {
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
private String name;
private String auths;
private String type;
private String creator;
private Long updateTime;
private List<RelationDTO> subRelation;
}

View File

@ -0,0 +1,31 @@
package io.dataease.api.permissions.relation.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @Author Junjun
*/
@Data
public class RelationListDTO implements Serializable {
private Long dsId;
private String dsName;
private String dsCreator;
private Long dsUpdateTime;
private Long datasetId;
private String datasetName;
private String datasetCreator;
private Long datasetUpdateTime;
private Long dashboardId;
private String dashboardName;
private String dashboardCreator;
private Long dashboardUpdateTime;
private Long dvId;
private String dvName;
private String dvCreator;
private Long dvUpdateTime;
}

View File

@ -27,6 +27,9 @@ public enum ResultCode {
RESULE_DATA_NONE(50001, "数据未找到"), RESULE_DATA_NONE(50001, "数据未找到"),
DATA_IS_WRONG(50002, "数据有误"), DATA_IS_WRONG(50002, "数据有误"),
DATA_ALREADY_EXISTED(50003, "数据已存在"), DATA_ALREADY_EXISTED(50003, "数据已存在"),
DS_RESOURCE_UNCHECKED(50004, "%s个数据集正在使用此数据源无法删除"),
DV_RESOURCE_UNCHECKED(50004, "%s个仪表板或数据大屏正在使用此数据集无法删除"),
/* 接口错误60001-69999 */ /* 接口错误60001-69999 */
INTERFACE_INNER_INVOKE_ERROR(60001, "内部系统接口调用异常"), INTERFACE_INNER_INVOKE_ERROR(60001, "内部系统接口调用异常"),