Skip to content

Commit

Permalink
#452 重构代码,将未分配条件转化移入service层
Browse files Browse the repository at this point in the history
  • Loading branch information
leewcc committed Jul 12, 2018
1 parent 2002afe commit 7968519
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class JobOverviewController extends AbstractGUIController {
public SuccessResponseEntity getJobsWithCondition(final HttpServletRequest request, @PathVariable String namespace,
@RequestParam Map<String, String> condition, @RequestParam(required = false, defaultValue = "1") int page,
@RequestParam(required = false, defaultValue = "25") int size) throws SaturnJobConsoleException {
return new SuccessResponseEntity(getJobOverviewVo(namespace, condition, page, size));
return new SuccessResponseEntity(getJobOverviewByPage(namespace, condition, page, size));
}

/**
Expand All @@ -78,14 +78,11 @@ public SuccessResponseEntity getJobNames(@PathVariable String namespace) throws
return new SuccessResponseEntity(jobService.getJobNames(namespace));
}

public JobOverviewVo getJobOverviewVo(String namespace, Map<String, String> condition, int page, int size)
throws SaturnJobConsoleException {
public JobOverviewVo getJobOverviewByPage(String namespace, Map<String, String> condition, int page,
int size) throws SaturnJobConsoleException {
JobOverviewVo jobOverviewVo = new JobOverviewVo();
try {
List<JobOverviewJobVo> jobList = new ArrayList<>();
if (condition.containsKey("groups") && SaturnConstants.NO_GROUPS_LABEL.equals(condition.get("groups"))) {
condition.put("groups", "");
}
List<JobConfig> unSystemJobs = jobService.getUnSystemJobsWithCondition(namespace, condition, page, size);
if (unSystemJobs != null) {
updateJobOverviewDetail(namespace, jobList, unSystemJobs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ public List<JobConfig> getUnSystemJobs(String namespace) {
public List<JobConfig> getUnSystemJobsWithCondition(String namespace, Map<String, String> condition,
int page, int size) throws SaturnJobConsoleException {
List<JobConfig> unSystemJobs = new ArrayList<>();
convertUnallocatedCondition(condition);
List<JobConfig4DB> jobConfig4DBList = currentJobConfigService.findConfigsByNamespaceWithCondition(namespace,
condition, PageableUtil.generatePageble(page, size));
if (jobConfig4DBList != null) {
Expand All @@ -727,7 +728,13 @@ public List<JobConfig> getUnSystemJobsWithCondition(String namespace, Map<String
return unSystemJobs;
}

@Override
private void convertUnallocatedCondition(Map<String, String> condition) {
if (condition.containsKey("groups") && SaturnConstants.NO_GROUPS_LABEL.equals(condition.get("groups"))) {
condition.put("groups", "");
}
}

@Override
public int countUnSystemJobsWithCondition(String namespace, Map<String, String> condition) {
return currentJobConfigService.countConfigsByNamespaceWithCondition(namespace, condition);
}
Expand Down

0 comments on commit 7968519

Please sign in to comment.