he2802 4 лет назад
Родитель
Сommit
36ca105eff

+ 17 - 9
zhongzheng-admin/src/main/java/com/zhongzheng/controller/goods/GoodsController.java

@@ -3,9 +3,13 @@ package com.zhongzheng.controller.goods;
 import java.util.List;
 import java.util.Arrays;
 
+import com.zhongzheng.modules.bank.bo.ExamQuestionQueryBo;
+import com.zhongzheng.modules.bank.vo.ExamQuestionVo;
 import com.zhongzheng.modules.goods.bo.*;
 import com.zhongzheng.modules.goods.domain.Goods;
+import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
+import com.zhongzheng.modules.goods.vo.GoodsAttachedVo;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import lombok.RequiredArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -41,6 +45,8 @@ public class GoodsController extends BaseController {
 
     private final IGoodsService iGoodsService;
 
+    private final IGoodsAttachedService iGoodsAttachedService;
+
     /**
      * 查询商品列表
      */
@@ -56,15 +62,7 @@ public class GoodsController extends BaseController {
     /**
      * 导出商品列表
      */
-    /*@ApiOperation("导出商品列表")
-    @PreAuthorize("@ss.hasPermi('system:goods:export')")
-    @Log(title = "商品", businessType = BusinessType.EXPORT)
-    @GetMapping("/export")
-    public AjaxResult<GoodsVo> export(GoodsQueryBo bo) {
-        List<GoodsVo> list = iGoodsService.queryList(bo);
-        ExcelUtil<GoodsVo> util = new ExcelUtil<GoodsVo>(GoodsVo.class);
-        return util.exportExcel(list, "商品");
-    }*/
+    /*selectList*/
 
     /**
      * 获取商品详细信息
@@ -131,4 +129,14 @@ public class GoodsController extends BaseController {
         return toAjax(iGoodsService.updateBankByEditBo(bo) ? 1 : 0);
     }
 
+    /**
+     * 查询题目业务层次关系列表
+     */
+    @ApiOperation("查询商品题库列表")
+    @PreAuthorize("@ss.hasPermi('system:business:list')")
+    @GetMapping("/bank/list")
+    public AjaxResult<List<GoodsAttachedVo>> bankList(GoodsAttachedQueryBo bo) {
+        List<GoodsAttachedVo> list = iGoodsAttachedService.selectList(bo);
+        return AjaxResult.success(list);
+    }
 }

+ 7 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/mapper/GoodsAttachedMapper.java

@@ -1,7 +1,13 @@
 package com.zhongzheng.modules.goods.mapper;
 
 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.GoodsAttachedVo;
+import com.zhongzheng.modules.goods.vo.GoodsVo;
+
+import java.util.List;
 
 /**
  * 商品附加产品Mapper接口
@@ -10,5 +16,5 @@ import com.zhongzheng.modules.goods.domain.GoodsAttached;
  * @date 2021-10-28
  */
 public interface GoodsAttachedMapper extends BaseMapper<GoodsAttached> {
-
+    List<GoodsAttachedVo> selectList(GoodsAttachedQueryBo bo);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/IGoodsAttachedService.java

@@ -28,6 +28,8 @@ public interface IGoodsAttachedService extends IService<GoodsAttached> {
 	 */
 	List<GoodsAttachedVo> queryList(GoodsAttachedQueryBo bo);
 
+	List<GoodsAttachedVo> selectList(GoodsAttachedQueryBo bo);
+
 	/**
 	 * 根据新增业务对象插入商品附加产品
 	 * @param bo 商品附加产品新增业务对象

+ 11 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsAttachedServiceImpl.java

@@ -8,8 +8,10 @@ import com.zhongzheng.modules.goods.bo.GoodsAttachedEditBo;
 import com.zhongzheng.modules.goods.bo.GoodsAttachedQueryBo;
 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.GoodsAttachedVo;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -30,6 +32,10 @@ import java.util.stream.Collectors;
 @Service
 public class GoodsAttachedServiceImpl extends ServiceImpl<GoodsAttachedMapper, GoodsAttached> implements IGoodsAttachedService {
 
+
+    @Autowired
+    private GoodsAttachedMapper goodsAttachedMapper;
+
     @Override
     public GoodsAttachedVo queryById(Long id){
         GoodsAttached db = this.baseMapper.selectById(id);
@@ -46,6 +52,11 @@ public class GoodsAttachedServiceImpl extends ServiceImpl<GoodsAttachedMapper, G
         return entity2Vo(this.list(lqw));
     }
 
+    @Override
+    public List<GoodsAttachedVo> selectList(GoodsAttachedQueryBo bo) {
+        return goodsAttachedMapper.selectList(bo);
+    }
+
     /**
     * 实体类转化成视图对象
     *

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

@@ -14,5 +14,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateTime" column="update_time"/>
     </resultMap>
 
+    <resultMap type="com.zhongzheng.modules.goods.vo.GoodsAttachedVo" id="GoodsAttachedResultVo">
+        <result property="id" column="id"/>
+        <result property="goodsId" column="goods_id"/>
+        <result property="majorId" column="major_id"/>
+        <result property="sort" column="sort"/>
+        <result property="type" column="type"/>
+        <result property="name" column="name"/>
+        <result property="subjectName" column="subject_name"/>
+    </resultMap>
+
+    <select id="selectList" parameterType="com.zhongzheng.modules.goods.bo.GoodsAttachedQueryBo" resultMap="CourseResultVo">
+        SELECT
+            ga.*,
+            CASE
+
+                WHEN ga.type = 1 THEN
+                    qm.module_name
+                WHEN ga.type = 2 THEN
+                    qc.`name`
+                WHEN ga.type = 3 THEN
+                    e.exam_name
+                END name,
+            CASE
 
+                WHEN ga.type = 1 THEN
+                    cs.subject_name
+                WHEN ga.type = 2 THEN
+                    cs1.subject_name
+                WHEN ga.type = 3 THEN
+                    cs2.subject_name
+                END subject_name
+        FROM
+            goods_attached ga
+                LEFT JOIN question_module qm ON ga.major_id = qm.module_exam_id
+                AND ga.type = 1
+                LEFT JOIN question_business qb ON qb.major_id = qm.module_exam_id
+                AND qb.type = 4
+                LEFT JOIN course_subject cs ON qb.subject_id = cs.id
+                LEFT JOIN question_chapter qc ON ga.major_id = qc.chapter_exam_id
+                AND ga.type = 2
+                LEFT JOIN question_business qb1 ON qb1.major_id = qc.chapter_exam_id
+                AND qb1.type = 3
+                LEFT JOIN course_subject cs1 ON qb1.subject_id = cs1.id
+                LEFT JOIN exam e ON ga.major_id = e.exam_id
+                AND ga.type = 3
+                LEFT JOIN question_business qb2 ON qb2.major_id = e.exam_id
+                AND qb2.type = 2
+                LEFT JOIN course_subject cs2 ON qb2.subject_id = cs2.id
+        WHERE
+            ga.goods_id = #{goodsId}
+    </select>
 </mapper>