Przeglądaj źródła

替换分页写法

张同佳 6 miesięcy temu
rodzic
commit
4d207f8f46

+ 30 - 19
services/ruoyi-job/src/main/java/com/hdkj/lt/job/controller/SysJobController.java

@@ -1,32 +1,30 @@
 package com.hdkj.lt.job.controller;
 
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
-import org.quartz.SchedulerException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.hdkj.lt.job.domain.SysJob;
+import com.hdkj.lt.job.service.ISysJobService;
+import com.hdkj.lt.job.util.CronUtils;
+import com.hdkj.lt.job.util.ScheduleUtils;
 import com.ruoyi.common.core.constant.Constants;
+import com.ruoyi.common.core.constant.HttpStatus;
 import com.ruoyi.common.core.exception.job.TaskException;
 import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.core.utils.poi.ExcelUtil;
 import com.ruoyi.common.core.web.controller.BaseController;
 import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.ruoyi.common.core.web.page.PageDomain;
 import com.ruoyi.common.core.web.page.TableDataInfo;
+import com.ruoyi.common.core.web.page.TableSupport;
 import com.ruoyi.common.log.annotation.Log;
 import com.ruoyi.common.log.enums.BusinessType;
 import com.ruoyi.common.security.annotation.RequiresPermissions;
 import com.ruoyi.common.security.utils.SecurityUtils;
-import com.hdkj.lt.job.domain.SysJob;
-import com.hdkj.lt.job.service.ISysJobService;
-import com.hdkj.lt.job.util.CronUtils;
-import com.hdkj.lt.job.util.ScheduleUtils;
+import org.quartz.SchedulerException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 
 /**
  * 调度任务信息操作处理
@@ -47,9 +45,22 @@ public class SysJobController extends BaseController
     @GetMapping("/list")
     public TableDataInfo list(SysJob sysJob)
     {
-        startPage();
-        List<SysJob> list = jobService.selectJobList(sysJob);
-        return getDataTable(list);
+//        startPage();
+        PageDomain pageDomain = TableSupport.buildPageRequest();
+        Integer pageNum = pageDomain.getPageNum();
+        Integer pageSize = pageDomain.getPageSize();
+        Page<SysJob> page = new Page<>();
+        page.setCurrent(pageNum);
+        page.setSize(pageSize);
+        Page<SysJob> list = jobService.selectJobListPage(page, sysJob);
+//        List<SysJob> list = jobService.selectJobList(sysJob);
+        TableDataInfo tableDataInfo = new TableDataInfo();
+        tableDataInfo.setCode(HttpStatus.SUCCESS);
+        tableDataInfo.setMsg("查询成功");
+        tableDataInfo.setRows(list.getRecords());
+        tableDataInfo.setTotal(list.getTotal());
+        return tableDataInfo;
+
     }
 
     /**

+ 4 - 0
services/ruoyi-job/src/main/java/com/hdkj/lt/job/mapper/SysJobMapper.java

@@ -1,7 +1,9 @@
 package com.hdkj.lt.job.mapper;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.hdkj.lt.job.domain.SysJob;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -21,6 +23,8 @@ public interface SysJobMapper
      */
     public List<SysJob> selectJobList(SysJob job);
 
+    public Page<SysJob> selectJobListPage(Page<SysJob> page, @Param("job") SysJob job);
+
     /**
      * 查询所有调度任务
      *

+ 3 - 0
services/ruoyi-job/src/main/java/com/hdkj/lt/job/service/ISysJobService.java

@@ -2,6 +2,7 @@ package com.hdkj.lt.job.service;
 
 import java.util.List;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.hdkj.lt.job.domain.SysJob;
 import org.quartz.SchedulerException;
 import com.ruoyi.common.core.exception.job.TaskException;
@@ -21,6 +22,8 @@ public interface ISysJobService
      */
     public List<SysJob> selectJobList(SysJob job);
 
+    public Page<SysJob> selectJobListPage(Page<SysJob> page, SysJob job);
+
     /**
      * 通过调度任务ID查询调度信息
      *

+ 6 - 0
services/ruoyi-job/src/main/java/com/hdkj/lt/job/service/impl/SysJobServiceImpl.java

@@ -3,6 +3,7 @@ package com.hdkj.lt.job.service.impl;
 import java.util.List;
 import javax.annotation.PostConstruct;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.hdkj.lt.job.domain.SysJob;
 import com.hdkj.lt.job.mapper.SysJobMapper;
 import com.hdkj.lt.job.service.ISysJobService;
@@ -58,6 +59,11 @@ public class SysJobServiceImpl implements ISysJobService
         return jobMapper.selectJobList(job);
     }
 
+    @Override
+    public Page<SysJob> selectJobListPage(Page<SysJob> page, SysJob job) {
+        return jobMapper.selectJobListPage(page, job);
+    }
+
     /**
      * 通过调度任务ID查询调度信息
      *

+ 20 - 0
services/ruoyi-job/src/main/resources/mapper/SysJobMapper.xml

@@ -43,6 +43,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		</where>
 	</select>
 
+	<select id="selectJobListPage" resultType="com.hdkj.lt.job.domain.SysJob">
+		<include refid="selectJobVo"/>
+		<where>
+			<if test="job.jobName != null and job.jobName != ''">
+				AND job_name like concat('%', #{job.jobName}, '%')
+			</if>
+			<if test="job.jobGroup != null and job.jobGroup != ''">
+				AND job_group = #{job.jobGroup}
+			</if>
+			<if test="job.status != null and job.status != ''">
+				AND status = #{job.status}
+			</if>
+			<if test="job.invokeTarget != null and job.invokeTarget != ''">
+				AND invoke_target like concat('%', #{job.invokeTarget}, '%')
+			</if>
+		</where>
+	</select>
+
 	<select id="selectJobAll" resultMap="SysJobResult">
 		<include refid="selectJobVo"/>
 	</select>
@@ -52,6 +70,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		where job_id = #{jobId}
 	</select>
 
+
+
 	<delete id="deleteJobById" parameterType="Long">
  		delete from sys_job where job_id = #{jobId}
  	</delete>