Commit e2aa1a56 authored by luzhuang's avatar luzhuang

删除发布限定

parent 332eb49b
......@@ -406,5 +406,8 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
@Delete("delete from b_r_student_chapter where chapter_id = #{chapterId} and student_id = #{uid} ")
int deleteBStudentChapter(@Param("chapterId") String chapterId,@Param("uid") String uid);
@Select("select count(0) from b_chapter where lesson_id = #{lessonId} and chapter_level = 2 and del_flag != 1 and flag =1")
int getlessonHours(@Param("lessonId") String lessonId);
}
......@@ -399,15 +399,22 @@ 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);
if(chapterCount == 1){
throw new ServiceException(ResultServiceEnums.CHAPTER_ONLY_ONE);
}
String firstChapter = bChapterRepository.getFirstChapter(id);
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);
......
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.rcisoft.business.bchapter.dao.BChapterRepository;
import org.rcisoft.business.bcourse.dao.BCourseRepository;
import org.rcisoft.business.bcourse.dto.AllCourseDTO;
import org.rcisoft.business.bfile.dao.BTrainFileRepository;
......@@ -83,6 +84,9 @@ public class BLessonServiceImpl implements BLessonService {
@Autowired
private BMaterialRepository bMaterialRepository;
@Autowired
private BChapterRepository bChapterRepository;
@Autowired
MTCotactApiRequestClient cotactApiRequestClient;
......@@ -460,6 +464,9 @@ public class BLessonServiceImpl implements BLessonService {
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel releaseBLesson(String id) {
if(bChapterRepository.getlessonHours(id) == 0){
throw new ServiceException(ResultServiceEnums.LESSON_NO_CHAPTER);
}
BLesson bLesson = new BLesson();
bLesson.setBusinessId(id);
bLesson = bLessonRepository.selectByPrimaryKey(bLesson);
......
......@@ -231,6 +231,8 @@ public enum ResultServiceEnums {
LESSON_CLOSED(131,"该课程已关闭"),
NO_ACCESS(132,"您对该课程无可见权限"),
LABEL_MORE_NUM(133,"标签超过规定个数"),
CHAPTER_ONLY_ONE(134,"当前课程仅有一节,不能被删除"),
LESSON_NO_CHAPTER(134,"当前课程暂无章节,不能被发布"),
;
private Integer code;
......
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