he2802 4 gadi atpakaļ
vecāks
revīzija
bd3e85ff44

+ 2 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseChapterSectionListAddBo.java

@@ -17,8 +17,8 @@ import java.util.List;
 @ApiModel("章与节关系实体添加对象")
 public class CourseChapterSectionListAddBo {
 
-    /** 排序id */
-    @ApiModelProperty("排序id")
+    /** 排序 */
+    @ApiModelProperty("排序")
     private Long sort;
     /** 节ID */
     @ApiModelProperty("节ID")

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseModuleAddBo.java

@@ -45,5 +45,7 @@ public class CourseModuleAddBo {
     /** 业务层级列表 */
     @ApiModelProperty("业务层级列表")
     private List<CourseModuleBusinessAddBo> businessList;
+    @ApiModelProperty("章id列表")
+    private List<CourseModuleChapterListAddBo> chapterIdList;
 
 }

+ 24 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseModuleChapterListAddBo.java

@@ -0,0 +1,24 @@
+package com.zhongzheng.modules.course.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+/**
+ * 模块与章关系添加对象 course_module_chapter
+ *
+ * @author hjl
+ * @date 2021-10-11
+ */
+@Data
+@ApiModel("模块与章关系添加对象")
+public class CourseModuleChapterListAddBo {
+
+    /** 排序 */
+    @ApiModelProperty("排序")
+    private Long sort;
+    /** 章ID */
+    @ApiModelProperty("章ID")
+    private Long chapterId;
+}

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseModuleEditBo.java

@@ -53,6 +53,8 @@ public class CourseModuleEditBo {
     /** 业务层级列表 */
     @ApiModelProperty("业务层级列表")
     private List<CourseModuleBusinessAddBo> businessList;
+    @ApiModelProperty("章id列表")
+    private List<CourseModuleChapterListAddBo> chapterIdList;
 
 
 

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/domain/CourseModuleChapter.java

@@ -30,4 +30,6 @@ private static final long serialVersionUID=1L;
     private Long moduleId;
     /** 章ID */
     private Long chapterId;
+
+    private Long sort;
 }

+ 34 - 6
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseModuleServiceImpl.java

@@ -5,13 +5,9 @@ import cn.hutool.core.util.StrUtil;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.modules.course.bo.*;
-import com.zhongzheng.modules.course.domain.CourseChapterBusiness;
-import com.zhongzheng.modules.course.domain.CourseModule;
-import com.zhongzheng.modules.course.domain.CourseModuleBusiness;
+import com.zhongzheng.modules.course.domain.*;
 import com.zhongzheng.modules.course.mapper.CourseModuleMapper;
-import com.zhongzheng.modules.course.service.ICourseChapterBusinessService;
-import com.zhongzheng.modules.course.service.ICourseModuleBusinessService;
-import com.zhongzheng.modules.course.service.ICourseModuleService;
+import com.zhongzheng.modules.course.service.*;
 import com.zhongzheng.modules.course.vo.CourseModuleVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -19,9 +15,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.pagehelper.Page;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -37,6 +35,9 @@ public class CourseModuleServiceImpl extends ServiceImpl<CourseModuleMapper, Cou
     @Autowired
     private ICourseModuleBusinessService iCourseModuleBusinessService;
 
+    @Autowired
+    private ICourseModuleChapterService iCourseModuleChapterService;
+
     @Override
     public CourseModuleVo queryById(Long moduleId){
         CourseModule db = this.baseMapper.selectById(moduleId);
@@ -76,6 +77,7 @@ public class CourseModuleServiceImpl extends ServiceImpl<CourseModuleMapper, Cou
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Boolean insertByAddBo(CourseModuleAddBo bo) {
         CourseModule add = BeanUtil.toBean(bo, CourseModule.class);
         add.setCode(ServletUtils.getEncoded("MK"));
@@ -89,11 +91,24 @@ public class CourseModuleServiceImpl extends ServiceImpl<CourseModuleMapper, Cou
                 item.setModuleId(add.getModuleId());
                 iCourseModuleBusinessService.insertByAddBo(item);
             }
+            if(bo.getChapterIdList()!=null){
+                Collection<CourseModuleChapter> coll = new HashSet<>();
+                for(int i=0;i<bo.getChapterIdList().size();i++){
+                    CourseModuleChapterListAddBo item = bo.getChapterIdList().get(i);
+                    CourseModuleChapter addItem = new CourseModuleChapter();
+                    addItem.setChapterId(item.getChapterId());
+                    addItem.setModuleId(add.getModuleId());
+                    addItem.setSort(item.getSort());
+                    coll.add(addItem);
+                }
+                iCourseModuleChapterService.saveBatch(coll);
+            }
         }
         return result;
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Boolean updateByEditBo(CourseModuleEditBo bo) {
         CourseModule update = BeanUtil.toBean(bo, CourseModule.class);
         validEntityBeforeSave(update);
@@ -106,6 +121,19 @@ public class CourseModuleServiceImpl extends ServiceImpl<CourseModuleMapper, Cou
                 iCourseModuleBusinessService.insertByAddBo(item);
             }
         }
+        if(bo.getChapterIdList()!=null){
+            iCourseModuleChapterService.remove(new LambdaQueryWrapper<CourseModuleChapter>().eq(CourseModuleChapter::getModuleId, bo.getModuleId()));
+            Collection<CourseModuleChapter> coll = new HashSet<>();
+            for(int i=0;i<bo.getChapterIdList().size();i++){
+                CourseModuleChapterListAddBo item = bo.getChapterIdList().get(i);
+                CourseModuleChapter addItem = new CourseModuleChapter();
+                addItem.setChapterId(item.getChapterId());
+                addItem.setModuleId(bo.getModuleId());
+                addItem.setSort(item.getSort());
+                coll.add(addItem);
+            }
+            iCourseModuleChapterService.saveBatch(coll);
+        }
         return this.updateById(update);
     }
 

+ 2 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseChapterSectionMapper.xml

@@ -38,6 +38,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         WHERE
             cs.`status` !=- 1
 	        AND ccs.chapter_id = #{id}
+        ORDER BY
+            c_sort DESC
     </select>
 
     <select id="getListTotalTime" parameterType="Long"  resultType="java.lang.Long">