Browse Source

fix 题目列表

he2802 3 years ago
parent
commit
20636eb224

+ 14 - 3
zhongzheng-admin/src/main/java/com/zhongzheng/controller/bank/QuestionController.java

@@ -3,6 +3,8 @@ package com.zhongzheng.controller.bank;
 import java.util.List;
 import java.util.Arrays;
 
+import cn.hutool.http.HttpStatus;
+import com.github.pagehelper.PageInfo;
 import com.zhongzheng.common.core.page.TableDataInfo;
 import com.zhongzheng.common.utils.poi.ExcelUtil;
 import com.zhongzheng.modules.bank.bo.QuestionAddBo;
@@ -55,10 +57,19 @@ public class QuestionController extends BaseController {
     @PreAuthorize("@ss.hasPermi('system:question:list')")
     @GetMapping("/list")
     public TableDataInfo<QuestionVo> list(QuestionQueryBo bo) {
-        startPage();
+        if(bo.getPageNum()>0){
+            bo.setCurrIndex((bo.getPageNum()-1)*bo.getPageSize());
+            bo.setPageSizeSelf(bo.getPageSize());
+            bo.setPageNum(null);
+            bo.setPageSize(null);
+        }
         List<QuestionVo> list = iQuestionService.selectList(bo);
-        TableDataInfo<QuestionVo> result = getDataTable(list);
-        return result;
+        TableDataInfo<QuestionVo> rspData = new TableDataInfo();
+        rspData.setCode(HttpStatus.HTTP_OK);
+        rspData.setMsg("查询成功");
+        rspData.setRows(list);
+        rspData.setTotal(iQuestionService.selectListCount(bo));
+        return rspData;
     }
 
     /**

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/QuestionQueryBo.java

@@ -23,6 +23,10 @@ import com.zhongzheng.common.core.domain.BaseEntity;
 @ApiModel("题库题目分页查询对象")
 public class QuestionQueryBo extends BaseEntity {
 
+	@ApiModelProperty("自定义分页大小")
+	private Integer pageSizeSelf;
+	@ApiModelProperty("偏移大小")
+	private Integer currIndex;
 	/** 分页大小 */
 	@ApiModelProperty("分页大小")
 	private Integer pageSize;

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/mapper/QuestionMapper.java

@@ -17,4 +17,5 @@ import java.util.List;
  */
 public interface QuestionMapper extends BaseMapper<Question> {
     List<QuestionVo> selectList(QuestionQueryBo bo);
+    Long selectListCount(QuestionQueryBo bo);
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IQuestionService.java

@@ -23,8 +23,11 @@ public interface IQuestionService extends IService<Question> {
 	 * @return
 	 */
 	QuestionVo queryById(Long questionId);
+
 	List<QuestionVo> selectList(QuestionQueryBo bo);
 
+	Long selectListCount(QuestionQueryBo bo);
+
 
 	/**
 	 * 查询列表

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

@@ -56,6 +56,11 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
         return questionMapper.selectList(bo);
     }
 
+    @Override
+    public Long selectListCount(QuestionQueryBo bo) {
+        return questionMapper.selectListCount(bo);
+    }
+
     @Override
     public List<QuestionVo> queryList(QuestionQueryBo bo) {
         LambdaQueryWrapper<Question> lqw = Wrappers.lambdaQuery();

+ 27 - 8
zhongzheng-system/src/main/resources/mapper/modules/bank/QuestionMapper.xml

@@ -72,13 +72,12 @@
         ek.knowledge_name,
         ek.knowledge_id
         FROM
+        (SELECT DISTINCT
+        q.*
+        FROM
         question q
-        LEFT JOIN question_business qb ON q.question_id = qb.major_id and qb.type = 1
-        LEFT JOIN course_education_type cet ON qb.education_type_id = cet.id
-        LEFT JOIN course_project_type cpt ON qb.project_id = cpt.id
-        LEFT JOIN course_business cb ON qb.business_id = cb.id
-        LEFT JOIN course_subject cs ON cs.id = qb.subject_id
-        LEFT JOIN exam_knowledge ek ON FIND_IN_SET( ek.knowledge_id, q.knowledge_ids )
+        LEFT JOIN question_business qb ON q.question_id = qb.major_id
+        AND qb.type = 1
         WHERE
         1 = 1
         <if test="status != null and status.size()!=0 ">
@@ -100,10 +99,30 @@
         <if test="prefixName != null and prefixName != ''">
             AND q.prefix_name like concat('%', #{prefixName}, '%')
         </if>
-
+        <if test="pageSizeSelf != null and pageSizeSelf != ''">
+            LIMIT #{currIndex} , #{pageSizeSelf}
+        </if>
+       )q
+        LEFT JOIN question_business qb ON q.question_id = qb.major_id and qb.type = 1
+        LEFT JOIN course_education_type cet ON qb.education_type_id = cet.id
+        LEFT JOIN course_project_type cpt ON qb.project_id = cpt.id
+        LEFT JOIN course_business cb ON qb.business_id = cb.id
+        LEFT JOIN course_subject cs ON cs.id = qb.subject_id
+        LEFT JOIN exam_knowledge ek ON FIND_IN_SET( ek.knowledge_id, q.knowledge_ids )
+        WHERE
+        1 = 1
+        <if test="educationTypeId != null and educationTypeId != ''">
+            AND qb.education_type_id = #{educationTypeId}
+        </if>
+        <if test="subjectId != null and subjectId != ''">
+            AND qb.subject_id = #{subjectId}
+        </if>
+        <if test="businessId != null and businessId != ''">
+            AND qb.business_id = #{businessId}
+        </if>
     </select>
 
-    <select id="selectList_COUNT" resultType="Long">
+    <select id="selectListCount" resultType="Long">
         SELECT
         count(distinct q.question_id)
         FROM

+ 40 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMapper.xml

@@ -118,6 +118,46 @@
         </if>
     </select>
 
+    <select id="selectList_COUNT" resultType="Long">
+        SELECT
+            c.course_id
+        FROM
+            course c
+        WHERE
+        1 = 1
+        <if test="status != null and status.size()!=0 ">
+            AND c.status in
+            <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+
+        <if test="educationTypeId != null and educationTypeId != ''">
+            AND c.education_type_id = #{educationTypeId}
+        </if>
+        <if test="subjectId != null and subjectId != ''">
+            AND c.subject_id = #{subjectId}
+        </if>
+        <if test="businessId != null and businessId != ''">
+            AND c.business_id = #{businessId}
+        </if>
+        <if test="prefixName != null and prefixName != ''">
+            AND c.prefix_name like concat('%', #{prefixName}, '%')
+        </if>
+        <if test="courseName != null and courseName != ''">
+            AND c.course_name like concat('%', #{courseName}, '%')
+        </if>
+        <if test="publishStatus != null and publishStatus != ''">
+            AND c.publish_status = #{publishStatus}
+        </if>
+        <if test="schoolId != null and schoolId != ''">
+            AND c.school_id = #{schoolId}
+        </if>
+        <if test="majorId != null and majorId != ''">
+            AND c.major_id = #{majorId}
+        </if>
+    </select>
+
     <select id="selectDetailById" parameterType="Long"  resultMap="CourseResultVo">
         SELECT
             c.*,