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 4 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 * delete schedule by id
* *
* @param loginUser login user * @param loginUser login user
* @param projectName project name * @param projectCode project code
* @param scheduleId scheule id * @param scheduleId scheule id
* @return delete result code * @return delete result code
*/ */
@ -262,10 +262,10 @@ public class SchedulerController extends BaseController {
@ApiException(DELETE_SCHEDULE_CRON_BY_ID_ERROR) @ApiException(DELETE_SCHEDULE_CRON_BY_ID_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser") @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result deleteScheduleById(@RequestAttribute(value = SESSION_USER) User 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 @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); return returnDataList(result);
} }
@ -273,7 +273,7 @@ public class SchedulerController extends BaseController {
* query schedule list * query schedule list
* *
* @param loginUser login user * @param loginUser login user
* @param projectName project name * @param projectCode project code
* @return schedule list * @return schedule list
*/ */
@ApiOperation(value = "queryScheduleList", notes = "QUERY_SCHEDULE_LIST_NOTES") @ApiOperation(value = "queryScheduleList", notes = "QUERY_SCHEDULE_LIST_NOTES")
@ -281,8 +281,8 @@ public class SchedulerController extends BaseController {
@ApiException(QUERY_SCHEDULE_LIST_ERROR) @ApiException(QUERY_SCHEDULE_LIST_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser") @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result queryScheduleList(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, public Result queryScheduleList(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName) { @ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode) {
Map<String, Object> result = schedulerService.queryScheduleList(loginUser, projectName); Map<String, Object> result = schedulerService.queryScheduleList(loginUser, projectCode);
return returnDataList(result); return returnDataList(result);
} }
@ -290,7 +290,6 @@ public class SchedulerController extends BaseController {
* preview schedule * preview schedule
* *
* @param loginUser login user * @param loginUser login user
* @param projectName project name
* @param schedule schedule expression * @param schedule schedule expression
* @return the next five fire time * @return the next five fire time
*/ */
@ -303,10 +302,9 @@ public class SchedulerController extends BaseController {
@ApiException(PREVIEW_SCHEDULE_ERROR) @ApiException(PREVIEW_SCHEDULE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser") @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result previewSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User 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 @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); 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 * query schedule list
* *
* @param loginUser login user * @param loginUser login user
* @param projectName project name * @param projectCode project code
* @return schedule list * @return schedule list
*/ */
Map<String, Object> queryScheduleList(User loginUser, String projectName); Map<String, Object> queryScheduleList(User loginUser, long projectCode);
/** /**
* delete schedule * delete schedule
@ -129,19 +129,18 @@ public interface SchedulerService {
* delete schedule by id * delete schedule by id
* *
* @param loginUser login user * @param loginUser login user
* @param projectName project name * @param projectCode project code
* @param scheduleId scheule id * @param scheduleId scheule id
* @return delete result code * @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 * preview schedule
* *
* @param loginUser login user * @param loginUser login user
* @param projectName project name
* @param schedule schedule expression * @param schedule schedule expression
* @return the next five fire time * @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 * query schedule list
* *
* @param loginUser login user * @param loginUser login user
* @param projectName project name * @param projectCode project code
* @return schedule list * @return schedule list
*/ */
@Override @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<>(); Map<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByName(projectName); Project project = projectMapper.queryByCode(projectCode);
// check project auth // check project auth
boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result); boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result);
@ -460,7 +460,7 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
return result; return result;
} }
List<Schedule> schedules = scheduleMapper.querySchedulerListByProjectName(projectName); List<Schedule> schedules = scheduleMapper.querySchedulerListByProjectName(project.getName());
result.put(Constants.DATA_LIST, schedules); result.put(Constants.DATA_LIST, schedules);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
@ -516,17 +516,17 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
* delete schedule by id * delete schedule by id
* *
* @param loginUser login user * @param loginUser login user
* @param projectName project name * @param projectCode project code
* @param scheduleId scheule id * @param scheduleId scheule id
* @return delete result code * @return delete result code
*/ */
@Override @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<>(); 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); Status resultEnum = (Status) checkResult.get(Constants.STATUS);
if (resultEnum != Status.SUCCESS) { if (resultEnum != Status.SUCCESS) {
return checkResult; return checkResult;
@ -566,12 +566,11 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
* preview schedule * preview schedule
* *
* @param loginUser login user * @param loginUser login user
* @param projectName project name
* @param schedule schedule expression * @param schedule schedule expression
* @return the next five fire time * @return the next five fire time
*/ */
@Override @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<>(); Map<String, Object> result = new HashMap<>();
CronExpression cronExpression; CronExpression cronExpression;
ScheduleParam scheduleParam = JSONUtils.parseObject(schedule, ScheduleParam.class); 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()); logger.info(mvcResult.getResponse().getContentAsString());
} }
@Test @Test
public void testQueryScheduleList() throws Exception { 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)) .header(SESSION_ID, sessionId))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
@ -197,10 +198,12 @@ public class SchedulerControllerTest extends AbstractControllerTest {
logger.info(mvcResult.getResponse().getContentAsString()); logger.info(mvcResult.getResponse().getContentAsString());
} }
@Test @Test
public void testPreviewSchedule() throws Exception { 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) .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 * * ? *'}")) .param("schedule","{'startTime':'2019-06-10 00:00:00','endTime':'2019-06-13 00:00:00','crontab':'0 0 3/6 * * ? *'}"))
.andExpect(status().isCreated()) .andExpect(status().isCreated())
@ -217,7 +220,10 @@ public class SchedulerControllerTest extends AbstractControllerTest {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("scheduleId","37"); 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) .header(SESSION_ID, sessionId)
.params(paramsMap)) .params(paramsMap))
.andExpect(status().isOk()) .andExpect(status().isOk())

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

@ -567,7 +567,7 @@ export default {
*/ */
previewSchedule ({ state }, payload) { previewSchedule ({ state }, payload) {
return new Promise((resolve, reject) => { 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) resolve(res.data)
// alert(res.data) // alert(res.data)
}).catch(e => { }).catch(e => {
@ -827,7 +827,7 @@ export default {
*/ */
deleteTiming ({ state }, payload) { deleteTiming ({ state }, payload) {
return new Promise((resolve, reject) => { 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) resolve(res)
}).catch(e => { }).catch(e => {
reject(e) reject(e)

Loading…
Cancel
Save