Browse Source

[Fix-5778]: The scheduler list、preview、delete interface, projectName -> projectCode (#5779)

* fix: createSchedule interface, process definition id -> process definition code

* fix: add junit

* fix junit

* fix: projectName -> projectCode

* fix UT

* Optimize variable type

* fix: the updateSchedule interface, projectName -> projectCode

* fix comment

* fix: The scheduler online/offline interface, projectName -> projectCode

* fix UT

* fix: the scheduler list-page interface, projectName -> projectCode, processDefinitionId -> processDefinitionCode

* add UT

* fix: The scheduler list、preview、delete interface, projectName -> projectCode

Co-authored-by: wen-hemin <wenhemin@apache.com>
2.0.7-release
wen-hemin 3 years ago committed by GitHub
parent
commit
d2a9e05a66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
  2. 11
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java
  3. 19
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java
  4. 16
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java
  5. 4
      dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js

16
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java

@ -249,7 +249,7 @@ public class SchedulerController extends BaseController {
* delete schedule by id
*
* @param loginUser login user
* @param projectName project name
* @param projectCode project code
* @param scheduleId scheule id
* @return delete result code
*/
@ -262,10 +262,10 @@ public class SchedulerController extends BaseController {
@ApiException(DELETE_SCHEDULE_CRON_BY_ID_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result deleteScheduleById(@RequestAttribute(value = SESSION_USER) User loginUser,
@PathVariable String projectName,
@ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode,
@RequestParam("scheduleId") Integer scheduleId
) {
Map<String, Object> result = schedulerService.deleteScheduleById(loginUser, projectName, scheduleId);
Map<String, Object> result = schedulerService.deleteScheduleById(loginUser, projectCode, scheduleId);
return returnDataList(result);
}
@ -273,7 +273,7 @@ public class SchedulerController extends BaseController {
* query schedule list
*
* @param loginUser login user
* @param projectName project name
* @param projectCode project code
* @return schedule list
*/
@ApiOperation(value = "queryScheduleList", notes = "QUERY_SCHEDULE_LIST_NOTES")
@ -281,8 +281,8 @@ public class SchedulerController extends BaseController {
@ApiException(QUERY_SCHEDULE_LIST_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result queryScheduleList(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName) {
Map<String, Object> result = schedulerService.queryScheduleList(loginUser, projectName);
@ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode) {
Map<String, Object> result = schedulerService.queryScheduleList(loginUser, projectCode);
return returnDataList(result);
}
@ -290,7 +290,6 @@ public class SchedulerController extends BaseController {
* preview schedule
*
* @param loginUser login user
* @param projectName project name
* @param schedule schedule expression
* @return the next five fire time
*/
@ -303,10 +302,9 @@ public class SchedulerController extends BaseController {
@ApiException(PREVIEW_SCHEDULE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result previewSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
@RequestParam(value = "schedule") String schedule
) {
Map<String, Object> result = schedulerService.previewSchedule(loginUser, projectName, schedule);
Map<String, Object> result = schedulerService.previewSchedule(loginUser, schedule);
return returnDataList(result);
}
}

11
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java

@ -111,10 +111,10 @@ public interface SchedulerService {
* query schedule list
*
* @param loginUser login user
* @param projectName project name
* @param projectCode project code
* @return schedule list
*/
Map<String, Object> queryScheduleList(User loginUser, String projectName);
Map<String, Object> queryScheduleList(User loginUser, long projectCode);
/**
* delete schedule
@ -129,19 +129,18 @@ public interface SchedulerService {
* delete schedule by id
*
* @param loginUser login user
* @param projectName project name
* @param projectCode project code
* @param scheduleId scheule id
* @return delete result code
*/
Map<String, Object> deleteScheduleById(User loginUser, String projectName, Integer scheduleId);
Map<String, Object> deleteScheduleById(User loginUser, long projectCode, Integer scheduleId);
/**
* preview schedule
*
* @param loginUser login user
* @param projectName project name
* @param schedule schedule expression
* @return the next five fire time
*/
Map<String, Object> previewSchedule(User loginUser, String projectName, String schedule);
Map<String, Object> previewSchedule(User loginUser, String schedule);
}

19
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java

@ -446,13 +446,13 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
* query schedule list
*
* @param loginUser login user
* @param projectName project name
* @param projectCode project code
* @return schedule list
*/
@Override
public Map<String, Object> queryScheduleList(User loginUser, String projectName) {
public Map<String, Object> queryScheduleList(User loginUser, long projectCode) {
Map<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByName(projectName);
Project project = projectMapper.queryByCode(projectCode);
// check project auth
boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result);
@ -460,7 +460,7 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
return result;
}
List<Schedule> schedules = scheduleMapper.querySchedulerListByProjectName(projectName);
List<Schedule> schedules = scheduleMapper.querySchedulerListByProjectName(project.getName());
result.put(Constants.DATA_LIST, schedules);
putMsg(result, Status.SUCCESS);
@ -516,17 +516,17 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
* delete schedule by id
*
* @param loginUser login user
* @param projectName project name
* @param projectCode project code
* @param scheduleId scheule id
* @return delete result code
*/
@Override
public Map<String, Object> deleteScheduleById(User loginUser, String projectName, Integer scheduleId) {
public Map<String, Object> deleteScheduleById(User loginUser, long projectCode, Integer scheduleId) {
Map<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByName(projectName);
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, project.getName());
Status resultEnum = (Status) checkResult.get(Constants.STATUS);
if (resultEnum != Status.SUCCESS) {
return checkResult;
@ -566,12 +566,11 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
* preview schedule
*
* @param loginUser login user
* @param projectName project name
* @param schedule schedule expression
* @return the next five fire time
*/
@Override
public Map<String, Object> previewSchedule(User loginUser, String projectName, String schedule) {
public Map<String, Object> previewSchedule(User loginUser, String schedule) {
Map<String, Object> result = new HashMap<>();
CronExpression cronExpression;
ScheduleParam scheduleParam = JSONUtils.parseObject(schedule, ScheduleParam.class);

16
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java

@ -183,10 +183,11 @@ public class SchedulerControllerTest extends AbstractControllerTest {
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testQueryScheduleList() throws Exception {
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/list","cxc_1113")
Mockito.when(schedulerService.queryScheduleList(isA(User.class), isA(Long.class))).thenReturn(success());
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/list",123)
.header(SESSION_ID, sessionId))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
@ -197,10 +198,12 @@ public class SchedulerControllerTest extends AbstractControllerTest {
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testPreviewSchedule() throws Exception {
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/preview","cxc_1113")
Mockito.when(schedulerService.previewSchedule(isA(User.class), isA(String.class)))
.thenReturn(success());
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/preview",123)
.header(SESSION_ID, sessionId)
.param("schedule","{'startTime':'2019-06-10 00:00:00','endTime':'2019-06-13 00:00:00','crontab':'0 0 3/6 * * ? *'}"))
.andExpect(status().isCreated())
@ -217,7 +220,10 @@ public class SchedulerControllerTest extends AbstractControllerTest {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("scheduleId","37");
MvcResult mvcResult = mockMvc.perform(get("/projects/{projectName}/schedule/delete","cxc_1113")
Mockito.when(schedulerService.deleteScheduleById(isA(User.class), isA(Long.class), isA(Integer.class)))
.thenReturn(success());
MvcResult mvcResult = mockMvc.perform(get("/projects/{projectCode}/schedule/delete",123)
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())

4
dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js

@ -567,7 +567,7 @@ export default {
*/
previewSchedule ({ state }, payload) {
return new Promise((resolve, reject) => {
io.post(`projects/${state.projectName}/schedule/preview`, payload, res => {
io.post(`projects/${state.projectCode}/schedule/preview`, payload, res => {
resolve(res.data)
// alert(res.data)
}).catch(e => {
@ -827,7 +827,7 @@ export default {
*/
deleteTiming ({ state }, payload) {
return new Promise((resolve, reject) => {
io.get(`projects/${state.projectName}/schedule/delete`, payload, res => {
io.get(`projects/${state.projectCode}/schedule/delete`, payload, res => {
resolve(res)
}).catch(e => {
reject(e)

Loading…
Cancel
Save