feat: 分页接口

Signed-off-by: skyyemperor <skyyemperor@qq.com>
此提交包含在:
2022-09-30 10:37:21 +08:00
父節點 b984c8c497
當前提交 7367119d4a
共有 4 個檔案被更改,包括 30 行新增7 行删除

查看文件

@@ -121,4 +121,11 @@ public class JobController {
public Result getJobList(@RequestParam(required = false) Integer type) {
return jobService.getJobList(type);
}
@GetMapping("/list/v2")
public Result getJobList(@RequestParam(required = false) Integer type,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "100") Integer size) {
return jobService.getJobList(type, page, size);
}
}

查看文件

@@ -1,11 +1,9 @@
package com.weilab.biology.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.weilab.biology.core.data.dto.JobLessDto;
import com.weilab.biology.core.data.po.Job;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.python.modules.itertools.count;
import java.util.List;
@@ -22,4 +20,8 @@ public interface JobMapper extends BaseMapper<Job> {
List<Job> selectJobList(@Param("type") Integer type);
List<Job> selectJobListByPage(@Param("type") Integer type,
@Param("offset") Integer offset,
@Param("count") Integer count);
}

查看文件

@@ -172,6 +172,11 @@ public class JobService {
return Result.success(jobs.stream().map(JobLessDto::parseJob).collect(Collectors.toList()));
}
public Result getJobList(Integer type, Integer page, Integer size) {
List<Job> jobs = jobMapper.selectJobListByPage(type, (page - 1) * size, size);
return Result.success(jobs.stream().map(JobLessDto::parseJob).collect(Collectors.toList()));
}
/**
* 运行下一个job
*/
@@ -232,7 +237,6 @@ public class JobService {
String param1 = job.getJobId().toString();
String param2 = job.getRequestTime().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + job.getJobId();
String content = null;
switch (status) {
case WAIT: