Commit f5ce0064 authored by luzhuang's avatar luzhuang

Merge remote-tracking branch 'origin/meiteng' into meiteng

parents 7e49ba13 85dc8044
......@@ -144,8 +144,8 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
"AND t1.del_flag = 0 and t1.flag = 1</script>")
List<StuScoreDTO> selectScoreListBySlIdAndStuId(@Param("slid") String slid, @Param("stuid") String stuid);
// @Delete("<script>delete from b_r_student_chapter where chapter_id = #{chapterId}</script>")
// int deleteStudentChapter(String chapterId);
@Delete("<script>delete from b_r_student_chapter where chapter_id = #{chapterId}</script>")
int deleteStudentChapter(String chapterId);
/**
* 根据章节id和学生id获取主键
......
......@@ -155,22 +155,17 @@ public class BChapterServiceImpl implements BChapterService {
if (bLesson == null){
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
}
// //判断课程是否被关闭
// if ("4".equals(bLesson.getReleaseState())){
// throw new ServiceException(ResultServiceEnums.LESSON_CLOSED);
// }
//判断课程是否被关闭
if ("4".equals(bLesson.getReleaseState())){
throw new ServiceException(ResultServiceEnums.LESSON_CLOSED);
}
//判断该登录人是否可见该课程
List<String> ids = Arrays.asList(new String[]{curUser.getUserId()});
MTUserGetsReqDTO mtUserGetsReqDTO = new MTUserGetsReqDTO();
mtUserGetsReqDTO.setCorpId(curUser.getCorpId());
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = mtCotactApiRequestClient.userGets(mtUserGetsReqDTO);
List<String> departs = new ArrayList<>();
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){
departs = QueryDepart.queryDepart(mtUserInfoRspDTOList);
departs.removeAll(Collections.singleton(null));
departs.removeAll(Collections.singleton(""));
}
List<String> departs = QueryDepart.queryDepart(mtUserInfoRspDTOList);
int result = bLessonRepository.isInViewRange(curUser,lessonId,departs);
if (result < 1){
throw new ServiceException(ResultServiceEnums.NO_ACCESS);
......@@ -301,19 +296,18 @@ public class BChapterServiceImpl implements BChapterService {
UserUtil.setCurrentMergeOperation(model);
bFile.setChapterId(model.getBusinessId());
UserUtil.setCurrentMergeOperation(bFile);
model.setCourseTime(dto.getFileTime());
model.setIsTest(dto.getType());
if (StringUtils.isNotEmpty(dto.getFileTime()) && dto.getFileTime().contains(".")) {
model.setCourseTime(dto.getFileTime().substring(0, dto.getFileTime().lastIndexOf(".")));
bFile.setFileTime(dto.getFileTime().substring(0, dto.getFileTime().lastIndexOf(".")));
}
//先判断该课程的第一节是否是本节 更新blesson表中course_time字段
String cid = bChapterRepository.getFirstChapter(model.getLessonId());
log.debug("--------------------------------第一节id--------:"+cid);
log.debug("------------------------------当前章节id--------:"+model.getBusinessId());
if (model.getBusinessId().equals(cid)) {
int linex = bChapterRepository.updateVideoTimeInLesson(model.getCourseTime(), model.getLessonId());
log.debug("----------------------更新lesson表中第一节时长--"+(linex==0?"失败":"成功")+"----------");
log.debug("--------------------------时长-----------:"+model.getCourseTime());
bChapterRepository.updateVideoTimeInLesson(model.getCourseTime(), model.getLessonId());
}
line = bChapterRepository.updateByPrimaryKeySelective(model);
......@@ -340,7 +334,6 @@ public class BChapterServiceImpl implements BChapterService {
bLessonPersonRepository.updateByPrimaryKeySelective(lessonPerson);
studentChapter.setProgress(0);
brStudentChapterRepository.updateById(studentChapter);
}
}
}
......@@ -389,6 +382,14 @@ public class BChapterServiceImpl implements BChapterService {
if (learnProgress > 0 && newLearnProgress < 0.01){
newLearnProgress = 0.01f;
}
if ("2".equals(lessonPerson.getIsFinish()) && newLearnProgress < 1){
lessonPerson.setIsFinish("1");
}
if (newLearnProgress >= 1){
newLearnProgress = 1;
lessonPerson.setIsFinish("2");
}
lessonPerson.setLearnProgress(newLearnProgress*100+"%");
bLessonPersonRepository.updateByPrimaryKeySelective(lessonPerson);
}
......@@ -405,21 +406,15 @@ public class BChapterServiceImpl implements BChapterService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel removeBChapter(String id,String userId) {
BChapter bChapter = bChapterRepository.selectByPrimaryKey(id);
String lessonId = bChapterRepository.getLessonIdBychaperId(id);
if (bChapter == null)
throw new ServiceException(ResultServiceEnums.CHAPTER_NOT_EXISTS);
int chapterCount =bChapterRepository.getlessonHours(lessonId);
BLesson bLesson = bLessonRepository.selectByPrimaryKey(lessonId);
if("2".equals(bLesson.getReleaseState()) && chapterCount == 1){
throw new ServiceException(ResultServiceEnums.CHAPTER_ONLY_ONE);
}
List<QueryChapterListResDTO> childList = bChapterRepository.queryBChaptersByPid(id);
boolean hasChild = childList != null && childList.size() > 0;
boolean isChapter = bChapter.getChapterLevel() == ChapterLevelEnum.CHAPTER.getCode();
if (isChapter && hasChild) {
throw new ServiceException(ResultServiceEnums.CHAPTER_HAS_CHILD);
}
String lessonId = bChapterRepository.getLessonIdBychaperId(id);
//获取第一节课的id 与当前id对比
String firstId = bChapterRepository.getFirstChapter(lessonId);
int line = bChapterRepository.removeByPrimaryKey(id);
......@@ -429,7 +424,7 @@ public class BChapterServiceImpl implements BChapterService {
String secondId = bChapterRepository.getFirstChapter(lessonId);
String time = bChapterRepository.getTimeByChapterId(secondId);
//更新到b_lesson 表
bChapterRepository.updateVideoTimeInLesson(time,lessonId);
bChapterRepository.updateCourseTimeForLesson(time,lessonId);
// 更新学生 对应章节总进度
this.updateLessonProgress(lessonId, false);
//删除student_chapter表中数据
......
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