he2802 2 years ago
parent
commit
a44f0fde2b

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

@@ -76,8 +76,8 @@ public class QuestionController extends BaseController {
     @GetMapping("/list")
     public TableDataInfo<QuestionVo> list(QuestionQueryBo bo) {
         startPage();
-        List<QuestionVo> list = iQuestionService.selectListByBo(bo);
-        return getDataTable(list);
+    //    List<QuestionVo> list = ;
+        return iQuestionService.selectListByBo(bo);
     }
 
     /**

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

@@ -20,6 +20,10 @@ import java.util.List;
  * @date 2021-10-21
  */
 public interface QuestionMapper extends BaseMapper<Question> {
+    List<Long> selectListByBoBackId(QuestionQueryBo bo);
+
+    List<QuestionVo> selectListByBoWithId(QuestionQueryBo bo);
+
     List<QuestionVo> selectListByBo(QuestionQueryBo bo);
 
     List<GoodsUserQuestionVo> listGoodsUserQuestionVo(GoodsQueryBo bo);

+ 2 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IQuestionService.java

@@ -3,6 +3,7 @@ package com.zhongzheng.modules.bank.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zhongzheng.common.core.domain.entity.SysUser;
+import com.zhongzheng.common.core.page.TableDataInfo;
 import com.zhongzheng.modules.bank.bo.QuestionAddBo;
 import com.zhongzheng.modules.bank.bo.QuestionBatchDelBo;
 import com.zhongzheng.modules.bank.bo.QuestionEditBo;
@@ -32,7 +33,7 @@ public interface IQuestionService extends IService<Question> {
 	 */
 	QuestionVo queryById(Long questionId);
 
-	List<QuestionVo> selectListByBo(QuestionQueryBo bo);
+	TableDataInfo<QuestionVo> selectListByBo(QuestionQueryBo bo);
 
 
 	List<GoodsUserQuestionVo> listUserFreeGoodsList(GoodsQueryBo bo);

+ 12 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

@@ -3,6 +3,7 @@ package com.zhongzheng.modules.bank.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.http.HttpStatus;
 import com.alibaba.fastjson.JSON;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -12,6 +13,8 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.Page;
+import com.github.pagehelper.PageInfo;
+import com.zhongzheng.common.core.page.TableDataInfo;
 import com.zhongzheng.common.core.redis.RedisCache;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
@@ -150,8 +153,15 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
     }
 
     @Override
-    public List<QuestionVo> selectListByBo(QuestionQueryBo bo) {
-        return questionMapper.selectListByBo(bo);
+    public TableDataInfo<QuestionVo> selectListByBo(QuestionQueryBo bo) {
+        TableDataInfo tableDataInfo = new TableDataInfo();
+        List<Long> ids = questionMapper.selectListByBoBackId(bo);
+        bo.setIds(ids);
+        List<QuestionVo> list = questionMapper.selectListByBoWithId(bo);
+        tableDataInfo.setTotal(new PageInfo(ids).getTotal());
+        tableDataInfo.setRows(list);
+        tableDataInfo.setCode(HttpStatus.HTTP_OK);
+        return tableDataInfo;
     }
 
     @Override

+ 57 - 0
zhongzheng-system/src/main/resources/mapper/modules/bank/QuestionMapper.xml

@@ -175,6 +175,63 @@
         <result property="doExamNum" column="do_exam_num"/>
         <result property="subjectNames" column="subject_names"/>
     </resultMap>
+    <select id="selectListByBoWithId" parameterType="com.zhongzheng.modules.bank.bo.QuestionQueryBo" resultMap="QuestionResultVo">
+        SELECT
+             q.*
+        FROM
+            question q
+        where 1=1
+        <if test="ids != null and ids.size()!=0 ">
+            AND q.question_id in
+            <foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        ORDER BY q.question_id DESC
+    </select>
+    <select id="selectListByBoBackId" parameterType="com.zhongzheng.modules.bank.bo.QuestionQueryBo" resultType="Long">
+        SELECT
+        q.question_id
+        FROM
+        question q
+        LEFT JOIN question_business qb ON q.question_id = qb.major_id AND qb.type = 1
+        WHERE
+        1 = 1 AND q.status !=-1
+        <if test="status != null and status.size()!=0 ">
+            AND q.status in
+            <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+
+        <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="type != null and type != ''">
+            AND q.type = #{type}
+        </if>
+        <if test="businessId != null and businessId != ''">
+            AND qb.business_id = #{businessId}
+        </if>
+        <if test="publishStatus != null ">
+            AND q.publish_status = #{publishStatus}
+        </if>
+        <if test="prefixName != null and prefixName != ''">
+            AND q.prefix_name like concat('%', #{prefixName}, '%')
+        </if>
+        <if test="key != null and key != ''">
+            AND (q.content like concat('%', #{key}, '%') or q.prefix_name like concat('%', #{key}, '%') or q.code like concat('%', #{key}, '%'))
+        </if>
+        GROUP BY
+        q.question_id
+        <if test="pageSizeSelf != null and pageSizeSelf != ''">
+            LIMIT #{currIndex} , #{pageSizeSelf}
+        </if>
+        ORDER BY q.question_id DESC
+    </select>
 
     <select id="selectListByBo" parameterType="com.zhongzheng.modules.bank.bo.QuestionQueryBo" resultMap="QuestionResultVo">
         SELECT