feat: 分页接口

Signed-off-by: skyyemperor <skyyemperor@qq.com>
This commit is contained in:
skyyemperor 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:

查看文件

@ -43,8 +43,7 @@
<select id="selectNextWaitingJob" resultMap="BaseResultMap">
<include refid="JobSql"/>
WHERE status = '${@com.weilab.biology.core.data.enums.JobStatusEnum@WAIT.getKey()}'
ORDER BY request_time
LIMIT 1
ORDER BY request_time LIMIT 1
</select>
<select id="selectJobList" resultMap="BaseResultMap">
<include refid="JobLessSql"/>
@ -52,9 +51,20 @@
<if test="type != null">
AND type = #{type}
</if>
AND create_time > DATE_SUB(CURDATE(), INTERVAL 3 MONTH)
AND request_time > DATE_SUB(CURDATE(), INTERVAL 3 MONTH)
</where>
ORDER BY job_id DESC
<!-- LIMIT #{count}-->
<!-- LIMIT #{count}-->
</select>
<select id="selectJobListByPage" resultMap="BaseResultMap">
<include refid="JobLessSql"/>
<where>
<if test="type != null">
AND type = #{type}
</if>
</where>
ORDER BY job_id DESC
LIMIT #{offset}, #{count}
</select>
</mapper>