zhaosongshan 7 mēneši atpakaļ
vecāks
revīzija
5600b40070

+ 4 - 8
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/controller/admin/ExamPaperController.java

@@ -1,5 +1,7 @@
 package vip.xiaonuo.exam.controller.admin;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import vip.xiaonuo.common.pojo.CommonResult;
 import vip.xiaonuo.exam.base.BaseApiController;
 import vip.xiaonuo.exam.base.RestResponse;
 import vip.xiaonuo.exam.domain.ExamPaper;
@@ -27,14 +29,8 @@ public class ExamPaperController extends BaseApiController {
     }
 
     @RequestMapping(value = "/page", method = RequestMethod.POST)
-    public RestResponse<PageInfo<ExamResponseVM>> pageList(@RequestBody ExamPaperPageRequestVM model) {
-        PageInfo<ExamPaper> pageInfo = examPaperService.page(model);
-        PageInfo<ExamResponseVM> page = PageInfoHelper.copyMap(pageInfo, e -> {
-            ExamResponseVM vm = modelMapper.map(e, ExamResponseVM.class);
-            vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
-            return vm;
-        });
-        return RestResponse.ok(page);
+    public CommonResult<Page<ExamPaper>> pageList(@RequestBody ExamPaperPageRequestVM model) {
+        return CommonResult.data(examPaperService.page(model));
     }
 
 

+ 3 - 1
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/mapper/ExamPaperMapper.java

@@ -1,8 +1,10 @@
 package vip.xiaonuo.exam.mapper;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import vip.xiaonuo.exam.domain.ExamPaper;
 import vip.xiaonuo.exam.domain.other.KeyValue;
 import vip.xiaonuo.exam.viewmodel.admin.exam.ExamPaperPageRequestVM;
+import vip.xiaonuo.exam.viewmodel.admin.exam.ExamResponseVM;
 import vip.xiaonuo.exam.viewmodel.student.dashboard.PaperFilter;
 import vip.xiaonuo.exam.viewmodel.student.dashboard.PaperInfo;
 import vip.xiaonuo.exam.viewmodel.student.exam.ExamPaperPageVM;
@@ -15,7 +17,7 @@ import java.util.List;
 @Mapper
 public interface ExamPaperMapper extends BaseMapper<ExamPaper> {
 
-    List<ExamPaper> page(ExamPaperPageRequestVM requestVM);
+    Page<ExamPaper> page(@Param("bo")ExamPaperPageRequestVM bo, @Param("page") Page<ExamPaper> page);
 
     List<ExamPaper> taskExamPage(ExamPaperPageRequestVM requestVM);
 

+ 9 - 8
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/mapper/mapping/ExamPaperMapper.xml

@@ -232,19 +232,20 @@
     FROM t_exam_paper
     <where>
         and deleted=0
-      <if test="id != null ">
-        and id= #{id}
+      <if test="bo.id != null ">
+        and id= #{bo.id}
       </if>
-      <if test="level != null ">
-        and grade_level= #{level}
+      <if test="bo.level != null ">
+        and grade_level= #{bo.level}
       </if>
-      <if test="subjectId != null ">
-        and subject_id= #{subjectId}
+      <if test="bo.subjectId != null ">
+        and subject_id= #{bo.subjectId}
       </if>
-      <if test="paperType != null ">
-        and paper_type= #{paperType}
+      <if test="bo.paperType != null ">
+        and paper_type= #{bo.paperType}
       </if>
     </where>
+    order by create_time desc
   </select>
 
 

+ 3 - 1
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/service/ExamPaperService.java

@@ -1,10 +1,12 @@
 package vip.xiaonuo.exam.service;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.pagehelper.PageInfo;
 import vip.xiaonuo.auth.core.pojo.SaBaseLoginUser;
 import vip.xiaonuo.exam.domain.ExamPaper;
 import vip.xiaonuo.exam.viewmodel.admin.exam.ExamPaperEditRequestVM;
 import vip.xiaonuo.exam.viewmodel.admin.exam.ExamPaperPageRequestVM;
+import vip.xiaonuo.exam.viewmodel.admin.exam.ExamResponseVM;
 import vip.xiaonuo.exam.viewmodel.student.dashboard.PaperFilter;
 import vip.xiaonuo.exam.viewmodel.student.dashboard.PaperInfo;
 import vip.xiaonuo.exam.viewmodel.student.exam.ExamPaperPageVM;
@@ -13,7 +15,7 @@ import java.util.List;
 
 public interface ExamPaperService extends BaseService<ExamPaper> {
 
-    PageInfo<ExamPaper> page(ExamPaperPageRequestVM requestVM);
+    Page<ExamPaper> page(ExamPaperPageRequestVM requestVM);
 
     PageInfo<ExamPaper> taskExamPage(ExamPaperPageRequestVM requestVM);
 

+ 6 - 4
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/service/impl/ExamPaperServiceImpl.java

@@ -29,11 +29,12 @@ import vip.xiaonuo.exam.utility.ModelMapperSingle;
 import vip.xiaonuo.exam.viewmodel.admin.exam.ExamPaperEditRequestVM;
 import vip.xiaonuo.exam.viewmodel.admin.exam.ExamPaperPageRequestVM;
 import vip.xiaonuo.exam.viewmodel.admin.exam.ExamPaperTitleItemVM;
+import vip.xiaonuo.exam.viewmodel.admin.exam.ExamResponseVM;
 import vip.xiaonuo.exam.viewmodel.admin.question.QuestionEditRequestVM;
 import vip.xiaonuo.exam.viewmodel.student.dashboard.PaperFilter;
 import vip.xiaonuo.exam.viewmodel.student.dashboard.PaperInfo;
 import vip.xiaonuo.exam.viewmodel.student.exam.ExamPaperPageVM;
-
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
@@ -62,9 +63,10 @@ public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaper> implements
 
 
     @Override
-    public PageInfo<ExamPaper> page(ExamPaperPageRequestVM requestVM) {
-        return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() ->
-                examPaperMapper.page(requestVM));
+    public Page<ExamPaper> page(ExamPaperPageRequestVM requestVM) {
+        Page<ExamPaper> page = new Page<ExamPaper>(requestVM.getCurrent(), requestVM.getSize());
+        page.setSearchCount(true); // 设置计算总记录数
+        return examPaperMapper.page(requestVM,page);
     }
 
     @Override

+ 20 - 0
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/viewmodel/admin/exam/ExamPaperPageRequestVM.java

@@ -12,6 +12,10 @@ public class ExamPaperPageRequestVM extends BasePage {
     private Integer paperType;
     private Integer taskExamId;
 
+    private Integer current;
+
+    private Integer size;
+
     public Integer getId() {
         return id;
     }
@@ -51,4 +55,20 @@ public class ExamPaperPageRequestVM extends BasePage {
     public void setTaskExamId(Integer taskExamId) {
         this.taskExamId = taskExamId;
     }
+
+    public Integer getCurrent() {
+        return current;
+    }
+
+    public void setCurrent(Integer current) {
+        this.current = current;
+    }
+
+    public Integer getSize() {
+        return size;
+    }
+
+    public void setSize(Integer size) {
+        this.size = size;
+    }
 }