From bea8021c773401dcbdfb165b7343add1065795e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=B2=BB=E5=9B=BD?= Date: Mon, 8 Apr 2024 16:40:21 +0800 Subject: [PATCH] =?UTF-8?q?Job=E6=8E=A5=E5=8F=A3=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/controller/JobController.java | 5 ++- .../manager/server/service/JobService.java | 5 ++- .../server/service/impl/JobServiceImpl.java | 32 ++++++++++--------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/JobController.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/JobController.java index f1f59be..c4bd843 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/JobController.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/JobController.java @@ -26,6 +26,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import org.apache.bigtop.manager.server.model.vo.JobVO; +import org.apache.bigtop.manager.server.model.vo.PageVO; import org.apache.bigtop.manager.server.service.JobService; import org.apache.bigtop.manager.server.utils.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -33,8 +34,6 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.List; - @Tag(name = "Job Controller") @RestController @RequestMapping("/clusters/{clusterId}/jobs") @@ -51,7 +50,7 @@ public class JobController { @Parameter(in = ParameterIn.QUERY, name = "sort", description = "asc/desc", schema = @Schema(type = "string", defaultValue = "asc")) }) @GetMapping - public ResponseEntity> list(@PathVariable Long clusterId) { + public ResponseEntity> list(@PathVariable Long clusterId) { return ResponseEntity.success(jobService.list(clusterId)); } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/JobService.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/JobService.java index 396390c..117292f 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/JobService.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/JobService.java @@ -19,12 +19,11 @@ package org.apache.bigtop.manager.server.service; import org.apache.bigtop.manager.server.model.vo.JobVO; - -import java.util.List; +import org.apache.bigtop.manager.server.model.vo.PageVO; public interface JobService { - List list(Long clusterId); + PageVO list(Long clusterId); JobVO get(Long id); } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/JobServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/JobServiceImpl.java index ba67210..e22ceb5 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/JobServiceImpl.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/JobServiceImpl.java @@ -22,12 +22,17 @@ import jakarta.annotation.Resource; import org.apache.bigtop.manager.dao.entity.Job; import org.apache.bigtop.manager.dao.repository.JobRepository; import org.apache.bigtop.manager.server.model.mapper.JobMapper; +import org.apache.bigtop.manager.server.model.query.PageQuery; import org.apache.bigtop.manager.server.model.vo.JobVO; +import org.apache.bigtop.manager.server.model.vo.PageVO; import org.apache.bigtop.manager.server.service.JobService; +import org.apache.bigtop.manager.server.utils.ClusterUtils; +import org.apache.bigtop.manager.server.utils.PageUtils; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; -import java.util.List; - @Service public class JobServiceImpl implements JobService { @@ -35,20 +40,17 @@ public class JobServiceImpl implements JobService { private JobRepository jobRepository; @Override - public List list(Long clusterId) { -// PageQuery pageQuery = PageUtils.getPageQuery(); -// Pageable pageable = PageRequest.of(pageQuery.getPageNum(), pageQuery.getPageSize(), pageQuery.getSort()); -// Page page; -// if (ClusterUtils.isNoneCluster(clusterId)) { -// page = jobRepository.findAllByClusterIsNull(pageable); -// } else { -// page = jobRepository.findAllByClusterId(clusterId, pageable); -// } -// -// return PageVO.of(page); - List jobs = jobRepository.findAllByClusterId(clusterId); + public PageVO list(Long clusterId) { + PageQuery pageQuery = PageUtils.getPageQuery(); + Pageable pageable = PageRequest.of(pageQuery.getPageNum(), pageQuery.getPageSize(), pageQuery.getSort()); + Page page; + if (ClusterUtils.isNoneCluster(clusterId)) { + page = jobRepository.findAllByClusterIsNull(pageable); + } else { + page = jobRepository.findAllByClusterId(clusterId, pageable); + } - return JobMapper.INSTANCE.fromEntity2VO(jobs); + return PageVO.of(page); } @Override -- Gitee