Bladeren bron

流业务层

he2802 4 jaren geleden
bovenliggende
commit
eb5dafedb3

+ 17 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/course/CourseChapterController.java

@@ -6,7 +6,11 @@ import java.util.Arrays;
 import com.zhongzheng.modules.course.bo.CourseChapterAddBo;
 import com.zhongzheng.modules.course.bo.CourseChapterEditBo;
 import com.zhongzheng.modules.course.bo.CourseChapterQueryBo;
+import com.zhongzheng.modules.course.domain.CourseChapterBusiness;
+import com.zhongzheng.modules.course.domain.CourseSectionBusiness;
+import com.zhongzheng.modules.course.service.ICourseChapterBusinessService;
 import com.zhongzheng.modules.course.service.ICourseChapterService;
+import com.zhongzheng.modules.course.service.ICourseSectionBusinessService;
 import com.zhongzheng.modules.course.vo.CourseChapterVo;
 import lombok.RequiredArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -42,6 +46,8 @@ public class CourseChapterController extends BaseController {
 
     private final ICourseChapterService iCourseChapterService;
 
+    private final ICourseChapterBusinessService iCourseChapterBusinessService;
+
     /**
      * 查询课程大章列表
      */
@@ -109,4 +115,15 @@ public class CourseChapterController extends BaseController {
     public AjaxResult<Void> remove(@PathVariable Long[] chapterIds) {
         return toAjax(iCourseChapterService.deleteWithValidByIds(Arrays.asList(chapterIds), true) ? 1 : 0);
     }*/
+
+    /**
+     * 获取课程小节业务层次列表
+     */
+    @ApiOperation("获取课程大章业务层次列表")
+    @PreAuthorize("@ss.hasPermi('system:section:query')")
+    @GetMapping("/business/{chapterId}")
+    public AjaxResult<List<CourseChapterBusiness>> getBusinessList(@PathVariable("chapterId" ) Long chapterId) {
+        List<CourseChapterBusiness> list = iCourseChapterBusinessService.getListById(chapterId);
+        return AjaxResult.success(list);
+    }
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/mapper/CourseChapterBusinessMapper.java

@@ -3,6 +3,8 @@ package com.zhongzheng.modules.course.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.modules.course.domain.CourseChapterBusiness;
 
+import java.util.List;
+
 /**
  * 课程大章适用业务关系Mapper接口
  *
@@ -10,5 +12,6 @@ import com.zhongzheng.modules.course.domain.CourseChapterBusiness;
  * @date 2021-10-09
  */
 public interface CourseChapterBusinessMapper extends BaseMapper<CourseChapterBusiness> {
+    List<CourseChapterBusiness> getListById(Long id);
 
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/ICourseChapterBusinessService.java

@@ -5,6 +5,7 @@ import com.zhongzheng.modules.course.bo.CourseChapterBusinessAddBo;
 import com.zhongzheng.modules.course.bo.CourseChapterBusinessEditBo;
 import com.zhongzheng.modules.course.bo.CourseChapterBusinessQueryBo;
 import com.zhongzheng.modules.course.domain.CourseChapterBusiness;
+import com.zhongzheng.modules.course.domain.CourseSectionBusiness;
 import com.zhongzheng.modules.course.vo.CourseChapterBusinessVo;
 
 import java.util.Collection;
@@ -23,6 +24,8 @@ public interface ICourseChapterBusinessService extends IService<CourseChapterBus
 	 */
 	CourseChapterBusinessVo queryById(Long id);
 
+	List<CourseChapterBusiness> getListById(Long id);
+
 	/**
 	 * 查询列表
 	 */

+ 10 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseChapterBusinessServiceImpl.java

@@ -8,8 +8,10 @@ import com.zhongzheng.modules.course.bo.CourseChapterBusinessEditBo;
 import com.zhongzheng.modules.course.bo.CourseChapterBusinessQueryBo;
 import com.zhongzheng.modules.course.domain.CourseChapterBusiness;
 import com.zhongzheng.modules.course.mapper.CourseChapterBusinessMapper;
+import com.zhongzheng.modules.course.mapper.CourseSectionBusinessMapper;
 import com.zhongzheng.modules.course.service.ICourseChapterBusinessService;
 import com.zhongzheng.modules.course.vo.CourseChapterBusinessVo;
+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,12 +32,20 @@ import java.util.stream.Collectors;
 @Service
 public class CourseChapterBusinessServiceImpl extends ServiceImpl<CourseChapterBusinessMapper, CourseChapterBusiness> implements ICourseChapterBusinessService {
 
+    @Autowired
+    private CourseChapterBusinessMapper courseChapterBusinessMapper;
+
     @Override
     public CourseChapterBusinessVo queryById(Long id){
         CourseChapterBusiness db = this.baseMapper.selectById(id);
         return BeanUtil.toBean(db, CourseChapterBusinessVo.class);
     }
 
+    @Override
+    public List<CourseChapterBusiness> getListById(Long id) {
+        return courseChapterBusinessMapper.getListById(id);
+    }
+
     @Override
     public List<CourseChapterBusinessVo> queryList(CourseChapterBusinessQueryBo bo) {
         LambdaQueryWrapper<CourseChapterBusiness> lqw = Wrappers.lambdaQuery();

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseChapterVo.java

@@ -63,4 +63,10 @@ public class CourseChapterVo {
 	/** 课程列表 */
 	@ApiModelProperty("课程列表")
 	private List<CourseSectionListVo> courseList;
+	@Excel(name = "节数")
+	@ApiModelProperty("节数")
+	private Integer sectionNum;
+	@Excel(name = "节时间")
+	@ApiModelProperty("节时间")
+	private Integer durationTime;
 }

+ 38 - 25
zhongzheng-system/src/main/resources/mapper/modules/course/CourseChapterMapper.xml

@@ -26,6 +26,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="coverUrl" column="cover_url"/>
         <result property="publishStatus" column="publish_status"/>
         <result property="code" column="code"/>
+        <result property="sectionNum" column="section_num"/>
+        <result property="durationTime" column="duration_time"/>
         <collection property="businessList" javaType="java.util.List" resultMap="CourseChapterBusiness"/>
         <collection property="moduleList" javaType="java.util.List" resultMap="CourseModuleChapterListResult"/>
         <collection property="courseList" javaType="java.util.List" resultMap="CourseSectionListResult"/>
@@ -56,33 +58,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectList" parameterType="com.zhongzheng.modules.course.bo.CourseChapterQueryBo" resultMap="CourseChapterResultVo">
         SELECT
-            c.*,
-            ccb.education_type_id,
-            ccb.id,
-            ccb.business_id,
-            ccb.subject_id,
-            ccb.project_id,
-            cet.education_name,
-            cpt.project_name,
-            cb.business_name,
-            cs.subject_name,
-            cmc.module_id,
-            cm.module_name,
-            m.course_id,
-            co.course_name
+        c.*,
+        ccb.education_type_id,
+        ccb.id,
+        ccb.business_id,
+        ccb.subject_id,
+        ccb.project_id,
+        cet.education_name,
+        cpt.project_name,
+        cb.business_name,
+        cs.subject_name,
+        cmc.module_id,
+        cm.module_name,
+        m.course_id,
+        co.course_name
         FROM
-            course_chapter c
-                LEFT JOIN course_chapter_business ccb ON c.chapter_id = ccb.chapter_id
-                LEFT JOIN course_education_type cet ON ccb.education_type_id = cet.id
-                LEFT JOIN course_project_type cpt ON ccb.project_id = cpt.id
-                LEFT JOIN course_business cb ON ccb.business_id = cb.id
-                LEFT JOIN course_subject cs ON ccb.subject_id = cs.id
-                LEFT JOIN course_module_chapter cmc ON c.chapter_id = cmc.chapter_id
-                LEFT JOIN course_module cm ON cmc.module_id = cm.module_id
-                LEFT JOIN ( SELECT course_id, menu_id FROM course_menu WHERE type = 3 AND STATUS = 1 ) m ON c.chapter_id = m.menu_id
-                LEFT JOIN course co ON m.course_id = co.course_id
+        (
+        SELECT
+        cc.*,
+        count( ccs.section_id ) AS section_num,
+        COALESCE ( SUM( cs.duration_time ), 0 ) AS duration_time
+        FROM
+        course_chapter cc
+        LEFT JOIN course_chapter_section ccs ON cc.chapter_id = ccs.chapter_id
+        LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
+        GROUP BY
+        cc.chapter_id
+        ) c
+        LEFT JOIN course_chapter_business ccb ON c.chapter_id = ccb.chapter_id
+        LEFT JOIN course_education_type cet ON ccb.education_type_id = cet.id
+        LEFT JOIN course_project_type cpt ON ccb.project_id = cpt.id
+        LEFT JOIN course_business cb ON ccb.business_id = cb.id
+        LEFT JOIN course_subject cs ON ccb.subject_id = cs.id
+        LEFT JOIN course_module_chapter cmc ON c.chapter_id = cmc.chapter_id
+        LEFT JOIN course_module cm ON cmc.module_id = cm.module_id
+        LEFT JOIN ( SELECT course_id, menu_id FROM course_menu WHERE type = 3 AND STATUS = 1 ) m ON c.chapter_id = m.menu_id
+        LEFT JOIN course co ON m.course_id = co.course_id
         WHERE
-            1 = 1
+        1 = 1
         <if test="status != null and status.size()!=0 ">
             AND c.status in
             <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">