|
@@ -22,9 +22,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;
|
|
|
|
|
@@ -91,6 +93,7 @@ public class CourseChapterServiceImpl extends ServiceImpl<CourseChapterMapper, C
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Long insertByAddBo(CourseChapterAddBo bo) {
|
|
|
CourseChapter add = BeanUtil.toBean(bo, CourseChapter.class);
|
|
|
add.setCode(ServletUtils.getEncoded("Z"));
|
|
@@ -107,14 +110,16 @@ public class CourseChapterServiceImpl extends ServiceImpl<CourseChapterMapper, C
|
|
|
}
|
|
|
}
|
|
|
if(bo.getSectionIdList()!=null){
|
|
|
+ Collection<CourseChapterSection> coll = new HashSet<>();
|
|
|
for(int i=0;i<bo.getSectionIdList().size();i++){
|
|
|
CourseChapterSectionListAddBo item = bo.getSectionIdList().get(i);
|
|
|
CourseChapterSection addItem = new CourseChapterSection();
|
|
|
addItem.setChapterId(add.getChapterId());
|
|
|
addItem.setSectionId(item.getSectionId());
|
|
|
addItem.setSort(item.getSort());
|
|
|
- iCourseChapterSectionService.save(addItem);
|
|
|
+ coll.add(addItem);
|
|
|
}
|
|
|
+ iCourseChapterSectionService.saveBatch(coll);
|
|
|
}
|
|
|
|
|
|
}
|