浏览代码

submit:题库列表新增查询条件

yangdamao 3 年之前
父节点
当前提交
72fd774551

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/GoodsAttachedQueryBo.java

@@ -54,4 +54,6 @@ public class GoodsAttachedQueryBo extends BaseEntity {
 	private Integer isDo;
 	@ApiModelProperty("订单商品id")
 	private Long orderGoodsId;
+	@ApiModelProperty("试卷类型ID")
+	private Long paperId;
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/mapper/GoodsAttachedMapper.java

@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.modules.goods.bo.GoodsAttachedQueryBo;
 import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
 import com.zhongzheng.modules.goods.domain.GoodsAttached;
+import com.zhongzheng.modules.goods.vo.GoodsAttachedPaperVo;
 import com.zhongzheng.modules.goods.vo.GoodsAttachedVo;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -18,4 +20,6 @@ import java.util.List;
 public interface GoodsAttachedMapper extends BaseMapper<GoodsAttached> {
     List<GoodsAttachedVo> getList(GoodsAttachedQueryBo bo);
     List<GoodsAttachedVo> selectDoList(GoodsAttachedQueryBo bo);
+
+    List<GoodsAttachedPaperVo> getPaperIds(@Param("goodsId") Long goodsId);
 }

+ 16 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsAttachedServiceImpl.java

@@ -2,6 +2,8 @@ package com.zhongzheng.modules.goods.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.modules.goods.bo.GoodsAttachedAddBo;
 import com.zhongzheng.modules.goods.bo.GoodsAttachedEditBo;
@@ -10,6 +12,7 @@ import com.zhongzheng.modules.goods.domain.GoodsAttached;
 import com.zhongzheng.modules.goods.mapper.GoodsAttachedMapper;
 import com.zhongzheng.modules.goods.mapper.GoodsMapper;
 import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
+import com.zhongzheng.modules.goods.vo.GoodsAttachedPaperVo;
 import com.zhongzheng.modules.goods.vo.GoodsAttachedVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -60,7 +63,19 @@ public class GoodsAttachedServiceImpl extends ServiceImpl<GoodsAttachedMapper, G
 
     @Override
     public List<GoodsAttachedVo> getList(GoodsAttachedQueryBo bo) {
-        return goodsAttachedMapper.getList(bo);
+        List<GoodsAttachedVo> list = goodsAttachedMapper.getList(bo);
+        if (ObjectUtils.isNotNull(bo.getPaperId())){
+            List<GoodsAttachedPaperVo> paperVos = goodsAttachedMapper.getPaperIds(bo.getGoodsId());
+            if (CollectionUtils.isNotEmpty(paperVos)){
+                //需要过滤的
+                List<Long> goodsAttIds = paperVos.stream().filter(x -> x.getExamPaperId().equals(bo.getPaperId()))
+                        .map(GoodsAttachedPaperVo::getGoodsAttachedId).collect(Collectors.toList());
+                if (CollectionUtils.isNotEmpty(goodsAttIds)){
+                    list = list.stream().filter(item -> goodsAttIds.contains(item.getId())).collect(Collectors.toList());
+                }
+            }
+        }
+        return list;
     }
 
     /**

+ 24 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/vo/GoodsAttachedPaperVo.java

@@ -0,0 +1,24 @@
+package com.zhongzheng.modules.goods.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+/**
+ * 题库试卷类型Vo
+ *
+ * @author  hjl
+ * @date 2021-10-28
+ */
+@Data
+@ApiModel("题库试卷类型Vo")
+public class GoodsAttachedPaperVo {
+	private static final long serialVersionUID = 1L;
+
+	@ApiModelProperty("goodsAttachedId")
+	private Long goodsAttachedId;
+
+	@ApiModelProperty("试卷类型ID")
+	private Long examPaperId;
+}

+ 32 - 0
zhongzheng-system/src/main/resources/mapper/modules/goods/GoodsAttachedMapper.xml

@@ -309,4 +309,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 					   ga.type = 1
 					   AND ga.major_id IN ( SELECT module_exam_id FROM user_exam_record WHERE user_id = #{userId} AND order_goods_id = #{orderGoodsId} AND module_exam_id > 0 GROUP BY module_exam_id )))
 	</select>
+
+	<select id="getPaperIds" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.goods.vo.GoodsAttachedPaperVo">
+		SELECT
+			ga.id as goodsAttachedId,
+			e.exam_paper_id as examPaperId
+		FROM
+			goods_attached ga
+				LEFT JOIN question_module_chapter qmc ON ga.major_id = qmc.module_exam_id
+				LEFT JOIN question_chapter_exam qce ON qmc.chapter_exam_id = qce.chapter_exam_id
+				LEFT JOIN exam e ON qce.exam_id = e.exam_id
+		WHERE
+			ga.goods_id = #{goodsId} AND ga.type = 1
+		UNION ALL
+		SELECT
+			ga.id as goodsAttachedId,
+			e.exam_paper_id as examPaperId
+		FROM
+			goods_attached ga
+				LEFT JOIN question_chapter_exam qce ON ga.major_id = qce.chapter_exam_id
+				LEFT JOIN exam e ON qce.exam_id = e.exam_id
+		WHERE
+			ga.goods_id = #{goodsId} AND ga.type = 2
+		UNION ALL
+		SELECT
+			ga.id as goodsAttachedId,
+			e.exam_paper_id as examPaperId
+		FROM
+			goods_attached ga
+				LEFT JOIN exam e ON ga.major_id = e.exam_id
+		WHERE
+			ga.goods_id = #{goodsId} AND ga.type = 3
+	</select>
 </mapper>