fix: 部分接口请求参数不准确

This commit is contained in:
taojinlong 2024-09-11 15:00:11 +08:00
parent 2a84294329
commit da192d8810
4 changed files with 291 additions and 206 deletions

View File

@ -9,10 +9,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.dataease.api.dataset.dto.PreviewSqlDTO;
import io.dataease.api.ds.DatasourceApi;
import io.dataease.api.ds.vo.ApiDefinition;
import io.dataease.api.ds.vo.CoreDatasourceTaskLogDTO;
import io.dataease.api.ds.vo.ExcelFileData;
import io.dataease.api.ds.vo.ExcelSheetData;
import io.dataease.api.ds.vo.*;
import io.dataease.api.permissions.relation.api.RelationApi;
import io.dataease.commons.constants.TaskStatus;
import io.dataease.constant.LogOT;
@ -92,7 +89,6 @@ public class DatasourceServer implements DatasourceApi {
@Resource
private TaskLogExtMapper taskLogExtMapper;
private static final ObjectMapper objectMapper = new ObjectMapper();
@Resource
private DataSourceManage dataSourceManage;
@Resource
@ -103,61 +99,32 @@ public class DatasourceServer implements DatasourceApi {
private CoreDsFinishPageMapper coreDsFinishPageMapper;
@Resource
private DatasetDataManage datasetDataManage;
@Resource
private ScheduleManager scheduleManager;
@Resource
private CoreUserManage coreUserManage;
@Autowired(required = false)
private PluginManageApi pluginManage;
@Autowired(required = false)
private RelationApi relationManage;
public enum UpdateType {
all_scope, add_scope
}
private TypeReference<List<ApiDefinition>> listTypeReference = new TypeReference<List<ApiDefinition>>() {
};
@Resource
private CommonThreadPool commonThreadPool;
private boolean isUpdatingStatus = false;
private static List<Long> syncDsIds = new ArrayList<>();
@Override
public List<DatasourceDTO> query(String keyWord) {
return null;
}
public enum UpdateType {
all_scope, add_scope
}
private TypeReference<List<ApiDefinition>> listTypeReference = new TypeReference<List<ApiDefinition>>() {
};
@Resource
private CommonThreadPool commonThreadPool;
private boolean isUpdatingStatus = false;
private static List<Long> syncDsIds = new ArrayList<>();
private void getParents(Long pid, List<Long> ids) {
CoreDatasource parent = datasourceMapper.selectById(pid);// 查找父级folder
ids.add(parent.getId());
if (parent.getPid() != null && parent.getPid() != 0) {
getParents(parent.getPid(), ids);
}
}
private void filterDs(List<BusiNodeVO> busiNodeVOS, List<Long> ids, String type, Long id) {
for (BusiNodeVO busiNodeVO : busiNodeVOS) {
if (busiNodeVO.getType() != null && busiNodeVO.getType().equalsIgnoreCase(type)) {
if (id != null) {
if (!busiNodeVO.getId().equals(id)) {
ids.add(busiNodeVO.getId());
}
} else {
ids.add(busiNodeVO.getId());
}
}
if (CollectionUtils.isNotEmpty(busiNodeVO.getChildren())) {
filterDs(busiNodeVO.getChildren(), ids, type, id);
}
}
}
public boolean checkRepeat(@RequestBody DatasourceDTO dataSourceDTO) {
public boolean checkRepeat(@RequestBody BusiDsRequest dataSourceDTO) {
if (Arrays.asList("API", "Excel", "folder").contains(dataSourceDTO.getType())) {
return false;
}
@ -211,7 +178,9 @@ public class DatasourceServer implements DatasourceApi {
@DeLog(id = "#p0.id", ot = LogOT.MODIFY, st = LogST.DATASOURCE)
@Transactional
public DatasourceDTO move(DatasourceDTO dataSourceDTO) {
public DatasourceDTO move(BusiDsRequest busiDsRequest) {
DatasourceDTO dataSourceDTO = new DatasourceDTO();
BeanUtils.copyBean(dataSourceDTO, busiDsRequest);
if (dataSourceDTO.getPid() == null) {
DEException.throwException("目录必选!");
}
@ -230,7 +199,9 @@ public class DatasourceServer implements DatasourceApi {
}
@Transactional
public DatasourceDTO reName(DatasourceDTO dataSourceDTO) {
public DatasourceDTO reName(BusiDsRequest busiDsRequest) {
DatasourceDTO dataSourceDTO = new DatasourceDTO();
BeanUtils.copyBean(dataSourceDTO, busiDsRequest);
if (StringUtils.isEmpty(dataSourceDTO.getName())) {
DEException.throwException("名称不能为空!");
}
@ -243,7 +214,9 @@ public class DatasourceServer implements DatasourceApi {
@DeLog(id = "#p0.id", pid = "#p0.pid", ot = LogOT.CREATE, st = LogST.DATASOURCE)
@Transactional
public DatasourceDTO createFolder(DatasourceDTO dataSourceDTO) {
public DatasourceDTO createFolder(BusiDsRequest busiDsRequest) {
DatasourceDTO dataSourceDTO = new DatasourceDTO();
BeanUtils.copyBean(dataSourceDTO, busiDsRequest);
dataSourceDTO.setCreateTime(System.currentTimeMillis());
dataSourceDTO.setUpdateTime(System.currentTimeMillis());
dataSourceDTO.setType(dataSourceDTO.getNodeType());
@ -256,9 +229,11 @@ public class DatasourceServer implements DatasourceApi {
@DeLog(id = "#p0.id", pid = "#p0.pid", ot = LogOT.CREATE, st = LogST.DATASOURCE)
@Transactional
@Override
public DatasourceDTO save(DatasourceDTO dataSourceDTO) throws DEException {
public DatasourceDTO save(BusiDsRequest busiDsRequest) throws DEException {
DatasourceDTO dataSourceDTO = new DatasourceDTO();
BeanUtils.copyBean(dataSourceDTO, busiDsRequest);
if (dataSourceDTO.getId() != null && dataSourceDTO.getId() > 0) {
return update(dataSourceDTO);
return update(busiDsRequest);
}
if (StringUtils.isNotEmpty(dataSourceDTO.getConfiguration())) {
dataSourceDTO.setConfiguration(new String(Base64.getDecoder().decode(dataSourceDTO.getConfiguration())));
@ -337,10 +312,12 @@ public class DatasourceServer implements DatasourceApi {
@DeLog(id = "#p0.id", ot = LogOT.MODIFY, st = LogST.DATASOURCE)
@Transactional
@Override
public DatasourceDTO update(DatasourceDTO dataSourceDTO) throws DEException {
public DatasourceDTO update(BusiDsRequest busiDsRequest) throws DEException {
DatasourceDTO dataSourceDTO = new DatasourceDTO();
BeanUtils.copyBean(dataSourceDTO, busiDsRequest);
Long pk = null;
if (ObjectUtils.isEmpty(pk = dataSourceDTO.getId())) {
return save(dataSourceDTO);
return save(busiDsRequest);
}
DatasourceDTO sourceData = dataSourceManage.getDs(pk);
dataSourceDTO.setConfiguration(new String(Base64.getDecoder().decode(dataSourceDTO.getConfiguration())));
@ -461,35 +438,6 @@ public class DatasourceServer implements DatasourceApi {
return dataSourceDTO;
}
private static void checkParams(String configurationStr) {
DatasourceConfiguration configuration = JsonUtil.parseObject(configurationStr, DatasourceConfiguration.class);
if (configuration.getInitialPoolSize() < configuration.getMinPoolSize()) {
DEException.throwException("初始连接数不能小于最小连接数!");
}
if (configuration.getInitialPoolSize() > configuration.getMaxPoolSize()) {
DEException.throwException("初始连接数不能大于最大连接数!");
}
if (configuration.getMaxPoolSize() < configuration.getMinPoolSize()) {
DEException.throwException("最大连接数不能小于最小连接数!");
}
if (configuration.getQueryTimeout() < 0) {
DEException.throwException("查询超时不能小于0");
}
}
private static void checkName(List<String> tables) {
for (int i = 0; i < tables.size() - 1; i++) {
for (int j = i + 1; j < tables.size(); j++) {
if (tables.get(i).equalsIgnoreCase(tables.get(j))) {
DEException.throwException(Translator.get("i18n_table_name_repeat") + tables.get(i));
}
}
}
}
private String excelDataTableName(String name) {
return StringUtils.substring(name, 6, name.length() - 11);
}
@Override
public List<DatasourceConfiguration.DatasourceType> datasourceTypes() {
@ -497,7 +445,9 @@ public class DatasourceServer implements DatasourceApi {
}
@Override
public DatasourceDTO validate(DatasourceDTO dataSourceDTO) throws DEException {
public DatasourceDTO validate(BusiDsRequest busiDsRequest) throws DEException {
DatasourceDTO dataSourceDTO = new DatasourceDTO();
BeanUtils.copyBean(dataSourceDTO, busiDsRequest);
dataSourceDTO.setConfiguration(new String(Base64.getDecoder().decode(dataSourceDTO.getConfiguration())));
CoreDatasource coreDatasource = new CoreDatasource();
BeanUtils.copyBean(coreDatasource, dataSourceDTO);
@ -509,7 +459,7 @@ public class DatasourceServer implements DatasourceApi {
}
@Override
public List<String> getSchema(DatasourceDTO dataSourceDTO) throws DEException {
public List<String> getSchema(BusiDsRequest dataSourceDTO) throws DEException {
dataSourceDTO.setConfiguration(new String(Base64.getDecoder().decode(dataSourceDTO.getConfiguration())));
CoreDatasource coreDatasource = new CoreDatasource();
BeanUtils.copyBean(coreDatasource, dataSourceDTO);
@ -563,90 +513,6 @@ public class DatasourceServer implements DatasourceApi {
return list;
}
private DatasourceDTO getDatasourceDTOById(Long datasourceId, boolean hidePw) throws DEException {
CoreDatasource datasource = datasourceMapper.selectById(datasourceId);
if (datasource == null) {
DEException.throwException("不存在的数据源!");
}
return convertCoreDatasource(datasourceId, hidePw, datasource);
}
private DatasourceDTO convertCoreDatasource(Long datasourceId, boolean hidePw, CoreDatasource datasource) {
DatasourceDTO datasourceDTO = new DatasourceDTO();
BeanUtils.copyBean(datasourceDTO, datasource);
if (datasourceDTO.getType().equalsIgnoreCase(DatasourceConfiguration.DatasourceType.API.toString())) {
List<ApiDefinition> apiDefinitionList = JsonUtil.parseList(datasourceDTO.getConfiguration(), listTypeReference);
List<ApiDefinition> apiDefinitionListWithStatus = new ArrayList<>();
List<ApiDefinition> params = new ArrayList<>();
int success = 0;
for (ApiDefinition apiDefinition : apiDefinitionList) {
String status = null;
if (StringUtils.isNotEmpty(datasourceDTO.getStatus())) {
JsonNode jsonNode = null;
try {
jsonNode = objectMapper.readTree(datasourceDTO.getStatus());
} catch (Exception e) {
DEException.throwException(e);
}
for (JsonNode node : jsonNode) {
if (node.get("name").asText().equals(apiDefinition.getName())) {
status = node.get("status").asText();
}
}
apiDefinition.setStatus(status);
}
if (StringUtils.isNotEmpty(status) && status.equalsIgnoreCase("Success")) {
success++;
}
CoreDatasourceTaskLog log = datasourceTaskServer.lastSyncLogForTable(datasourceId, apiDefinition.getDeTableName());
if (log != null) {
apiDefinition.setUpdateTime(log.getStartTime());
}
if (StringUtils.isEmpty(apiDefinition.getType()) || apiDefinition.getType().equalsIgnoreCase("table")) {
apiDefinitionListWithStatus.add(apiDefinition);
} else {
params.add(apiDefinition);
}
}
datasourceDTO.setApiConfigurationStr(new String(Base64.getEncoder().encode(Objects.requireNonNull(JsonUtil.toJSONString(apiDefinitionListWithStatus)).toString().getBytes())));
datasourceDTO.setParamsStr(new String(Base64.getEncoder().encode(Objects.requireNonNull(JsonUtil.toJSONString(params)).toString().getBytes())));
if (success == apiDefinitionList.size()) {
datasourceDTO.setStatus("Success");
} else {
if (success > 0 && success < apiDefinitionList.size()) {
datasourceDTO.setStatus("Warning");
} else {
datasourceDTO.setStatus("Error");
}
}
CoreDatasourceTask coreDatasourceTask = datasourceTaskServer.selectByDSId(datasourceDTO.getId());
TaskDTO taskDTO = new TaskDTO();
BeanUtils.copyBean(taskDTO, coreDatasourceTask);
datasourceDTO.setSyncSetting(taskDTO);
CoreDatasourceTask task = datasourceTaskServer.selectByDSId(datasourceDTO.getId());
if (task != null) {
datasourceDTO.setLastSyncTime(task.getStartTime());
}
} else {
if (hidePw) {
Provider provider = ProviderFactory.getProvider(datasourceDTO.getType());
provider.hidePW(datasourceDTO);
}
}
if (datasourceDTO.getType().equalsIgnoreCase(DatasourceConfiguration.DatasourceType.Excel.toString())) {
datasourceDTO.setFileName(ExcelUtils.getFileName(datasource));
datasourceDTO.setSize(ExcelUtils.getSize(datasource));
}
datasourceDTO.setConfiguration(new String(Base64.getEncoder().encode(datasourceDTO.getConfiguration().getBytes())));
datasourceDTO.setCreator(coreUserManage.getUserName(Long.valueOf(datasourceDTO.getCreateBy())));
return datasourceDTO;
}
@Override
public boolean perDelete(Long id) {
if (LicenseUtil.licenseValid()) {
@ -758,25 +624,6 @@ public class DatasourceServer implements DatasourceApi {
cron, new Date(System.currentTimeMillis()), null, new JobDataMap());
}
private DatasourceDTO validate(CoreDatasource coreDatasource) {
DatasourceDTO datasourceDTO = new DatasourceDTO();
BeanUtils.copyBean(datasourceDTO, coreDatasource);
try {
checkDatasourceStatus(datasourceDTO);
if (!Arrays.asList("API", "Excel", "folder").contains(coreDatasource.getType())) {
calciteProvider.updateDsPoolAfterCheckStatus(datasourceDTO);
}
} catch (Exception e) {
coreDatasource.setStatus("Error");
DEException.throwException(e.getMessage());
} finally {
coreDatasource.setStatus(datasourceDTO.getStatus());
dataSourceManage.innerEditStatus(coreDatasource);
}
datasourceDTO.setConfiguration("");
return datasourceDTO;
}
@Override
public List<BusiNodeVO> tree(BusiNodeRequest request) throws DEException {
return dataSourceManage.tree(request);
@ -1044,8 +891,6 @@ public class DatasourceServer implements DatasourceApi {
}
public IPage<CoreDatasourceTaskLogDTO> listSyncRecord(int goPage, int pageSize, Long dsId) {
QueryWrapper<CoreDatasourceTaskLogDTO> wrapper = new QueryWrapper<>();
wrapper.eq("ds_id", dsId);
wrapper.orderByDesc("start_time");
@ -1149,4 +994,163 @@ public class DatasourceServer implements DatasourceApi {
BeanUtils.copyBean(datasourceDTO, record);
return datasourceDTO;
}
private void getParents(Long pid, List<Long> ids) {
CoreDatasource parent = datasourceMapper.selectById(pid);// 查找父级folder
ids.add(parent.getId());
if (parent.getPid() != null && parent.getPid() != 0) {
getParents(parent.getPid(), ids);
}
}
private void filterDs(List<BusiNodeVO> busiNodeVOS, List<Long> ids, String type, Long id) {
for (BusiNodeVO busiNodeVO : busiNodeVOS) {
if (busiNodeVO.getType() != null && busiNodeVO.getType().equalsIgnoreCase(type)) {
if (id != null) {
if (!busiNodeVO.getId().equals(id)) {
ids.add(busiNodeVO.getId());
}
} else {
ids.add(busiNodeVO.getId());
}
}
if (CollectionUtils.isNotEmpty(busiNodeVO.getChildren())) {
filterDs(busiNodeVO.getChildren(), ids, type, id);
}
}
}
private static void checkParams(String configurationStr) {
DatasourceConfiguration configuration = JsonUtil.parseObject(configurationStr, DatasourceConfiguration.class);
if (configuration.getInitialPoolSize() < configuration.getMinPoolSize()) {
DEException.throwException("初始连接数不能小于最小连接数!");
}
if (configuration.getInitialPoolSize() > configuration.getMaxPoolSize()) {
DEException.throwException("初始连接数不能大于最大连接数!");
}
if (configuration.getMaxPoolSize() < configuration.getMinPoolSize()) {
DEException.throwException("最大连接数不能小于最小连接数!");
}
if (configuration.getQueryTimeout() < 0) {
DEException.throwException("查询超时不能小于0");
}
}
private static void checkName(List<String> tables) {
for (int i = 0; i < tables.size() - 1; i++) {
for (int j = i + 1; j < tables.size(); j++) {
if (tables.get(i).equalsIgnoreCase(tables.get(j))) {
DEException.throwException(Translator.get("i18n_table_name_repeat") + tables.get(i));
}
}
}
}
private String excelDataTableName(String name) {
return StringUtils.substring(name, 6, name.length() - 11);
}
private DatasourceDTO getDatasourceDTOById(Long datasourceId, boolean hidePw) throws DEException {
CoreDatasource datasource = datasourceMapper.selectById(datasourceId);
if (datasource == null) {
DEException.throwException("不存在的数据源!");
}
return convertCoreDatasource(datasourceId, hidePw, datasource);
}
private DatasourceDTO convertCoreDatasource(Long datasourceId, boolean hidePw, CoreDatasource datasource) {
DatasourceDTO datasourceDTO = new DatasourceDTO();
BeanUtils.copyBean(datasourceDTO, datasource);
if (datasourceDTO.getType().equalsIgnoreCase(DatasourceConfiguration.DatasourceType.API.toString())) {
List<ApiDefinition> apiDefinitionList = JsonUtil.parseList(datasourceDTO.getConfiguration(), listTypeReference);
List<ApiDefinition> apiDefinitionListWithStatus = new ArrayList<>();
List<ApiDefinition> params = new ArrayList<>();
int success = 0;
for (ApiDefinition apiDefinition : apiDefinitionList) {
String status = null;
if (StringUtils.isNotEmpty(datasourceDTO.getStatus())) {
JsonNode jsonNode = null;
try {
jsonNode = objectMapper.readTree(datasourceDTO.getStatus());
} catch (Exception e) {
DEException.throwException(e);
}
for (JsonNode node : jsonNode) {
if (node.get("name").asText().equals(apiDefinition.getName())) {
status = node.get("status").asText();
}
}
apiDefinition.setStatus(status);
}
if (StringUtils.isNotEmpty(status) && status.equalsIgnoreCase("Success")) {
success++;
}
CoreDatasourceTaskLog log = datasourceTaskServer.lastSyncLogForTable(datasourceId, apiDefinition.getDeTableName());
if (log != null) {
apiDefinition.setUpdateTime(log.getStartTime());
}
if (StringUtils.isEmpty(apiDefinition.getType()) || apiDefinition.getType().equalsIgnoreCase("table")) {
apiDefinitionListWithStatus.add(apiDefinition);
} else {
params.add(apiDefinition);
}
}
datasourceDTO.setApiConfigurationStr(new String(Base64.getEncoder().encode(Objects.requireNonNull(JsonUtil.toJSONString(apiDefinitionListWithStatus)).toString().getBytes())));
datasourceDTO.setParamsStr(new String(Base64.getEncoder().encode(Objects.requireNonNull(JsonUtil.toJSONString(params)).toString().getBytes())));
if (success == apiDefinitionList.size()) {
datasourceDTO.setStatus("Success");
} else {
if (success > 0 && success < apiDefinitionList.size()) {
datasourceDTO.setStatus("Warning");
} else {
datasourceDTO.setStatus("Error");
}
}
CoreDatasourceTask coreDatasourceTask = datasourceTaskServer.selectByDSId(datasourceDTO.getId());
TaskDTO taskDTO = new TaskDTO();
BeanUtils.copyBean(taskDTO, coreDatasourceTask);
datasourceDTO.setSyncSetting(taskDTO);
CoreDatasourceTask task = datasourceTaskServer.selectByDSId(datasourceDTO.getId());
if (task != null) {
datasourceDTO.setLastSyncTime(task.getStartTime());
}
} else {
if (hidePw) {
Provider provider = ProviderFactory.getProvider(datasourceDTO.getType());
provider.hidePW(datasourceDTO);
}
}
if (datasourceDTO.getType().equalsIgnoreCase(DatasourceConfiguration.DatasourceType.Excel.toString())) {
datasourceDTO.setFileName(ExcelUtils.getFileName(datasource));
datasourceDTO.setSize(ExcelUtils.getSize(datasource));
}
datasourceDTO.setConfiguration(new String(Base64.getEncoder().encode(datasourceDTO.getConfiguration().getBytes())));
datasourceDTO.setCreator(coreUserManage.getUserName(Long.valueOf(datasourceDTO.getCreateBy())));
return datasourceDTO;
}
private DatasourceDTO validate(CoreDatasource coreDatasource) {
DatasourceDTO datasourceDTO = new DatasourceDTO();
BeanUtils.copyBean(datasourceDTO, coreDatasource);
try {
checkDatasourceStatus(datasourceDTO);
if (!Arrays.asList("API", "Excel", "folder").contains(coreDatasource.getType())) {
calciteProvider.updateDsPoolAfterCheckStatus(datasourceDTO);
}
} catch (Exception e) {
coreDatasource.setStatus("Error");
DEException.throwException(e.getMessage());
} finally {
coreDatasource.setStatus(datasourceDTO.getStatus());
dataSourceManage.innerEditStatus(coreDatasource);
}
datasourceDTO.setConfiguration("");
return datasourceDTO;
}
}

View File

@ -452,6 +452,11 @@ defineExpose({
</template>
</el-table-column>
<el-table-column prop="exportFromName" :label="$t('data_export.export_obj')" width="200" />
<el-table-column prop="exportTime" width="180" :label="$t('data_export.export_time')">
<template #default="scope">
<span>{{ timestampFormatDate(scope.row.exportTime) }}</span>
</template>
</el-table-column>
<el-table-column prop="exportFromType" width="120" :label="$t('data_export.export_from')">
<template #default="scope">
<span v-if="scope.row.exportFromType === 'dataset'">{{ t('data_set.data_set') }}</span>
@ -464,11 +469,6 @@ defineExpose({
:label="t('data_set.organization')"
width="200"
/>
<el-table-column prop="exportTime" width="180" :label="$t('data_export.export_time')">
<template #default="scope">
<span>{{ timestampFormatDate(scope.row.exportTime) }}</span>
</template>
</el-table-column>
<el-table-column fixed="right" prop="operate" width="90" :label="$t('commons.operating')">
<template #default="scope">
<el-tooltip effect="dark" :content="t('data_set.download')" placement="top">

View File

@ -3,6 +3,7 @@ package io.dataease.api.ds;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.dataease.api.ds.vo.ApiDefinition;
import io.dataease.api.ds.vo.BusiDsRequest;
import io.dataease.api.ds.vo.CoreDatasourceTaskLogDTO;
import io.dataease.api.ds.vo.ExcelFileData;
import io.dataease.auth.DeApiPath;
@ -14,6 +15,7 @@ import io.dataease.extensions.datasource.dto.TableField;
import io.dataease.extensions.datasource.vo.DatasourceConfiguration;
import io.dataease.model.BusiNodeRequest;
import io.dataease.model.BusiNodeVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -34,96 +36,124 @@ public interface DatasourceApi {
* @return
*/
@GetMapping("/query/{keyWord}")
@Operation(summary = "查询")
List<DatasourceDTO> query(@PathVariable("keyWord") String keyWord);
@PostMapping("/save")
DatasourceDTO save(@RequestBody DatasourceDTO dataSourceDTO) throws DEException;
@Operation(summary = "保存")
DatasourceDTO save(@RequestBody BusiDsRequest dataSourceDTO) throws DEException;
@PostMapping("/update")
DatasourceDTO update(@RequestBody DatasourceDTO dataSourceDTO) throws DEException;
@Operation(summary = "更新")
DatasourceDTO update(@RequestBody BusiDsRequest dataSourceDTO) throws DEException;
@PostMapping("/move")
DatasourceDTO move(@RequestBody DatasourceDTO dataSourceDTO) throws DEException;
@Operation(summary = "移动")
DatasourceDTO move(@RequestBody BusiDsRequest dataSourceDTO) throws DEException;
@PostMapping("/reName")
DatasourceDTO reName(@RequestBody DatasourceDTO dataSourceDTO) throws DEException;
@Operation(summary = "重命名")
DatasourceDTO reName(@RequestBody BusiDsRequest dataSourceDTO) throws DEException;
@PostMapping("/createFolder")
DatasourceDTO createFolder(@RequestBody DatasourceDTO dataSourceDTO) throws DEException;
@Operation(summary = "新建文件夹")
DatasourceDTO createFolder(@RequestBody BusiDsRequest dataSourceDTO) throws DEException;
@PostMapping("/checkRepeat")
boolean checkRepeat(@RequestBody DatasourceDTO dataSourceDTO) throws DEException;
@Operation(summary = "校验重复")
boolean checkRepeat(@RequestBody BusiDsRequest dataSourceDTO) throws DEException;
@GetMapping("/types")
@Operation(summary = "数据源类型")
List<DatasourceConfiguration.DatasourceType> datasourceTypes() throws DEException;
@PostMapping("/validate")
DatasourceDTO validate(@RequestBody DatasourceDTO dataSourceDTO) throws DEException;
@Operation(summary = "校验")
DatasourceDTO validate(@RequestBody BusiDsRequest dataSourceDTO) throws DEException;
@PostMapping("/getSchema")
List<String> getSchema(@RequestBody DatasourceDTO dataSourceDTO) throws DEException;
@Operation(summary = "获取 schema")
List<String> getSchema(@RequestBody BusiDsRequest dataSourceDTO) throws DEException;
@DePermit({"#p0+':manage'"})
@GetMapping("/validate/{datasourceId}")
@Operation(summary = "校验")
DatasourceDTO validate(@PathVariable("datasourceId") Long datasourceId) throws DEException;
@DePermit({"#p0+':manage'"})
@PostMapping("/perDelete/{datasourceId}")
@Operation(summary = "是否有数据集正在使用此数据源")
boolean perDelete(@PathVariable("datasourceId") Long datasourceId);
@DePermit({"#p0+':manage'"})
@GetMapping("/delete/{datasourceId}")
@Operation(summary = "删除")
void delete(@PathVariable("datasourceId") Long datasourceId) throws DEException;
@DePermit({"#p0+':read'"})
@GetMapping("/get/{datasourceId}")
@Operation(summary = "数据源详情")
DatasourceDTO get(@PathVariable("datasourceId") Long datasourceId) throws DEException;
DatasourceDTO innerGet(Long datasourceId) throws DEException;
List<DatasourceDTO> innerList(List<Long> ids, List<String> types) throws DEException;
@DePermit({"#p0+':read'"})
@GetMapping("/hidePw/{datasourceId}")
@Operation(summary = "数据源详情")
DatasourceDTO hidePw(@PathVariable("datasourceId") Long datasourceId) throws DEException;
@PostMapping("/getTableField")
@Operation(summary = "获取表字段")
List<TableField> getTableField(@RequestBody Map<String, String> req) throws DEException;
@PostMapping("/syncApiTable")
@Operation(summary = "同步API数据表")
void syncApiTable(@RequestBody Map<String, String> req) throws DEException;
@PostMapping("/syncApiDs")
@Operation(summary = "同步API数据源")
void syncApiDs(@RequestBody Map<String, String> req) throws Exception;
@PostMapping("tree")
@Operation(summary = "数据源列表")
List<BusiNodeVO> tree(@RequestBody BusiNodeRequest request) throws DEException;
@DePermit({"#p0.datasourceId+':read'"})
@PostMapping("getTables")
@Operation(summary = "获取表")
List<DatasetTableDTO> getTables(@RequestBody DatasetTableDTO datasetTableDTO) throws DEException;
@PostMapping("/checkApiDatasource")
@Operation(summary = "校验API数据源")
ApiDefinition checkApiDatasource(@RequestBody Map<String, String> data) throws DEException;
@PostMapping("/uploadFile")
@Operation(summary = "上传文件")
ExcelFileData excelUpload(@RequestParam("file") MultipartFile file, @RequestParam("id") long datasourceId, @RequestParam("editType") Integer editType) throws DEException;
@PostMapping("/previewData")
@Operation(summary = "预览数据")
Map<String, Object> previewDataWithLimit(@RequestBody Map<String, Object> req) throws DEException;
@PostMapping("/latestUse")
@Operation(summary = "最近常用")
public List<String> latestUse();
@GetMapping("showFinishPage")
@Operation(summary = "是否显示完成页面")
public boolean showFinishPage() throws DEException;
@PostMapping("setShowFinishPage")
@Operation(summary = "是否显示完成页面")
public void setShowFinishPage() throws DEException;
@PostMapping("/listSyncRecord/{dsId}/{goPage}/{pageSize}")
@Operation(summary = "更新日志")
IPage<CoreDatasourceTaskLogDTO> listSyncRecord(@PathVariable("goPage") int goPage, @PathVariable("pageSize") int pageSize, @PathVariable("dsId") Long dsId);
DatasourceDTO innerGet(Long datasourceId) throws DEException;
List<DatasourceDTO> innerList(List<Long> ids, List<String> types) throws DEException;
}

View File

@ -0,0 +1,51 @@
package io.dataease.api.ds.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.dataease.extensions.datasource.dto.TaskDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
public class BusiDsRequest implements Serializable {
@Serial
private static final long serialVersionUID = 1175287571828910222L;
@JsonSerialize(using= ToStringSerializer.class)
private Long id;
@JsonSerialize(using= ToStringSerializer.class)
@Schema(description = "父ID", requiredMode = Schema.RequiredMode.REQUIRED)
private Long pid;
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED)
private String name;
@Schema(description = "节点类型", requiredMode = Schema.RequiredMode.REQUIRED)
private String nodeType;
@Schema(description = "操作类型", requiredMode = Schema.RequiredMode.REQUIRED)
private String action;
private String description;
private String type;
private String typeAlias;
private String catalog;
private String catalogDesc;
private String configuration;
private String apiConfigurationStr;
private String paramsStr;
private Long createTime;
private Long updateTime;
private Long updateBy;
private String createBy;
private String creator;
private String status;
private TaskDTO syncSetting;
private Integer editType;
private String fileName;
private String size;
private Long lastSyncTime;
private String qrtzInstance;
private String taskStatus;
private Boolean enableDataFill;
}