Commit 3e14381e authored by luzhuang's avatar luzhuang

修改节

parent 7375435e
......@@ -460,13 +460,14 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
* @param chapterId
* @return
*/
@Select("SELECT business_id " +
@Select("SELECT * " +
"from b_chapter where business_id in( " +
" 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) " +
" and del_flag != 1 and flag =1) " +
"ORDER BY sort")
List<String> getPdfIdList(@Param("chapterId")String chapterId);
@ResultMap(value = "BaseResultMap")
List<BChapter> getPdfIdList(@Param("chapterId")String chapterId);
/**
* 新增节时 pdf分节查询出之前 排序大于修改节的chapterId
......
......@@ -412,6 +412,9 @@ public class BChapterServiceImpl implements BChapterService {
}
} else {//修改
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 ){
model.setChapterName(model.getChapterName()+"-1");
}
......@@ -437,38 +440,29 @@ public class BChapterServiceImpl implements BChapterService {
bChapterRepository.updateVideoTimeInLesson(model.getCourseTime(), model.getLessonId());
}
//判断修改前后pid是否发生改变
BChapter bChapter = bChapterRepository.selectByPrimaryKey(model.getBusinessId());
BChapter bChapter = bChapterRepository.selectByPrimaryKey(model.getBusinessId());//获取当前节的信息
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());
model.setSort(sort);
line = bChapterRepository.updateByPrimaryKeySelective(model);
//更新修改之后章中节的sort
List<String> chapterIds2 = bChapterRepository.getChapterIds(model.getPid(), model.getLessonId());
if (chapterIds2 != null && chapterIds2.size() > 0) {
List<Map<String, Object>> params = new ArrayList<>();
for (int i = 0; i < chapterIds2.size(); i++) {
Map<String, Object> map = new HashedMap();
map.put("businessId", chapterIds2.get(i));
map.put("sort", i + 1);
params.add(map);
List<BChapter> cutPdfChapterList = bChapterRepository.getPdfIdList(model.getBusinessId());
int i = 1;
if(cutPdfChapterList!=null && cutPdfChapterList.size() > 1){
for(BChapter b:cutPdfChapterList){
if(b.getBusinessId().equals(model.getBusinessId())){
b.setChapterName(model.getChapterName());
}
b.setPid(model.getPid());
b.setSort(sort+i++);
bChapterRepository.updateByPrimaryKeySelective(b);
}
//更新表中sort
bChapterRepository.updateSort(params);
}else{
bChapterRepository.updateByPrimaryKeySelective(model);
}
//更新修改之前 章中节的sort
reSort(bChapter.getPid(), bChapter.getLessonId());
//更新修改之后 章中节的sort
reSort(model.getPid(), model.getLessonId());
} else {
line = bChapterRepository.updateByPrimaryKeySelective(model);
}
......@@ -701,18 +695,7 @@ public class BChapterServiceImpl implements BChapterService {
// brStudentChapterRepository.deleteByPrimaryKey(queryChapterListResDTO.getBRSBusinessId());
// }
//更新表中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);
}
reSort(bChapter.getPid(), bChapter.getLessonId());
// List<BRStudentChapter> brStudentChapterList = brStudentChapterRepository.queryByStuIdAndChapter(id, curUser.getUserId());
// 判断 2-节 才重新计算进度
......@@ -912,11 +895,11 @@ public class BChapterServiceImpl implements BChapterService {
}
}else{
//step1 根据章节id获取对应 文件的序号 x
List<String> chapterIds = bChapterRepository.getPdfIdList(bFile.getChapterId());
List<BChapter> chapterIds = bChapterRepository.getPdfIdList(bFile.getChapterId());
int x = 0;
for(String s : chapterIds){
for(BChapter b : chapterIds){
x++;
if(s.equals(bFile.getChapterId())){
if(b.getBusinessId().equals(bFile.getChapterId())){
break;
}
}
......@@ -1244,5 +1227,19 @@ public class BChapterServiceImpl implements BChapterService {
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