diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java index 75210439fd..ce5b776634 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java @@ -211,8 +211,8 @@ public class SchedulerController extends BaseController { * query schedule list paging * * @param loginUser login user - * @param projectName project name - * @param processDefinitionId process definition id + * @param projectCode project code + * @param processDefinitionCode process definition code * @param pageNo page number * @param pageSize page size * @param searchVal search value @@ -230,8 +230,8 @@ public class SchedulerController extends BaseController { @ApiException(QUERY_SCHEDULE_LIST_PAGING_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result queryScheduleListPaging(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, - @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName, - @RequestParam Integer processDefinitionId, + @ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode, + @RequestParam long processDefinitionCode, @RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize) { @@ -241,7 +241,7 @@ public class SchedulerController extends BaseController { return returnDataListPaging(result); } searchVal = ParameterUtils.handleEscapes(searchVal); - result = schedulerService.querySchedule(loginUser, projectName, processDefinitionId, searchVal, pageNo, pageSize); + result = schedulerService.querySchedule(loginUser, projectCode, processDefinitionCode, searchVal, pageNo, pageSize); return returnDataListPaging(result); } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java index 92707db8f9..908f8eeb64 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java @@ -97,14 +97,15 @@ public interface SchedulerService { * query schedule * * @param loginUser login user - * @param projectName project name - * @param processDefineId process definition id + * @param projectCode project code + * @param processDefineCode process definition code * @param pageNo page number * @param pageSize page size * @param searchVal search value * @return schedule list page */ - Map querySchedule(User loginUser, String projectName, Integer processDefineId, String searchVal, Integer pageNo, Integer pageSize); + Map querySchedule(User loginUser, long projectCode, long processDefineCode, String searchVal, + Integer pageNo, Integer pageSize); /** * query schedule list diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java index 780425e562..d966413130 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java @@ -197,7 +197,6 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe * @param failureStrategy failure strategy * @param workerGroup worker group * @param processInstancePriority process instance priority - * @param scheduleStatus schedule status * @return update result code */ @Override @@ -404,19 +403,19 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe * query schedule * * @param loginUser login user - * @param projectName project name - * @param processDefineId process definition id + * @param projectCode project code + * @param processDefineCode process definition code * @param pageNo page number * @param pageSize page size * @param searchVal search value * @return schedule list page */ @Override - public Map querySchedule(User loginUser, String projectName, Integer processDefineId, String searchVal, Integer pageNo, Integer pageSize) { - + public Map querySchedule(User loginUser, long projectCode, long processDefineCode, String searchVal, + Integer pageNo, Integer pageSize) { HashMap result = new HashMap<>(); - Project project = projectMapper.queryByName(projectName); + Project project = projectMapper.queryByCode(projectCode); // check project auth boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result); @@ -424,18 +423,18 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe return result; } - ProcessDefinition processDefinition = processService.findProcessDefineById(processDefineId); + ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefineCode); if (processDefinition == null) { - putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processDefineId); + putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processDefineCode); return result; } + Page page = new Page<>(pageNo, pageSize); - IPage scheduleIPage = scheduleMapper.queryByProcessDefineIdPaging( - page, processDefineId, searchVal - ); + IPage scheduleIPage = scheduleMapper.queryByProcessDefineIdPaging(page, processDefinition.getId(), + searchVal); PageInfo pageInfo = new PageInfo<>(pageNo, pageSize); - pageInfo.setTotalCount((int) scheduleIPage.getTotal()); + pageInfo.setTotalCount((int)scheduleIPage.getTotal()); pageInfo.setLists(scheduleIPage.getRecords()); result.put(Constants.DATA_LIST, pageInfo); putMsg(result, Status.SUCCESS); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java index c68963cc6a..6f146ff4a8 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java @@ -94,10 +94,9 @@ public class AbstractControllerTest { Assert.assertTrue(StringUtils.isNotEmpty(session)); } - public Map successResult() { + public Map success() { Map serviceResult = new HashMap<>(); putMsg(serviceResult, Status.SUCCESS); - serviceResult.put(Constants.DATA_LIST, "{}"); return serviceResult; } diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java index 307d816986..1a88d63f36 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java @@ -23,14 +23,19 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import java.util.Map; + import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.SchedulerService; +import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; +import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.FailureStrategy; import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.User; import org.junit.Assert; import org.junit.Test; @@ -68,7 +73,7 @@ public class SchedulerControllerTest extends AbstractControllerTest { Mockito.when(schedulerService.insertSchedule(isA(User.class), isA(Long.class), isA(Long.class), isA(String.class), isA(WarningType.class), isA(int.class), isA(FailureStrategy.class), - isA(Priority.class), isA(String.class))).thenReturn(successResult()); + isA(Priority.class), isA(String.class))).thenReturn(success()); MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/create",123) .header(SESSION_ID, sessionId) @@ -97,7 +102,7 @@ public class SchedulerControllerTest extends AbstractControllerTest { Mockito.when(schedulerService.updateSchedule(isA(User.class), isA(Long.class), isA(Integer.class), isA(String.class), isA(WarningType.class), isA(Integer.class), isA(FailureStrategy.class), - isA(Priority.class), isA(String.class))).thenReturn(successResult()); + isA(Priority.class), isA(String.class))).thenReturn(success()); MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/update",123) .header(SESSION_ID, sessionId) @@ -117,7 +122,7 @@ public class SchedulerControllerTest extends AbstractControllerTest { paramsMap.add("id","37"); Mockito.when(schedulerService.setScheduleState(isA(User.class), isA(Long.class), isA(Integer.class), - isA(ReleaseState.class))).thenReturn(successResult()); + isA(ReleaseState.class))).thenReturn(success()); MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/online",123) .header(SESSION_ID, sessionId) @@ -137,7 +142,7 @@ public class SchedulerControllerTest extends AbstractControllerTest { paramsMap.add("id","28"); Mockito.when(schedulerService.setScheduleState(isA(User.class), isA(Long.class), isA(Integer.class), - isA(ReleaseState.class))).thenReturn(successResult()); + isA(ReleaseState.class))).thenReturn(success()); MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/offline",123) .header(SESSION_ID, sessionId) @@ -151,16 +156,22 @@ public class SchedulerControllerTest extends AbstractControllerTest { logger.info(mvcResult.getResponse().getContentAsString()); } - @Test public void testQueryScheduleListPaging() throws Exception { MultiValueMap paramsMap = new LinkedMultiValueMap<>(); - paramsMap.add("processDefinitionId","40"); + paramsMap.add("processDefinitionCode","40"); paramsMap.add("searchVal","test"); paramsMap.add("pageNo","1"); paramsMap.add("pageSize","30"); - MvcResult mvcResult = mockMvc.perform(get("/projects/{projectName}/schedule/list-paging","cxc_1113") + Map mockResult = success(); + PageInfo pageInfo = new PageInfo<>(1, 10); + mockResult.put(Constants.DATA_LIST, pageInfo); + + Mockito.when(schedulerService.querySchedule(isA(User.class), isA(Long.class), isA(Long.class), + isA(String.class), isA(Integer.class), isA(Integer.class))).thenReturn(mockResult); + + MvcResult mvcResult = mockMvc.perform(get("/projects/{projectCode}/schedule/list-paging",123) .header(SESSION_ID, sessionId) .params(paramsMap)) .andExpect(status().isOk()) diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/list.vue b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/list.vue index 9f8c481be0..d730f508b5 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/list.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/list.vue @@ -243,7 +243,7 @@ * Timing manage */ _timingManage (item) { - this.$router.push({ path: `/projects/${this.projectId}/definition/list/timing/${item.id}` }) + this.$router.push({ path: `/projects/${this.projectId}/definition/list/timing/${item.code}` }) }, /** * delete diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/timing/_source/list.vue b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/timing/_source/list.vue index 8081d93e32..fca6630ecb 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/timing/_source/list.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/timing/_source/list.vue @@ -175,7 +175,7 @@ _getScheduleList (flag) { this.isLoading = !flag this.getScheduleList({ - processDefinitionId: this.$route.params.id, + processDefinitionCode: this.$route.params.code, searchVal: '', pageNo: this.pageNo, pageSize: this.pageSize diff --git a/dolphinscheduler-ui/src/js/conf/home/router/index.js b/dolphinscheduler-ui/src/js/conf/home/router/index.js index 35cb943b74..1ebe4a3a34 100644 --- a/dolphinscheduler-ui/src/js/conf/home/router/index.js +++ b/dolphinscheduler-ui/src/js/conf/home/router/index.js @@ -148,7 +148,7 @@ const router = new Router({ } }, { - path: '/projects/:projectId/definition/list/timing/:id', + path: '/projects/:projectId/definition/list/timing/:code', name: 'definition-timing-details', component: resolve => require(['../pages/projects/pages/definition/timing/index'], resolve), meta: { diff --git a/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js b/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js index 0d8e2abdef..ec78b4862b 100644 --- a/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js +++ b/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js @@ -580,7 +580,7 @@ export default { */ getScheduleList ({ state }, payload) { return new Promise((resolve, reject) => { - io.get(`projects/${state.projectName}/schedule/list-paging`, payload, res => { + io.get(`projects/${state.projectCode}/schedule/list-paging`, payload, res => { resolve(res) }).catch(e => { reject(e) diff --git a/pom.xml b/pom.xml index b4be3ddee6..668e6d5c76 100644 --- a/pom.xml +++ b/pom.xml @@ -835,6 +835,7 @@ **/api/configuration/TrafficConfigurationTest.java **/api/controller/ProcessDefinitionControllerTest.java **/api/controller/TenantControllerTest.java + **/api/controller/SchedulerControllerTest.java **/api/dto/resources/filter/ResourceFilterTest.java **/api/dto/resources/visitor/ResourceTreeVisitorTest.java **/api/enums/testGetEnum.java