|
@@ -3994,6 +3994,146 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
return baseMapper.queryGoodsByIdTenant(goodsId,tenantId);
|
|
return baseMapper.queryGoodsByIdTenant(goodsId,tenantId);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public boolean updateGoodsRepair(UpdateGoodsRepairBo bo) {
|
|
|
|
+// List<Goods> goodsList = list(new LambdaQueryWrapper<Goods>()
|
|
|
|
+// .eq(Goods::getEducationTypeId, bo.getEducationTypeId())
|
|
|
|
+// .eq(Goods::getBusinessId, bo.getBusinessId()));
|
|
|
|
+// if (CollectionUtils.isEmpty(goodsList)){
|
|
|
|
+// return true;
|
|
|
|
+// }
|
|
|
|
+ Map<Integer,List<Long>> mapIds = new HashMap<>();
|
|
|
|
+ List<Long> goodsIds = new ArrayList<>();
|
|
|
|
+ List<Long> courseIds = new ArrayList<>();
|
|
|
|
+ List<Long> moduleIds = new ArrayList<>();
|
|
|
|
+ List<Long> chapterIds = new ArrayList<>();
|
|
|
|
+ List<Long> sectionIds = new ArrayList<>();
|
|
|
|
+ for (Long goodsId : bo.getGoodsIds()) {
|
|
|
|
+ Goods goods = getById(goodsId);
|
|
|
|
+ if (ObjectUtils.isNull(goods)){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ goodsIds.add(goodsId);
|
|
|
|
+ //商品课程
|
|
|
|
+ List<GoodsCourse> courseList = iGoodsCourseService
|
|
|
|
+ .list(new LambdaQueryWrapper<GoodsCourse>()
|
|
|
|
+ .eq(GoodsCourse::getGoodsId, goodsId));
|
|
|
|
+ if (CollectionUtils.isEmpty(courseList)){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ List<Long> idsCourse = courseList.stream().map(GoodsCourse::getCourseId).collect(Collectors.toList());
|
|
|
|
+ courseIds.addAll(idsCourse);
|
|
|
|
+ //课程目录
|
|
|
|
+ List<CourseMenu> courseMenuList = iCourseMenuService.list(new LambdaQueryWrapper<CourseMenu>()
|
|
|
|
+ .in(CourseMenu::getCourseId, courseIds));
|
|
|
|
+ if (CollectionUtils.isEmpty(courseMenuList)){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Map<Integer, List<CourseMenu>> collect = courseMenuList.stream().collect(Collectors.groupingBy(CourseMenu::getType));
|
|
|
|
+ collect.forEach((k,v) -> {
|
|
|
|
+ List<Long> menuIds = v.stream().map(CourseMenu::getMenuId).collect(Collectors.toList());
|
|
|
|
+ switch (k){
|
|
|
|
+ case 1://模块
|
|
|
|
+ List<CourseModule> moduleList = iCourseModuleService.listByIds(menuIds);
|
|
|
|
+ List<CourseModule> list = iCourseModuleService.list(new LambdaQueryWrapper<CourseModule>()
|
|
|
|
+ .in(CourseModule::getModuleName, moduleList.stream().map(CourseModule::getModuleName).collect(Collectors.toList())));
|
|
|
|
+ List<Long> idsModule = list.stream().map(CourseModule::getModuleId).collect(Collectors.toList());
|
|
|
|
+ List<CourseModuleChapter> list1 = iCourseModuleChapterService
|
|
|
|
+ .list(new LambdaQueryWrapper<CourseModuleChapter>()
|
|
|
|
+ .in(CourseModuleChapter::getModuleId, idsModule));
|
|
|
|
+ if (CollectionUtils.isNotEmpty(list1)){
|
|
|
|
+ List<Long> collect1 = list1.stream().map(CourseModuleChapter::getChapterId).collect(Collectors.toList());
|
|
|
|
+ List<CourseChapter> courseChapterList = iCourseChapterService.listByIds(collect1);
|
|
|
|
+ List<CourseChapter> list2 = iCourseChapterService.list(new LambdaQueryWrapper<CourseChapter>()
|
|
|
|
+ .in(CourseChapter::getName, courseChapterList.stream().map(CourseChapter::getName).collect(Collectors.toList())));
|
|
|
|
+ List<Long> idsChapter = list2.stream().map(CourseChapter::getChapterId).collect(Collectors.toList());
|
|
|
|
+ chapterIds.addAll(idsChapter);
|
|
|
|
+ List<CourseChapterSection> list3 = iCourseChapterSectionService
|
|
|
|
+ .list(new LambdaQueryWrapper<CourseChapterSection>()
|
|
|
|
+ .in(CourseChapterSection::getChapterId, idsChapter));
|
|
|
|
+ if (CollectionUtils.isNotEmpty(list3)){
|
|
|
|
+ List<CourseSection> sectionList = iCourseSectionService.listByIds(list3.stream().map(CourseChapterSection::getSectionId).collect(Collectors.toList()));
|
|
|
|
+ List<CourseSection> list4 = iCourseSectionService.list(new LambdaQueryWrapper<CourseSection>()
|
|
|
|
+ .in(CourseSection::getName, sectionList.stream().map(CourseSection::getName).collect(Collectors.toList())));
|
|
|
|
+ List<Long> idsSection = list4.stream().map(CourseSection::getSectionId).collect(Collectors.toList());
|
|
|
|
+ sectionIds.addAll(idsSection);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ moduleIds.addAll(idsModule);
|
|
|
|
+ break;
|
|
|
|
+ case 2://章
|
|
|
|
+ List<CourseChapter> courseChapterList = iCourseChapterService.listByIds(menuIds);
|
|
|
|
+ List<CourseChapter> list2 = iCourseChapterService.list(new LambdaQueryWrapper<CourseChapter>()
|
|
|
|
+ .in(CourseChapter::getName, courseChapterList.stream().map(CourseChapter::getName).collect(Collectors.toList())));
|
|
|
|
+ List<Long> idsChapter = list2.stream().map(CourseChapter::getChapterId).collect(Collectors.toList());
|
|
|
|
+ chapterIds.addAll(idsChapter);
|
|
|
|
+ List<CourseChapterSection> list3 = iCourseChapterSectionService
|
|
|
|
+ .list(new LambdaQueryWrapper<CourseChapterSection>()
|
|
|
|
+ .in(CourseChapterSection::getChapterId, idsChapter));
|
|
|
|
+ if (CollectionUtils.isNotEmpty(list3)){
|
|
|
|
+ List<CourseSection> sectionList = iCourseSectionService.listByIds(list3.stream().map(CourseChapterSection::getSectionId).collect(Collectors.toList()));
|
|
|
|
+ List<CourseSection> list4 = iCourseSectionService.list(new LambdaQueryWrapper<CourseSection>()
|
|
|
|
+ .in(CourseSection::getName, sectionList.stream().map(CourseSection::getName).collect(Collectors.toList())));
|
|
|
|
+ List<Long> idsSection = list4.stream().map(CourseSection::getSectionId).collect(Collectors.toList());
|
|
|
|
+ sectionIds.addAll(idsSection);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 3://节
|
|
|
|
+ List<CourseSection> sectionList = iCourseSectionService.listByIds(menuIds);
|
|
|
|
+ List<CourseSection> list4 = iCourseSectionService.list(new LambdaQueryWrapper<CourseSection>()
|
|
|
|
+ .in(CourseSection::getName, sectionList.stream().map(CourseSection::getName).collect(Collectors.toList())));
|
|
|
|
+ List<Long> idsSection = list4.stream().map(CourseSection::getSectionId).collect(Collectors.toList());
|
|
|
|
+ sectionIds.addAll(idsSection);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+// List<Long> goodsIds = new ArrayList<>();
|
|
|
|
+// List<Long> courseIds = new ArrayList<>();
|
|
|
|
+// List<Long> moduleIds = new ArrayList<>();
|
|
|
|
+// List<Long> chapterIds = new ArrayList<>();
|
|
|
|
+// List<Long> sectionIds = new ArrayList<>();
|
|
|
|
+ //执行删除
|
|
|
|
+ iCourseSectionBusinessService.remove(new LambdaQueryWrapper<CourseSectionBusiness>()
|
|
|
|
+ .in(CourseSectionBusiness::getSectionId,sectionIds));
|
|
|
|
+ iCourseSectionService.removeByIds(sectionIds);
|
|
|
|
+
|
|
|
|
+ iCourseChapterSectionService.remove(new LambdaQueryWrapper<CourseChapterSection>()
|
|
|
|
+ .in(CourseChapterSection::getChapterId,chapterIds));
|
|
|
|
+ iCourseChapterBusinessService.remove(new LambdaQueryWrapper<CourseChapterBusiness>()
|
|
|
|
+ .in(CourseChapterBusiness::getChapterId,chapterIds));
|
|
|
|
+ iCourseChapterService.removeByIds(chapterIds);
|
|
|
|
+
|
|
|
|
+ iCourseModuleChapterService.remove(new LambdaQueryWrapper<CourseModuleChapter>()
|
|
|
|
+ .in(CourseModuleChapter::getModuleId,moduleIds));
|
|
|
|
+ iCourseModuleBusinessService.remove(new LambdaQueryWrapper<CourseModuleBusiness>()
|
|
|
|
+ .in(CourseModuleBusiness::getModuleId,moduleIds));
|
|
|
|
+ iCourseModuleService.removeByIds(moduleIds);
|
|
|
|
+
|
|
|
|
+ iCourseMenuService.remove(new LambdaQueryWrapper<CourseMenu>()
|
|
|
|
+ .in(CourseMenu::getCourseId,courseIds));
|
|
|
|
+ iCourseService.removeByIds(courseIds);
|
|
|
|
+
|
|
|
|
+ iGoodsCourseService.remove(new LambdaQueryWrapper<GoodsCourse>()
|
|
|
|
+ .in(GoodsCourse::getGoodsId,goodsIds));
|
|
|
|
+ removeByIds(goodsIds);
|
|
|
|
+
|
|
|
|
+ mapIds.put(GoodsCopyEnum.GOODS.getType(),goodsIds);
|
|
|
|
+ mapIds.put(GoodsCopyEnum.COURSE.getType(),courseIds);
|
|
|
|
+ mapIds.put(GoodsCopyEnum.COURSE_MODULE.getType(),moduleIds);
|
|
|
|
+ mapIds.put(GoodsCopyEnum.COURSE_CHAPTER.getType(),chapterIds);
|
|
|
|
+ mapIds.put(GoodsCopyEnum.COURSE_SECTION.getType(),sectionIds);
|
|
|
|
+
|
|
|
|
+ mapIds.forEach((k,v) -> {
|
|
|
|
+ iSysGoodsCopyRecordService.remove(new LambdaQueryWrapper<SysGoodsCopyRecord>()
|
|
|
|
+ .eq(SysGoodsCopyRecord::getType,k)
|
|
|
|
+ .in(SysGoodsCopyRecord::getNewId,v));
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
private Long getNewId(Long oldId, Integer type){
|
|
private Long getNewId(Long oldId, Integer type){
|
|
if (ObjectUtils.isNull(oldId) || oldId <= 0L){
|
|
if (ObjectUtils.isNull(oldId) || oldId <= 0L){
|
|
return null;
|
|
return null;
|