| @@ -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> | ||||
		Reference in New Issue
	
	Block a user