Commit 3e14381e authored by luzhuang's avatar luzhuang

修改节

parent 7375435e
...@@ -460,13 +460,14 @@ public interface BChapterRepository extends BaseMapper<BChapter> { ...@@ -460,13 +460,14 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
* @param chapterId * @param chapterId
* @return * @return
*/ */
@Select("SELECT business_id " + @Select("SELECT * " +
"from b_chapter where business_id in( " + "from b_chapter where business_id in( " +
" SELECT chapter_id from b_file where video_url = ( " + " SELECT chapter_id from b_file where video_url = ( " +
" select video_url from b_file where chapter_id = #{chapterId} and del_flag != 1 and flag =1) " + " select video_url from b_file where chapter_id = #{chapterId} and del_flag != 1 and flag =1) " +
" and del_flag != 1 and flag =1) " + " and del_flag != 1 and flag =1) " +
"ORDER BY sort") "ORDER BY sort")
List<String> getPdfIdList(@Param("chapterId")String chapterId); @ResultMap(value = "BaseResultMap")
List<BChapter> getPdfIdList(@Param("chapterId")String chapterId);
/** /**
* 新增节时 pdf分节查询出之前 排序大于修改节的chapterId * 新增节时 pdf分节查询出之前 排序大于修改节的chapterId
......
...@@ -412,6 +412,9 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -412,6 +412,9 @@ public class BChapterServiceImpl implements BChapterService {
} }
} else {//修改 } else {//修改
BFile bFileOld = bFileRepository.selectInfoByChapterId(chapterDTO.getBusinessId()); BFile bFileOld = bFileRepository.selectInfoByChapterId(chapterDTO.getBusinessId());
if(bFileOld.getVideoUrl().equals(dto.getVideoUrl())){
dto.setPdfNum("0");
}
if("3".equals(model.getIsTest()) && dto.getPdfNum()!=null && Integer.parseInt(dto.getPdfNum()) > 1 ){ if("3".equals(model.getIsTest()) && dto.getPdfNum()!=null && Integer.parseInt(dto.getPdfNum()) > 1 ){
model.setChapterName(model.getChapterName()+"-1"); model.setChapterName(model.getChapterName()+"-1");
} }
...@@ -437,38 +440,29 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -437,38 +440,29 @@ public class BChapterServiceImpl implements BChapterService {
bChapterRepository.updateVideoTimeInLesson(model.getCourseTime(), model.getLessonId()); bChapterRepository.updateVideoTimeInLesson(model.getCourseTime(), model.getLessonId());
} }
//判断修改前后pid是否发生改变 //判断修改前后pid是否发生改变
BChapter bChapter = bChapterRepository.selectByPrimaryKey(model.getBusinessId()); BChapter bChapter = bChapterRepository.selectByPrimaryKey(model.getBusinessId());//获取当前节的信息
if (bChapter != null && !bChapter.getPid().equals(model.getPid())) { if (bChapter != null && !bChapter.getPid().equals(model.getPid())) {
line = bChapterRepository.updateByPrimaryKeySelective(model);
//更新修改之前章中节的sort
List<String> chapterIds = bChapterRepository.getChapterIds(bChapter.getPid(), bChapter.getLessonId());
if (chapterIds != null && chapterIds.size() > 0) {
List<Map<String, Object>> params = new ArrayList<>();
for (int i = 0; i < chapterIds.size(); i++) {
Map<String, Object> map = new HashedMap();
map.put("businessId", chapterIds.get(i));
map.put("sort", i + 1);
params.add(map);
}
//更新表中sort
bChapterRepository.updateSort(params);
}
int sort = bChapterRepository.selectMaxSort(model.getPid(), model.getLessonId()); int sort = bChapterRepository.selectMaxSort(model.getPid(), model.getLessonId());
model.setSort(sort); model.setSort(sort);
line = bChapterRepository.updateByPrimaryKeySelective(model); List<BChapter> cutPdfChapterList = bChapterRepository.getPdfIdList(model.getBusinessId());
//更新修改之后章中节的sort int i = 1;
List<String> chapterIds2 = bChapterRepository.getChapterIds(model.getPid(), model.getLessonId()); if(cutPdfChapterList!=null && cutPdfChapterList.size() > 1){
if (chapterIds2 != null && chapterIds2.size() > 0) { for(BChapter b:cutPdfChapterList){
List<Map<String, Object>> params = new ArrayList<>(); if(b.getBusinessId().equals(model.getBusinessId())){
for (int i = 0; i < chapterIds2.size(); i++) { b.setChapterName(model.getChapterName());
Map<String, Object> map = new HashedMap(); }
map.put("businessId", chapterIds2.get(i)); b.setPid(model.getPid());
map.put("sort", i + 1); b.setSort(sort+i++);
params.add(map); bChapterRepository.updateByPrimaryKeySelective(b);
} }
//更新表中sort
bChapterRepository.updateSort(params); }else{
bChapterRepository.updateByPrimaryKeySelective(model);
} }
//更新修改之前 章中节的sort
reSort(bChapter.getPid(), bChapter.getLessonId());
//更新修改之后 章中节的sort
reSort(model.getPid(), model.getLessonId());
} else { } else {
line = bChapterRepository.updateByPrimaryKeySelective(model); line = bChapterRepository.updateByPrimaryKeySelective(model);
} }
...@@ -701,18 +695,7 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -701,18 +695,7 @@ public class BChapterServiceImpl implements BChapterService {
// brStudentChapterRepository.deleteByPrimaryKey(queryChapterListResDTO.getBRSBusinessId()); // brStudentChapterRepository.deleteByPrimaryKey(queryChapterListResDTO.getBRSBusinessId());
// } // }
//更新表中sort //更新表中sort
List<String> chapterIds = bChapterRepository.getChapterIds(bChapter.getPid(), bChapter.getLessonId()); reSort(bChapter.getPid(), bChapter.getLessonId());
if (chapterIds != null && chapterIds.size() > 0) {
List<Map<String, Object>> params = new ArrayList<>();
for (int i = 0; i < chapterIds.size(); i++) {
Map<String, Object> map = new HashedMap();
map.put("businessId", chapterIds.get(i));
map.put("sort", i + 1);
params.add(map);
}
//更新表中sort
bChapterRepository.updateSort(params);
}
// List<BRStudentChapter> brStudentChapterList = brStudentChapterRepository.queryByStuIdAndChapter(id, curUser.getUserId()); // List<BRStudentChapter> brStudentChapterList = brStudentChapterRepository.queryByStuIdAndChapter(id, curUser.getUserId());
// 判断 2-节 才重新计算进度 // 判断 2-节 才重新计算进度
...@@ -912,11 +895,11 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -912,11 +895,11 @@ public class BChapterServiceImpl implements BChapterService {
} }
}else{ }else{
//step1 根据章节id获取对应 文件的序号 x //step1 根据章节id获取对应 文件的序号 x
List<String> chapterIds = bChapterRepository.getPdfIdList(bFile.getChapterId()); List<BChapter> chapterIds = bChapterRepository.getPdfIdList(bFile.getChapterId());
int x = 0; int x = 0;
for(String s : chapterIds){ for(BChapter b : chapterIds){
x++; x++;
if(s.equals(bFile.getChapterId())){ if(b.getBusinessId().equals(bFile.getChapterId())){
break; break;
} }
} }
...@@ -1244,5 +1227,19 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -1244,5 +1227,19 @@ public class BChapterServiceImpl implements BChapterService {
return result; return result;
} }
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public void reSort(String pid,String lessonId){
List<String> chapterIds = bChapterRepository.getChapterIds(pid,lessonId);
if (chapterIds != null && chapterIds.size() > 0) {
List<Map<String, Object>> params = new ArrayList<>();
for (int i = 0; i < chapterIds.size(); i++) {
Map<String, Object> map = new HashedMap();
map.put("businessId", chapterIds.get(i));
map.put("sort", i + 1);
params.add(map);
}
//更新表中sort
bChapterRepository.updateSort(params);
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment