Unverified Commit be0ff515 authored by Licho's avatar Licho Committed by GitHub

refacotr: DolphinSchedule logic (#2307)

* refacotr: dolphone Signed-off-by: 's avatarLicho <lecho.sun@gmail.com> * Spotless Apply * refacotr: dolphinScheduler undefined error * refactor: fetchData type * refactor: type * refactor: type * refactor: type * fix: type or null * fix: dolphin problem * fix: left corner hide problem * Spotless Apply * fix: minWith --------- Signed-off-by: 's avatarLicho <lecho.sun@gmail.com> Co-authored-by: 's avatarleechor <leechor@users.noreply.github.com>
parent baebf478
...@@ -33,7 +33,9 @@ import org.apache.commons.lang3.StringUtils; ...@@ -33,7 +33,9 @@ import org.apache.commons.lang3.StringUtils;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -71,7 +73,7 @@ public class LogAspect { ...@@ -71,7 +73,7 @@ public class LogAspect {
*/ */
@AfterReturning(pointcut = "logPointCut()", returning = "jsonResult") @AfterReturning(pointcut = "logPointCut()", returning = "jsonResult")
public void doAfterReturning(JoinPoint joinPoint, Object jsonResult) { public void doAfterReturning(JoinPoint joinPoint, Object jsonResult) {
handleLog(joinPoint, null, jsonResult); handleCommonLogic(joinPoint, null, jsonResult);
} }
/** /**
...@@ -82,10 +84,10 @@ public class LogAspect { ...@@ -82,10 +84,10 @@ public class LogAspect {
*/ */
@AfterThrowing(value = "logPointCut()", throwing = "e") @AfterThrowing(value = "logPointCut()", throwing = "e")
public void doAfterThrowing(JoinPoint joinPoint, Exception e) { public void doAfterThrowing(JoinPoint joinPoint, Exception e) {
handleLog(joinPoint, e, null); handleCommonLogic(joinPoint, e, null);
} }
protected void handleLog(final JoinPoint joinPoint, final Exception e, Object jsonResult) { protected void handleCommonLogic(final JoinPoint joinPoint, final Exception e, Object jsonResult) {
try { try {
// 获得注解 // 获得注解
Log controllerLog = getAnnotationLog(joinPoint); Log controllerLog = getAnnotationLog(joinPoint);
...@@ -165,7 +167,7 @@ public class LogAspect { ...@@ -165,7 +167,7 @@ public class LogAspect {
* @param operLog 操作日志 * @param operLog 操作日志
* @throws Exception 异常 * @throws Exception 异常
*/ */
private void setRequestValue(JoinPoint joinPoint, OperateLog operLog) throws Exception { private void setRequestValue(JoinPoint joinPoint, OperateLog operLog) {
String requestMethod = operLog.getRequestMethod(); String requestMethod = operLog.getRequestMethod();
if (HttpMethod.PUT.name().equals(requestMethod) if (HttpMethod.PUT.name().equals(requestMethod)
|| HttpMethod.POST.name().equals(requestMethod)) { || HttpMethod.POST.name().equals(requestMethod)) {
...@@ -192,16 +194,10 @@ public class LogAspect { ...@@ -192,16 +194,10 @@ public class LogAspect {
/** 参数拼装 */ /** 参数拼装 */
private String argsArrayToString(Object[] paramsArray) { private String argsArrayToString(Object[] paramsArray) {
String params = ""; return Arrays.stream(paramsArray)
if (paramsArray != null && paramsArray.length > 0) { .filter(o -> !isFilterObject(o))
for (int i = 0; i < paramsArray.length; i++) { .map(JSONUtil::toJsonStr)
if (!isFilterObject(paramsArray[i])) { .collect(Collectors.joining(" "));
String jsonObj = JSONUtil.toJsonStr(paramsArray[i]);
params += jsonObj + " ";
}
}
}
return params.trim();
} }
/** /**
......
...@@ -74,22 +74,22 @@ public class APIController { ...@@ -74,22 +74,22 @@ public class APIController {
@GetMapping("/submitTask") @GetMapping("/submitTask")
@ApiOperation("Submit Task") @ApiOperation("Submit Task")
@Log(title = "Submit Task", businessType = BusinessType.SUBMIT) // @Log(title = "Submit Task", businessType = BusinessType.SUBMIT)
public Result<JobResult> submitTask(@RequestParam Integer id) { public Result<JobResult> submitTask(@RequestParam Integer id) {
taskService.initTenantByTaskId(id); taskService.initTenantByTaskId(id);
return Result.succeed(taskService.submitTask(id), Status.EXECUTE_SUCCESS); return Result.succeed(taskService.submitTask(id), Status.EXECUTE_SUCCESS);
} }
@PostMapping("/executeSql") @PostMapping("/executeSql")
@Log(title = "Execute Sql", businessType = BusinessType.EXECUTE)
@ApiOperation("Execute Sql") @ApiOperation("Execute Sql")
// @Log(title = "Execute Sql", businessType = BusinessType.EXECUTE)
public Result<APIJobResult> executeSql(@RequestBody APIExecuteSqlDTO apiExecuteSqlDTO) { public Result<APIJobResult> executeSql(@RequestBody APIExecuteSqlDTO apiExecuteSqlDTO) {
return Result.succeed(apiService.executeSql(apiExecuteSqlDTO), Status.EXECUTE_SUCCESS); return Result.succeed(apiService.executeSql(apiExecuteSqlDTO), Status.EXECUTE_SUCCESS);
} }
@PostMapping("/explainSql") @PostMapping("/explainSql")
@Log(title = "Explain Sql", businessType = BusinessType.EXECUTE)
@ApiOperation("Explain Sql") @ApiOperation("Explain Sql")
// @Log(title = "Explain Sql", businessType = BusinessType.EXECUTE)
public Result<ExplainResult> explainSql(@RequestBody APIExplainSqlDTO apiExecuteSqlDTO) { public Result<ExplainResult> explainSql(@RequestBody APIExplainSqlDTO apiExecuteSqlDTO) {
return Result.succeed(apiService.explainSql(apiExecuteSqlDTO), Status.EXECUTE_SUCCESS); return Result.succeed(apiService.explainSql(apiExecuteSqlDTO), Status.EXECUTE_SUCCESS);
} }
...@@ -127,15 +127,15 @@ public class APIController { ...@@ -127,15 +127,15 @@ public class APIController {
} }
@PostMapping("/executeJar") @PostMapping("/executeJar")
@Log(title = "Execute Jar", businessType = BusinessType.EXECUTE)
@ApiOperation("Execute Jar") @ApiOperation("Execute Jar")
// @Log(title = "Execute Jar", businessType = BusinessType.EXECUTE)
public Result<APIJobResult> executeJar(@RequestBody APIExecuteJarDTO apiExecuteJarDTO) { public Result<APIJobResult> executeJar(@RequestBody APIExecuteJarDTO apiExecuteJarDTO) {
return Result.succeed(apiService.executeJar(apiExecuteJarDTO), Status.EXECUTE_SUCCESS); return Result.succeed(apiService.executeJar(apiExecuteJarDTO), Status.EXECUTE_SUCCESS);
} }
@PostMapping("/savepointTask") @PostMapping("/savepointTask")
@Log(title = "Savepoint Task", businessType = BusinessType.TRIGGER)
@ApiOperation("Savepoint Task") @ApiOperation("Savepoint Task")
// @Log(title = "Savepoint Task", businessType = BusinessType.TRIGGER)
public Result<Boolean> savepointTask(@RequestBody APISavePointTaskDTO apiSavePointTaskDTO) { public Result<Boolean> savepointTask(@RequestBody APISavePointTaskDTO apiSavePointTaskDTO) {
return Result.succeed( return Result.succeed(
taskService.savepointTask(apiSavePointTaskDTO.getTaskId(), apiSavePointTaskDTO.getType()), "执行成功"); taskService.savepointTask(apiSavePointTaskDTO.getTaskId(), apiSavePointTaskDTO.getType()), "执行成功");
...@@ -144,7 +144,7 @@ public class APIController { ...@@ -144,7 +144,7 @@ public class APIController {
/** 重启任务 */ /** 重启任务 */
@GetMapping("/restartTask") @GetMapping("/restartTask")
@ApiOperation("Restart Task") @ApiOperation("Restart Task")
@Log(title = "Restart Task", businessType = BusinessType.EXECUTE) // @Log(title = "Restart Task", businessType = BusinessType.EXECUTE)
public Result<JobResult> restartTask(@RequestParam Integer id) { public Result<JobResult> restartTask(@RequestParam Integer id) {
taskService.initTenantByTaskId(id); taskService.initTenantByTaskId(id);
return Result.succeed(taskService.restartTask(id, null), Status.RESTART_SUCCESS); return Result.succeed(taskService.restartTask(id, null), Status.RESTART_SUCCESS);
...@@ -153,7 +153,7 @@ public class APIController { ...@@ -153,7 +153,7 @@ public class APIController {
/** 选择保存点重启任务 */ /** 选择保存点重启任务 */
@GetMapping("/selectSavePointRestartTask") @GetMapping("/selectSavePointRestartTask")
@ApiOperation("Select SavePoint Restart Task") @ApiOperation("Select SavePoint Restart Task")
@Log(title = "Select SavePoint Restart Task", businessType = BusinessType.EXECUTE) // @Log(title = "Select SavePoint Restart Task", businessType = BusinessType.EXECUTE)
public Result<JobResult> restartTask(@RequestParam Integer id, @RequestParam String savePointPath) { public Result<JobResult> restartTask(@RequestParam Integer id, @RequestParam String savePointPath) {
taskService.initTenantByTaskId(id); taskService.initTenantByTaskId(id);
return Result.succeed(taskService.restartTask(id, savePointPath), Status.RESTART_SUCCESS); return Result.succeed(taskService.restartTask(id, savePointPath), Status.RESTART_SUCCESS);
...@@ -162,7 +162,7 @@ public class APIController { ...@@ -162,7 +162,7 @@ public class APIController {
/** 上线任务 */ /** 上线任务 */
@GetMapping("/onLineTask") @GetMapping("/onLineTask")
@ApiOperation("Online Task") @ApiOperation("Online Task")
@Log(title = "Online Task", businessType = BusinessType.EXECUTE) // @Log(title = "Online Task", businessType = BusinessType.EXECUTE)
public Result<JobResult> onLineTask(@RequestParam Integer id) { public Result<JobResult> onLineTask(@RequestParam Integer id) {
taskService.initTenantByTaskId(id); taskService.initTenantByTaskId(id);
return taskService.onLineTask(id); return taskService.onLineTask(id);
...@@ -171,7 +171,7 @@ public class APIController { ...@@ -171,7 +171,7 @@ public class APIController {
/** 下线任务 */ /** 下线任务 */
@GetMapping("/offLineTask") @GetMapping("/offLineTask")
@ApiOperation("Offline Task") @ApiOperation("Offline Task")
@Log(title = "Offline Task", businessType = BusinessType.EXECUTE) // @Log(title = "Offline Task", businessType = BusinessType.EXECUTE)
public Result<Void> offLineTask(@RequestParam Integer id) { public Result<Void> offLineTask(@RequestParam Integer id) {
taskService.initTenantByTaskId(id); taskService.initTenantByTaskId(id);
return taskService.offLineTask(id, null); return taskService.offLineTask(id, null);
...@@ -180,7 +180,7 @@ public class APIController { ...@@ -180,7 +180,7 @@ public class APIController {
/** 重新上线任务 */ /** 重新上线任务 */
@GetMapping("/reOnLineTask") @GetMapping("/reOnLineTask")
@ApiOperation("ReOnline Task") @ApiOperation("ReOnline Task")
@Log(title = "ReOnline Task", businessType = BusinessType.EXECUTE) // @Log(title = "ReOnline Task", businessType = BusinessType.EXECUTE)
public Result<JobResult> reOnLineTask(@RequestParam Integer id) { public Result<JobResult> reOnLineTask(@RequestParam Integer id) {
taskService.initTenantByTaskId(id); taskService.initTenantByTaskId(id);
return taskService.reOnLineTask(id, null); return taskService.reOnLineTask(id, null);
...@@ -189,7 +189,7 @@ public class APIController { ...@@ -189,7 +189,7 @@ public class APIController {
/** 选择保存点重新上线任务 */ /** 选择保存点重新上线任务 */
@GetMapping("/selectSavePointReOnLineTask") @GetMapping("/selectSavePointReOnLineTask")
@ApiOperation("Select SavePoint ReOnline Task") @ApiOperation("Select SavePoint ReOnline Task")
@Log(title = "Select SavePoint ReOnline Task", businessType = BusinessType.EXECUTE) // @Log(title = "Select SavePoint ReOnline Task", businessType = BusinessType.EXECUTE)
public Result<JobResult> selectSavePointReOnLineTask(@RequestParam Integer id, @RequestParam String savePointPath) { public Result<JobResult> selectSavePointReOnLineTask(@RequestParam Integer id, @RequestParam String savePointPath) {
taskService.initTenantByTaskId(id); taskService.initTenantByTaskId(id);
return taskService.reOnLineTask(id, savePointPath); return taskService.reOnLineTask(id, savePointPath);
...@@ -197,8 +197,8 @@ public class APIController { ...@@ -197,8 +197,8 @@ public class APIController {
/** 获取Job实例的信息 */ /** 获取Job实例的信息 */
@GetMapping("/getJobInstance") @GetMapping("/getJobInstance")
@Log(title = "Get Job Instance", businessType = BusinessType.QUERY)
@ApiOperation("Get Job Instance") @ApiOperation("Get Job Instance")
// @Log(title = "Get Job Instance", businessType = BusinessType.QUERY)
public Result<JobInstance> getJobInstance(@RequestParam Integer id) { public Result<JobInstance> getJobInstance(@RequestParam Integer id) {
jobInstanceService.initTenantByJobInstanceId(id); jobInstanceService.initTenantByJobInstanceId(id);
return Result.succeed(jobInstanceService.getById(id)); return Result.succeed(jobInstanceService.getById(id));
...@@ -206,8 +206,8 @@ public class APIController { ...@@ -206,8 +206,8 @@ public class APIController {
/** 通过 taskId 获取 Task 对应的 Job 实例的信息 */ /** 通过 taskId 获取 Task 对应的 Job 实例的信息 */
@GetMapping("/getJobInstanceByTaskId") @GetMapping("/getJobInstanceByTaskId")
@Log(title = "Get Job Instance By Task Id", businessType = BusinessType.QUERY)
@ApiOperation("Get Job Instance By Task Id") @ApiOperation("Get Job Instance By Task Id")
// @Log(title = "Get Job Instance By Task Id", businessType = BusinessType.QUERY)
public Result<JobInstance> getJobInstanceByTaskId(@RequestParam Integer id) { public Result<JobInstance> getJobInstanceByTaskId(@RequestParam Integer id) {
taskService.initTenantByTaskId(id); taskService.initTenantByTaskId(id);
return Result.succeed(jobInstanceService.getJobInstanceByTaskId(id)); return Result.succeed(jobInstanceService.getJobInstanceByTaskId(id));
......
...@@ -37,9 +37,6 @@ import org.dinky.scheduler.model.TaskMainInfo; ...@@ -37,9 +37,6 @@ import org.dinky.scheduler.model.TaskMainInfo;
import org.dinky.scheduler.model.TaskRequest; import org.dinky.scheduler.model.TaskRequest;
import org.dinky.service.CatalogueService; import org.dinky.service.CatalogueService;
import org.apache.commons.lang3.StringUtils;
import java.util.Collections;
import java.util.List; import java.util.List;
import javax.validation.Valid; import javax.validation.Valid;
...@@ -53,7 +50,7 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -53,7 +50,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.google.common.collect.Lists; import com.google.common.base.Strings;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
...@@ -69,6 +66,7 @@ import lombok.RequiredArgsConstructor; ...@@ -69,6 +66,7 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor @RequiredArgsConstructor
public class SchedulerController { public class SchedulerController {
public static final String TASK_TYPE = "DINKY";
private final ProcessClient processClient; private final ProcessClient processClient;
private final TaskClient taskClient; private final TaskClient taskClient;
private final CatalogueService catalogueService; private final CatalogueService catalogueService;
...@@ -77,36 +75,32 @@ public class SchedulerController { ...@@ -77,36 +75,32 @@ public class SchedulerController {
@GetMapping("/task") @GetMapping("/task")
@ApiOperation("Get Task Definition") @ApiOperation("Get Task Definition")
public Result<TaskDefinition> getTaskDefinition(@ApiParam(value = "dinky任务id") @RequestParam Long dinkyTaskId) { public Result<TaskDefinition> getTaskDefinition(@ApiParam(value = "dinky任务id") @RequestParam Long dinkyTaskId) {
TaskDefinition taskDefinition = null;
Project dinkyProject = SystemInit.getProject();
Catalogue catalogue = Catalogue catalogue =
catalogueService.getOne(new LambdaQueryWrapper<Catalogue>().eq(Catalogue::getTaskId, dinkyTaskId)); catalogueService.getOne(new LambdaQueryWrapper<Catalogue>().eq(Catalogue::getTaskId, dinkyTaskId));
if (catalogue == null) { if (catalogue == null) {
return Result.failed(Status.DS_GET_NODE_LIST_ERROR); return Result.failed(Status.DS_GET_NODE_LIST_ERROR);
} }
List<String> lists = Lists.newArrayList(); Project dinkyProject = SystemInit.getProject();
getDinkyNames(lists, catalogue, 0);
Collections.reverse(lists);
String processName = StringUtils.join(lists, "_");
String taskName = catalogue.getName() + ":" + catalogue.getId();
long projectCode = dinkyProject.getCode(); long projectCode = dinkyProject.getCode();
String processName = getDinkyNames(catalogue, 0);
String taskName = catalogue.getName() + ":" + catalogue.getId();
TaskMainInfo taskMainInfo = taskClient.getTaskMainInfo(projectCode, processName, taskName); TaskMainInfo taskMainInfo = taskClient.getTaskMainInfo(projectCode, processName, taskName);
TaskDefinition taskDefinition = null;
if (taskMainInfo == null) {
return Result.succeed(taskDefinition);
}
if (taskMainInfo != null) {
taskDefinition = taskClient.getTaskDefinition(projectCode, taskMainInfo.getTaskCode()); taskDefinition = taskClient.getTaskDefinition(projectCode, taskMainInfo.getTaskCode());
if (taskDefinition == null) {
return Result.failed(Status.DS_WORK_FLOW_NOT_SAVE);
}
if (taskDefinition != null) {
taskDefinition.setProcessDefinitionCode(taskMainInfo.getProcessDefinitionCode()); taskDefinition.setProcessDefinitionCode(taskMainInfo.getProcessDefinitionCode());
taskDefinition.setProcessDefinitionName(taskMainInfo.getProcessDefinitionName()); taskDefinition.setProcessDefinitionName(taskMainInfo.getProcessDefinitionName());
taskDefinition.setProcessDefinitionVersion(taskMainInfo.getProcessDefinitionVersion()); taskDefinition.setProcessDefinitionVersion(taskMainInfo.getProcessDefinitionVersion());
taskDefinition.setUpstreamTaskMap(taskMainInfo.getUpstreamTaskMap()); taskDefinition.setUpstreamTaskMap(taskMainInfo.getUpstreamTaskMap());
} else {
return Result.failed(Status.DS_WORK_FLOW_NOT_SAVE);
}
}
return Result.succeed(taskDefinition); return Result.succeed(taskDefinition);
} }
...@@ -114,22 +108,14 @@ public class SchedulerController { ...@@ -114,22 +108,14 @@ public class SchedulerController {
@GetMapping("/upstream/tasks") @GetMapping("/upstream/tasks")
@ApiOperation("Get Upstream Task Definition") @ApiOperation("Get Upstream Task Definition")
public Result<List<TaskMainInfo>> getTaskMainInfos(@ApiParam(value = "dinky任务id") @RequestParam Long dinkyTaskId) { public Result<List<TaskMainInfo>> getTaskMainInfos(@ApiParam(value = "dinky任务id") @RequestParam Long dinkyTaskId) {
Project dinkyProject = SystemInit.getProject();
Catalogue catalogue = Catalogue catalogue =
catalogueService.getOne(new LambdaQueryWrapper<Catalogue>().eq(Catalogue::getTaskId, dinkyTaskId)); catalogueService.getOne(new LambdaQueryWrapper<Catalogue>().eq(Catalogue::getTaskId, dinkyTaskId));
if (catalogue == null) { if (catalogue == null) {
return Result.failed(Status.DS_GET_NODE_LIST_ERROR); return Result.failed(Status.DS_GET_NODE_LIST_ERROR);
} }
List<String> lists = Lists.newArrayList(); long projectCode = SystemInit.getProject().getCode();
getDinkyNames(lists, catalogue, 0); String processName = getDinkyNames(catalogue, 0);
Collections.reverse(lists);
String processName = StringUtils.join(lists, "_");
long projectCode = dinkyProject.getCode();
List<TaskMainInfo> taskMainInfos = taskClient.getTaskMainInfos(projectCode, processName, ""); List<TaskMainInfo> taskMainInfos = taskClient.getTaskMainInfos(projectCode, processName, "");
// 去掉本身 // 去掉本身
taskMainInfos.removeIf(taskMainInfo -> taskMainInfos.removeIf(taskMainInfo ->
...@@ -150,9 +136,7 @@ public class SchedulerController { ...@@ -150,9 +136,7 @@ public class SchedulerController {
dinkyTaskParams.setAddress( dinkyTaskParams.setAddress(
SystemConfiguration.getInstances().getDinkyAddr().getValue()); SystemConfiguration.getInstances().getDinkyAddr().getValue());
taskRequest.setTaskParams(JSONUtil.parseObj(dinkyTaskParams).toString()); taskRequest.setTaskParams(JSONUtil.parseObj(dinkyTaskParams).toString());
taskRequest.setTaskType("DINKY"); taskRequest.setTaskType(TASK_TYPE);
Project dinkyProject = SystemInit.getProject();
Catalogue catalogue = Catalogue catalogue =
catalogueService.getOne(new LambdaQueryWrapper<Catalogue>().eq(Catalogue::getTaskId, dinkyTaskId)); catalogueService.getOne(new LambdaQueryWrapper<Catalogue>().eq(Catalogue::getTaskId, dinkyTaskId));
...@@ -160,14 +144,11 @@ public class SchedulerController { ...@@ -160,14 +144,11 @@ public class SchedulerController {
return Result.failed(Status.DS_GET_NODE_LIST_ERROR); return Result.failed(Status.DS_GET_NODE_LIST_ERROR);
} }
List<String> lists = Lists.newArrayList(); String processName = getDinkyNames(catalogue, 0);
getDinkyNames(lists, catalogue, 0); long projectCode = SystemInit.getProject().getCode();
Collections.reverse(lists);
String processName = StringUtils.join(lists, "_");
String taskName = catalogue.getName() + ":" + catalogue.getId();
long projectCode = dinkyProject.getCode();
ProcessDefinition process = processClient.getProcessDefinitionInfo(projectCode, processName); ProcessDefinition process = processClient.getProcessDefinitionInfo(projectCode, processName);
String taskName = catalogue.getName() + ":" + catalogue.getId();
taskRequest.setName(taskName); taskRequest.setName(taskName);
if (process == null) { if (process == null) {
Long taskCode = taskClient.genTaskCode(projectCode); Long taskCode = taskClient.genTaskCode(projectCode);
...@@ -176,24 +157,23 @@ public class SchedulerController { ...@@ -176,24 +157,23 @@ public class SchedulerController {
JSONArray array = new JSONArray(); JSONArray array = new JSONArray();
array.set(jsonObject); array.set(jsonObject);
processClient.createProcessDefinition(projectCode, processName, taskCode, array.toString()); processClient.createProcessDefinition(projectCode, processName, taskCode, array.toString());
return Result.succeed(Status.DS_ADD_WORK_FLOW_DEFINITION_SUCCESS); return Result.succeed(Status.DS_ADD_WORK_FLOW_DEFINITION_SUCCESS);
} else { }
if (process.getReleaseState() == ReleaseState.ONLINE) { if (process.getReleaseState() == ReleaseState.ONLINE) {
return Result.failed(Status.DS_WORK_FLOW_DEFINITION_ONLINE, (Object) processName); return Result.failed(Status.DS_WORK_FLOW_DEFINITION_ONLINE, (Object) processName);
} }
long processCode = process.getCode();
TaskMainInfo taskDefinitionInfo = taskClient.getTaskMainInfo(projectCode, processName, taskName); TaskMainInfo taskDefinitionInfo = taskClient.getTaskMainInfo(projectCode, processName, taskName);
if (taskDefinitionInfo != null) { if (taskDefinitionInfo != null) {
return Result.failed(Status.DS_WORK_FLOW_DEFINITION_TASK_NAME_EXIST, processName, taskName); return Result.failed(Status.DS_WORK_FLOW_DEFINITION_TASK_NAME_EXIST, processName, taskName);
} }
String taskDefinitionJsonObj = JSONUtil.toJsonStr(taskRequest); String taskDefinitionJsonObj = JSONUtil.toJsonStr(taskRequest);
taskClient.createTaskDefinition(projectCode, processCode, upstreamCodes, taskDefinitionJsonObj); taskClient.createTaskDefinition(projectCode, process.getCode(), upstreamCodes, taskDefinitionJsonObj);
return Result.succeed(Status.DS_ADD_TASK_DEFINITION_SUCCESS); return Result.succeed(Status.DS_ADD_TASK_DEFINITION_SUCCESS);
} }
}
/** 更新任务定义 */ /** 更新任务定义 */
@PutMapping("/task") @PutMapping("/task")
...@@ -209,46 +189,50 @@ public class SchedulerController { ...@@ -209,46 +189,50 @@ public class SchedulerController {
if (taskDefinition == null) { if (taskDefinition == null) {
return Result.failed(Status.DS_TASK_NOT_EXIST); return Result.failed(Status.DS_TASK_NOT_EXIST);
} }
if (!"DINKY".equals(taskDefinition.getTaskType())) {
if (!TASK_TYPE.equals(taskDefinition.getTaskType())) {
return Result.failed(Status.DS_TASK_TYPE_NOT_SUPPORT, (Object) taskDefinition.getTaskType()); return Result.failed(Status.DS_TASK_TYPE_NOT_SUPPORT, (Object) taskDefinition.getTaskType());
} }
DagData dagData = processClient.getProcessDefinitionInfo(projectCode, processCode); DagData dagData = processClient.getProcessDefinitionInfo(projectCode, processCode);
if (dagData == null) { if (dagData == null) {
return Result.failed(Status.DS_WORK_FLOW_DEFINITION_NOT_EXIST); return Result.failed(Status.DS_WORK_FLOW_DEFINITION_NOT_EXIST);
} }
ProcessDefinition process = dagData.getProcessDefinition(); ProcessDefinition process = dagData.getProcessDefinition();
if (process == null) { if (process == null) {
return Result.failed(Status.DS_WORK_FLOW_DEFINITION_NOT_EXIST); return Result.failed(Status.DS_WORK_FLOW_DEFINITION_NOT_EXIST);
} }
if (process.getReleaseState() == ReleaseState.ONLINE) { if (process.getReleaseState() == ReleaseState.ONLINE) {
return Result.failed(Status.DS_WORK_FLOW_DEFINITION_ONLINE, (Object) process.getName()); return Result.failed(Status.DS_WORK_FLOW_DEFINITION_ONLINE, (Object) process.getName());
} }
taskRequest.setName(taskDefinition.getName()); taskRequest.setName(taskDefinition.getName());
taskRequest.setTaskParams(taskDefinition.getTaskParams()); taskRequest.setTaskParams(taskDefinition.getTaskParams());
taskRequest.setTaskType("DINKY"); taskRequest.setTaskType(TASK_TYPE);
String taskDefinitionJsonObj = JSONUtil.toJsonStr(taskRequest); String taskDefinitionJsonObj = JSONUtil.toJsonStr(taskRequest);
taskClient.updateTaskDefinition(projectCode, taskCode, upstreamCodes, taskDefinitionJsonObj); taskClient.updateTaskDefinition(projectCode, taskCode, upstreamCodes, taskDefinitionJsonObj);
return Result.succeed(Status.MODIFY_SUCCESS); return Result.succeed(Status.MODIFY_SUCCESS);
} }
private void getDinkyNames(List<String> lists, Catalogue catalogue, int i) { private String getDinkyNames(Catalogue catalogue, int i) {
if (i == 3) { if (i == 3 || catalogue.getParentId().equals(0)) {
return; return "";
}
if (catalogue.getParentId().equals(0)) {
return;
} }
catalogue = catalogueService.getById(catalogue.getParentId()); catalogue = catalogueService.getById(catalogue.getParentId());
if (catalogue == null) { if (catalogue == null) {
throw new SchedulerException("Get Node List Error"); throw new SchedulerException("Get Node List Error");
} }
if (i == 0) {
lists.add(catalogue.getName() + ":" + catalogue.getId()); String name = i == 0 ? catalogue.getName() + ":" + catalogue.getId() : catalogue.getName();
} else { String next = getDinkyNames(catalogue, ++i);
lists.add(catalogue.getName());
if (Strings.isNullOrEmpty(next)) {
return name;
} }
getDinkyNames(lists, catalogue, ++i); return name + "_" + next;
} }
} }
...@@ -116,9 +116,9 @@ public class SystemInit implements ApplicationRunner { ...@@ -116,9 +116,9 @@ public class SystemInit implements ApplicationRunner {
systemConfiguration.getResourcesHdfsDefaultFS(), systemConfiguration.getResourcesHdfsDefaultFS(),
systemConfiguration.getResourcesOssAccessKey(), systemConfiguration.getResourcesOssAccessKey(),
systemConfiguration.getResourcesOssRegion()) systemConfiguration.getResourcesOssRegion())
.forEach(x -> { .forEach(x -> x.addParameterCheck(y -> {
x.addParameterCheck((y) -> { if (Boolean.TRUE.equals(
if (systemConfiguration.getResourcesEnable().getValue()) { systemConfiguration.getResourcesEnable().getValue())) {
switch (systemConfiguration.getResourcesModel().getValue()) { switch (systemConfiguration.getResourcesModel().getValue()) {
case OSS: case OSS:
OssProperties ossProperties = new OssProperties(); OssProperties ossProperties = new OssProperties();
...@@ -137,8 +137,7 @@ public class SystemInit implements ApplicationRunner { ...@@ -137,8 +137,7 @@ public class SystemInit implements ApplicationRunner {
ossProperties.setRegion(systemConfiguration ossProperties.setRegion(systemConfiguration
.getResourcesOssRegion() .getResourcesOssRegion()
.getValue()); .getValue());
Singleton.get(OssResourceManager.class) Singleton.get(OssResourceManager.class).setOssTemplate(new OssTemplate(ossProperties));
.setOssTemplate(new OssTemplate(ossProperties));
break; break;
case HDFS: case HDFS:
final Configuration configuration = new Configuration(); final Configuration configuration = new Configuration();
...@@ -160,8 +159,7 @@ public class SystemInit implements ApplicationRunner { ...@@ -160,8 +159,7 @@ public class SystemInit implements ApplicationRunner {
} }
} }
} }
}); }));
});
} }
/** init task monitor */ /** init task monitor */
...@@ -181,7 +179,8 @@ public class SystemInit implements ApplicationRunner { ...@@ -181,7 +179,8 @@ public class SystemInit implements ApplicationRunner {
.getAllConfiguration() .getAllConfiguration()
.get("dolphinscheduler") .get("dolphinscheduler")
.forEach(c -> c.addParameterCheck(v -> { .forEach(c -> c.addParameterCheck(v -> {
if (systemConfiguration.getDolphinschedulerEnable().getValue()) { if (Boolean.TRUE.equals(
systemConfiguration.getDolphinschedulerEnable().getValue())) {
if (StrUtil.isEmpty(Convert.toStr(v))) { if (StrUtil.isEmpty(Convert.toStr(v))) {
sysConfigService.updateSysConfigByKv( sysConfigService.updateSysConfigByKv(
systemConfiguration systemConfiguration
......
...@@ -173,9 +173,7 @@ public class Configuration<T> implements Serializable { ...@@ -173,9 +173,7 @@ public class Configuration<T> implements Serializable {
} }
public void runParameterCheck() { public void runParameterCheck() {
getParameterCheckConsumer().forEach(x -> { getParameterCheckConsumer().forEach(x -> x.accept(getValue()));
x.accept(getValue());
});
} }
public void runChangeEvent() { public void runChangeEvent() {
......
...@@ -67,6 +67,7 @@ public class CustomParserImpl implements CustomParser { ...@@ -67,6 +67,7 @@ public class CustomParserImpl implements CustomParser {
return command.map(Collections::singletonList).orElse(null); return command.map(Collections::singletonList).orElse(null);
} }
@Override
public Parser getParser() { public Parser getParser() {
return parser; return parser;
} }
......
...@@ -30,9 +30,11 @@ import org.dinky.scheduler.utils.ParamUtil; ...@@ -30,9 +30,11 @@ import org.dinky.scheduler.utils.ParamUtil;
import org.dinky.scheduler.utils.ReadFileUtil; import org.dinky.scheduler.utils.ReadFileUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -57,13 +59,10 @@ public class ProcessClient { ...@@ -57,13 +59,10 @@ public class ProcessClient {
* @return {@link List<ProcessDefinition>} * @return {@link List<ProcessDefinition>}
*/ */
public List<ProcessDefinition> getProcessDefinition(Long projectCode, String processName) { public List<ProcessDefinition> getProcessDefinition(Long projectCode, String processName) {
Map<String, Object> map = new HashMap<>();
map.put("projectCode", projectCode);
String format = StrUtil.format( String format = StrUtil.format(
SystemConfiguration.getInstances().getDolphinschedulerUrl().getValue() SystemConfiguration.getInstances().getDolphinschedulerUrl().getValue()
+ "/projects/{projectCode}/process-definition", + "/projects/{projectCode}/process-definition",
map); Collections.singletonMap("projectCode", projectCode));
String content = HttpRequest.get(format) String content = HttpRequest.get(format)
.header( .header(
...@@ -95,14 +94,11 @@ public class ProcessClient { ...@@ -95,14 +94,11 @@ public class ProcessClient {
* @return {@link ProcessDefinition} * @return {@link ProcessDefinition}
*/ */
public ProcessDefinition getProcessDefinitionInfo(Long projectCode, String processName) { public ProcessDefinition getProcessDefinitionInfo(Long projectCode, String processName) {
List<ProcessDefinition> lists = getProcessDefinition(projectCode, processName); List<ProcessDefinition> lists = getProcessDefinition(projectCode, processName);
for (ProcessDefinition list : lists) { Optional<ProcessDefinition> processDefinition = lists.stream()
if (list.getName().equalsIgnoreCase(processName)) { .filter(list -> list.getName().equalsIgnoreCase(processName))
return list; .findFirst();
} return processDefinition.orElse(null);
}
return null;
} }
/** /**
...@@ -143,23 +139,16 @@ public class ProcessClient { ...@@ -143,23 +139,16 @@ public class ProcessClient {
*/ */
public ProcessDefinition createProcessDefinition( public ProcessDefinition createProcessDefinition(
Long projectCode, String processName, Long taskCode, String taskDefinitionJson) { Long projectCode, String processName, Long taskCode, String taskDefinitionJson) {
Map<String, Object> map = new HashMap<>();
map.put("projectCode", projectCode);
String format = StrUtil.format( String format = StrUtil.format(
SystemConfiguration.getInstances().getDolphinschedulerUrl().getValue() SystemConfiguration.getInstances().getDolphinschedulerUrl().getValue()
+ "/projects/{projectCode}/process-definition", + "/projects/{projectCode}/process-definition",
map); Collections.singletonMap("projectCode", projectCode));
Map<String, Object> taskMap = new HashMap<>();
taskMap.put("code", taskCode);
String taskRelationJson = ReadFileUtil.taskRelation(taskMap);
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("name", processName); params.put("name", processName);
params.put("description", "系统添加"); params.put("description", "系统添加");
params.put("tenantCode", "default"); params.put("tenantCode", "default");
params.put("taskRelationJson", taskRelationJson); params.put("taskRelationJson", ReadFileUtil.taskRelation(Collections.singletonMap("code", taskCode)));
params.put("taskDefinitionJson", taskDefinitionJson); params.put("taskDefinitionJson", taskDefinitionJson);
params.put("executionType", "PARALLEL"); params.put("executionType", "PARALLEL");
......
...@@ -95,9 +95,8 @@ public class ProjectClient { ...@@ -95,9 +95,8 @@ public class ProjectClient {
.execute() .execute()
.body(); .body();
Project pageBeanAndFindByName = null;
try { try {
pageBeanAndFindByName = MyJSONUtil.toPageBeanAndFindByName( return MyJSONUtil.toPageBeanAndFindByName(
content, content,
SystemConfiguration.getInstances() SystemConfiguration.getInstances()
.getDolphinschedulerProjectName() .getDolphinschedulerProjectName()
...@@ -107,7 +106,5 @@ public class ProjectClient { ...@@ -107,7 +106,5 @@ public class ProjectClient {
SystemConfiguration.getInstances().getDolphinschedulerEnable().setValue(false); SystemConfiguration.getInstances().getDolphinschedulerEnable().setValue(false);
throw new RuntimeException(content); throw new RuntimeException(content);
} }
return pageBeanAndFindByName;
} }
} }
...@@ -826,7 +826,7 @@ export default { ...@@ -826,7 +826,7 @@ export default {
'地址必须和DolphinScheduler后台配置的地址一致,eg: http://127.0.0.1:12345/dolphinscheduler', '地址必须和DolphinScheduler后台配置的地址一致,eg: http://127.0.0.1:12345/dolphinscheduler',
'sys.dolphinscheduler.settings.token': 'DolphinScheduler Token', 'sys.dolphinscheduler.settings.token': 'DolphinScheduler Token',
'sys.dolphinscheduler.settings.token.note': 'sys.dolphinscheduler.settings.token.note':
'DolphinScheduler的Token,请在DolphinScheduler的安全中心->Token管理中创建一个token,并填入该配置中', 'DolphinScheduler的Token,请在DolphinScheduler的安全中心->令牌管理中创建一个token,并填入该配置中',
'sys.dolphinscheduler.settings.projectName': 'DolphinScheduler 项目名', 'sys.dolphinscheduler.settings.projectName': 'DolphinScheduler 项目名',
'sys.dolphinscheduler.settings.projectName.note': 'sys.dolphinscheduler.settings.projectName.note':
'DolphinScheduler 中指定的项目名称,不区分大小写', 'DolphinScheduler 中指定的项目名称,不区分大小写',
......
...@@ -285,7 +285,14 @@ const DataStudio = (props: any) => { ...@@ -285,7 +285,14 @@ const DataStudio = (props: any) => {
<PersistGate loading={null} persistor={persist}> <PersistGate loading={null} persistor={persist}>
<div style={{ marginInline: -10, marginTop: -6, width: size.width }}> <div style={{ marginInline: -10, marginTop: -6, width: size.width }}>
<SecondHeaderContainer size={size} activeBreadcrumbTitle={activeBreadcrumbTitle} /> <SecondHeaderContainer size={size} activeBreadcrumbTitle={activeBreadcrumbTitle} />
<Layout hasSider style={{ minHeight: size.contentHeight, paddingInline: 0 }}> <Layout
hasSider
style={{
minHeight: size.contentHeight,
maxHeight: size.contentHeight,
paddingInline: 0
}}
>
<Sider collapsed collapsedWidth={40}> <Sider collapsed collapsedWidth={40}>
<div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}> <div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
{LeftTopMenu} {LeftTopMenu}
...@@ -293,7 +300,7 @@ const DataStudio = (props: any) => { ...@@ -293,7 +300,7 @@ const DataStudio = (props: any) => {
</div> </div>
</Sider> </Sider>
<Content style={{ display: 'flex', flexDirection: 'column' }}> <Content style={{ display: 'flex', flexDirection: 'column', minWidth: 0 }}>
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<LeftContainer size={size} /> <LeftContainer size={size} />
<Content <Content
......
...@@ -12,9 +12,9 @@ export type VerticesTableListItem = { ...@@ -12,9 +12,9 @@ export type VerticesTableListItem = {
status: string; status: string;
metrics: any; metrics: any;
parallelism: number; parallelism: number;
startTime: string; startTime?: string;
duration: number; duration?: number;
endTime: string; endTime?: string;
tasks: any; tasks: any;
}; };
...@@ -24,7 +24,7 @@ export type VerticesTableListItem = { ...@@ -24,7 +24,7 @@ export type VerticesTableListItem = {
* @param {JobProps} props - The component props containing the job detail. * @param {JobProps} props - The component props containing the job detail.
* @returns {JSX.Element} - The rendered JobConfigTab component. * @returns {JSX.Element} - The rendered JobConfigTab component.
*/ */
const FlinkTable = (props: JobProps) => { const FlinkTable = (props: JobProps): JSX.Element => {
const { jobDetail } = props; const { jobDetail } = props;
const columns: ProColumns<VerticesTableListItem>[] = [ const columns: ProColumns<VerticesTableListItem>[] = [
...@@ -104,7 +104,7 @@ const FlinkTable = (props: JobProps) => { ...@@ -104,7 +104,7 @@ const FlinkTable = (props: JobProps) => {
<ProTable <ProTable
columns={columns} columns={columns}
style={{ width: '100%' }} style={{ width: '100%' }}
dataSource={jobDetail?.jobHistory?.job.vertices} dataSource={jobDetail?.jobHistory?.job?.vertices}
rowKey='name' rowKey='name'
pagination={{ pagination={{
defaultPageSize: 10, defaultPageSize: 10,
......
...@@ -69,7 +69,7 @@ const JobDesc = (props: JobProps) => { ...@@ -69,7 +69,7 @@ const JobDesc = (props: JobProps) => {
<Descriptions.Item label={l('devops.jobinfo.config.RestartStrategy')}> <Descriptions.Item label={l('devops.jobinfo.config.RestartStrategy')}>
<Tag color='blue' title={'Restart Strategy'}> <Tag color='blue' title={'Restart Strategy'}>
{jobDetail?.jobHistory?.config['execution-config']['restart-strategy']} {jobDetail?.jobHistory?.config?.['execution-config']?.['restart-strategy']}
</Tag> </Tag>
</Descriptions.Item> </Descriptions.Item>
...@@ -116,7 +116,7 @@ const JobDesc = (props: JobProps) => { ...@@ -116,7 +116,7 @@ const JobDesc = (props: JobProps) => {
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label={l('devops.jobinfo.config.JobParallelism')}> <Descriptions.Item label={l('devops.jobinfo.config.JobParallelism')}>
{jobDetail?.jobHistory?.config['execution-config']['job-parallelism']} {jobDetail?.jobHistory?.config?.['execution-config']?.['job-parallelism']}
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label={l('global.table.useTime')}> <Descriptions.Item label={l('global.table.useTime')}>
......
...@@ -52,7 +52,6 @@ const JarList: React.FC<JarListProps> = (props) => { ...@@ -52,7 +52,6 @@ const JarList: React.FC<JarListProps> = (props) => {
/** /**
* columns * columns
* @type {({copyable: boolean, dataIndex: string, tooltip: any, title: any, render: (dom: any, record: BuildJarList) => JSX.Element} | {dataIndex: string, valueType: string} | {copyable: boolean, dataIndex: string, title: any})[]}
*/ */
const columns: ProColumns<BuildJarList>[] = [ const columns: ProColumns<BuildJarList>[] = [
{ {
...@@ -85,9 +84,7 @@ const JarList: React.FC<JarListProps> = (props) => { ...@@ -85,9 +84,7 @@ const JarList: React.FC<JarListProps> = (props) => {
* @param {BuildJarList} record * @param {BuildJarList} record
* @returns {JSX.Element} * @returns {JSX.Element}
*/ */
const renderUdf = (record: BuildJarList) => { const renderUdf = (record: BuildJarList): JSX.Element => (
return (
<>
<ProList <ProList
dataSource={record.classList as any[]} dataSource={record.classList as any[]}
rowKey='index' rowKey='index'
...@@ -105,16 +102,14 @@ const JarList: React.FC<JarListProps> = (props) => { ...@@ -105,16 +102,14 @@ const JarList: React.FC<JarListProps> = (props) => {
); );
}} }}
/> />
</>
); );
};
/** /**
* drag sort call * drag sort call
* @param {BuildJarList[]} newDataSource * @param {BuildJarList[]} newDataSource
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
const handleDragSortEnd = async (newDataSource: BuildJarList[]) => { const handleDragSortEnd = async (newDataSource: BuildJarList[]): Promise<void> => {
setLoading(true); setLoading(true);
const updatedItems = newDataSource.map((item: BuildJarList, index: number) => ({ const updatedItems = newDataSource.map((item: BuildJarList, index: number) => ({
...item, ...item,
...@@ -133,7 +128,6 @@ const JarList: React.FC<JarListProps> = (props) => { ...@@ -133,7 +128,6 @@ const JarList: React.FC<JarListProps> = (props) => {
* render * render
*/ */
return ( return (
<>
<DragSortTable<BuildJarList> <DragSortTable<BuildJarList>
style={{ style={{
overflowY: 'auto', overflowY: 'auto',
...@@ -161,7 +155,6 @@ const JarList: React.FC<JarListProps> = (props) => { ...@@ -161,7 +155,6 @@ const JarList: React.FC<JarListProps> = (props) => {
dragSortKey={'orderLine'} dragSortKey={'orderLine'}
onDragSortEnd={handleDragSortEnd} onDragSortEnd={handleDragSortEnd}
/> />
</>
); );
}; };
......
...@@ -128,20 +128,20 @@ const ProjectProTable: React.FC = () => { ...@@ -128,20 +128,20 @@ const ProjectProTable: React.FC = () => {
* @param {Partial<GitProject>} value * @param {Partial<GitProject>} value
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
const handleEdit = async (value: Partial<GitProject>) => { const handleEdit = async (value: Partial<GitProject>): Promise<void> =>
setGitProjectStatus((prevState) => ({ ...prevState, value: value, editOpen: true })); setGitProjectStatus((prevState) => ({ ...prevState, value: value, editOpen: true }));
};
/** /**
* drag sort call * drag sort call
* @param {GitProject[]} newDataSource * @param {GitProject[]} newDataSource
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
const handleDragSortEnd = async (newDataSource: GitProject[]) => { const handleDragSortEnd = async (newDataSource: GitProject[]): Promise<void> => {
const updatedItems = newDataSource.map((item: GitProject, index: number) => ({ const updatedItems = newDataSource.map((item: GitProject, index: number) => ({
...item, ...item,
orderLine: index + 1 orderLine: index + 1
})); }));
await executeAndCallback(async () => await executeAndCallback(async () =>
handleOption(API_CONSTANTS.GIT_DRAGEND_SORT_PROJECT, l('rc.gp.ucl.projectOrder'), { handleOption(API_CONSTANTS.GIT_DRAGEND_SORT_PROJECT, l('rc.gp.ucl.projectOrder'), {
sortList: updatedItems sortList: updatedItems
......
...@@ -66,18 +66,18 @@ const ResourceOverView: React.FC = () => { ...@@ -66,18 +66,18 @@ const ResourceOverView: React.FC = () => {
}); });
const refreshTreeData = async (pid: number, path: string) => { const refreshTreeData = async (pid: number, path: string) => {
const data = await queryDataByParams(API_CONSTANTS.RESOURCE_SHOW_TREE, { const data = await queryDataByParams<any[]>(API_CONSTANTS.RESOURCE_SHOW_TREE, {
pid: pid pid: pid
}); });
setResourceState((prevState) => ({ setResourceState((prevState) => ({
...prevState, ...prevState,
treeData: updateTreeData(prevState.treeData, path, data) treeData: updateTreeData(prevState.treeData, path, data ?? [])
})); }));
}; };
const refreshTree = async () => { const refreshTree = async () => {
await queryDataByParams(API_CONSTANTS.RESOURCE_SHOW_TREE, { pid: -1 }).then((res) => await queryDataByParams<any[]>(API_CONSTANTS.RESOURCE_SHOW_TREE, { pid: -1 }).then((res) =>
setResourceState((prevState) => ({ ...prevState, treeData: res })) setResourceState((prevState) => ({ ...prevState, treeData: res ?? [] }))
); );
}; };
...@@ -91,9 +91,9 @@ const ResourceOverView: React.FC = () => { ...@@ -91,9 +91,9 @@ const ResourceOverView: React.FC = () => {
*/ */
const queryContent = useCallback( const queryContent = useCallback(
async (id: number) => { async (id: number) => {
await queryDataByParams(API_CONSTANTS.RESOURCE_GET_CONTENT_BY_ID, { await queryDataByParams<string>(API_CONSTANTS.RESOURCE_GET_CONTENT_BY_ID, {
id id
}).then((res) => setResourceState((prevState) => ({ ...prevState, content: res }))); }).then((res) => setResourceState((prevState) => ({ ...prevState, content: res ?? '' })));
}, },
[resourceState.clickedNode] [resourceState.clickedNode]
); );
...@@ -103,7 +103,7 @@ const ResourceOverView: React.FC = () => { ...@@ -103,7 +103,7 @@ const ResourceOverView: React.FC = () => {
* @param info * @param info
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
const handleNodeClick = async (info: any) => { const handleNodeClick = async (info: any): Promise<void> => {
const { const {
node: { id, isLeaf, key }, node: { id, isLeaf, key },
node node
......
...@@ -57,8 +57,10 @@ const SettingOverView = () => { ...@@ -57,8 +57,10 @@ const SettingOverView = () => {
}); });
const fetchData = async () => { const fetchData = async () => {
await queryDataByParams(API_CONSTANTS.SYSTEM_GET_ALL_CONFIG).then((res) => { await queryDataByParams<Settings>(API_CONSTANTS.SYSTEM_GET_ALL_CONFIG).then((res) => {
if (res) {
setData(res); setData(res);
}
}); });
}; };
...@@ -67,11 +69,12 @@ const SettingOverView = () => { ...@@ -67,11 +69,12 @@ const SettingOverView = () => {
}, []); }, []);
const handleSaveSubmit = async (dataConfig: BaseConfigProperties) => { const handleSaveSubmit = async (dataConfig: BaseConfigProperties) => {
const { code } = await handleOption( const { code } =
(await handleOption(
API_CONSTANTS.SYSTEM_MODIFY_CONFIG, API_CONSTANTS.SYSTEM_MODIFY_CONFIG,
l('sys.setting.modify', '', { key: l(`sys.${dataConfig.key}`) }), l('sys.setting.modify', '', { key: l(`sys.${dataConfig.key}`) }),
dataConfig dataConfig
); )) ?? {};
if (code === RESPONSE_CODE.ERROR) { if (code === RESPONSE_CODE.ERROR) {
await fetchData(); await fetchData();
......
...@@ -405,7 +405,7 @@ export function parseNumStr(num: number) { ...@@ -405,7 +405,7 @@ export function parseNumStr(num: number) {
* @param {number} second_time * @param {number} second_time
* @returns {any} * @returns {any}
*/ */
export function parseMilliSecondStr(second_time: number) { export function parseMilliSecondStr(second_time: number | undefined) {
if (second_time == null) { if (second_time == null) {
return 'None'; return 'None';
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment