he2802 3 роки тому
батько
коміт
d1094fc0b9

+ 48 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/goods/GoodsCourseController.java

@@ -0,0 +1,48 @@
+package com.zhongzheng.controller.goods;
+
+import com.zhongzheng.common.annotation.Log;
+import com.zhongzheng.common.core.controller.BaseController;
+import com.zhongzheng.common.core.domain.AjaxResult;
+import com.zhongzheng.common.core.page.TableDataInfo;
+import com.zhongzheng.common.enums.BusinessType;
+import com.zhongzheng.modules.course.vo.CourseVo;
+import com.zhongzheng.modules.goods.bo.GoodsCourseAddBo;
+import com.zhongzheng.modules.goods.service.IGoodsCourseService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * 商品课程关系Controller
+ *
+ * @author hjl
+ * @date 2021-10-12
+ */
+@Api(value = "商品课程关系控制器", tags = {"商品课程关系管理"})
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
+@RestController
+@RequestMapping("/app/common/goods/course")
+public class GoodsCourseController extends BaseController {
+
+    private final IGoodsCourseService iGoodsCourseService;
+
+    /**
+     * 查询商品课程关系列表
+     */
+    @ApiOperation("查询商品课程关系列表")
+    @GetMapping("/list/{id}")
+    public TableDataInfo<CourseVo> list(@PathVariable Long id) {
+        startPage();
+        List<CourseVo> list = iGoodsCourseService.selectList(id);
+        return getDataTable(list);
+    }
+
+
+
+}

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/GoodsQueryBo.java

@@ -136,4 +136,7 @@ GoodsQueryBo extends BaseEntity {
 	/** 学习次数 */
 	@ApiModelProperty("学习次数")
 	private Long studyCount;
+
+	@ApiModelProperty("科目ID")
+	private Integer subjectId;
 }

+ 3 - 1
zhongzheng-system/src/main/resources/mapper/modules/goods/GoodsCourseMapper.xml

@@ -41,6 +41,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="sort" column="g_sort"/>
     </resultMap>
 
+
+
+
     <select id="selectList" parameterType="Long" resultMap="CourseResultVo">
         SELECT
         c.*,
@@ -62,6 +65,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         LEFT JOIN course_subject cs ON cs.id = c.subject_id
         WHERE
         gc.goods_id = #{goodsId} AND c.`status` = 1
-
     </select>
 </mapper>

+ 20 - 0
zhongzheng-system/src/main/resources/mapper/modules/goods/GoodsMapper.xml

@@ -127,6 +127,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         LEFT JOIN school s ON s.id = g.school_id
         LEFT JOIN major m ON g.major_id = m.id
         LEFT JOIN order_input_template ot ON cb.template_status = ot.id
+        <if test="goodsType ==1 and subjectId >0">
+            LEFT JOIN goods_course gc ON gc.goods_id = g.goods_id
+            LEFT JOIN course c ON gc.course_id = c.course_id
+        </if>
+        <if test="goodsType ==2 and subjectId >0">
+            LEFT JOIN goods_attached ga on g.goods_id = ga.goods_id
+            LEFT JOIN question_business qb on ga.major_id = qb.major_id
+        </if>
         WHERE
         1 = 1
         <if test="status != null and status.size()!=0 ">
@@ -171,6 +179,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="studyStartTime != null and studyStartTime != '' and studyEndTime != null and studyEndTime != ''">
             and #{studyStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{studyEndTime} BETWEEN g.validity_start_time and g.validity_end_time
         </if>
+        <if test="goodsType ==1 and subjectId >0">
+            AND c.`status` = 1
+            AND c.subject_id = #{subjectId}
+        </if>
+        <if test="goodsType ==2 and subjectId >0">
+            AND ((
+            qb.type = 4
+            AND ga.type = 1
+            )
+            OR ( qb.type = 3 AND ga.type = 2 )
+            OR ( qb.type = 2 AND ga.type = 3 )) AND qb.subject_id = #{subjectId}
+        </if>
         ORDER BY g.update_time DESC
     </select>