|
|
@@ -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);
|
|
|
}
|
|
|
|