Commit 524b7876 authored by liwei's avatar liwei

修改了导入的bug,删掉了权重重复的判断,并且修改了权重的逻辑

parent 461cf89d
......@@ -221,9 +221,9 @@ public class BChapterServiceImpl extends ServiceImpl<BChapterRepository, BChapte
//查询出当前用户拥有的不同角色下的这门课程
List<BLesson> list = bChapterRepository.selectLessonsByLessonIdAndUserId(bChapter.getLessonId(),sysUser.getBusinessId());
//找出当前课程的最小开始时间和最大结束时间
if (list.size() > 0) {
BLesson one = new BLesson();
BeanUtils.copyProperties(list.get(0), one);
if (!list.isEmpty()) {
// 找出具有最小startTime的BLesson
Optional<BLesson> minStartTime = list.stream()
.min(Comparator.comparing(BLesson::getStartTime));
......@@ -255,6 +255,9 @@ public class BChapterServiceImpl extends ServiceImpl<BChapterRepository, BChapte
//过期
i1 = 0;
}
} else {
//该用户没有该课程
i1 = 0;
}
//因为 上边查询课程返回的是全部的 章节+视频id 所以当 试看时需要将 非试看的 视频id 置空
if (i == null || i == 0 || i1 == 0) {
......
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -80,8 +81,8 @@ public class TeaExamQuestionsServiceImpl extends ServiceImpl<TeaExamQuestionsRep
if (baseMapper.queryNumbeSomeCourse(teaExamQuestions) > 0)
throw new CyServiceException(1001, "同一课程下,该题目编号已存在");
if (baseMapper.queryNumberSomeWeiht(teaExamQuestions) > 0)
throw new CyServiceException(1001, "同一课程下,该权重已存在");
// if (baseMapper.queryNumberSomeWeiht(teaExamQuestions) > 0)
// throw new CyServiceException(1001, "同一课程下,该权重已存在");
teaExamQuestions.setCreateBy("1");
int line = baseMapper.insert(teaExamQuestions);
if (CollectionUtils.isNotEmpty(examQuestionDto.getOptionsList())) {
......@@ -136,8 +137,8 @@ public class TeaExamQuestionsServiceImpl extends ServiceImpl<TeaExamQuestionsRep
BeanUtils.copyProperties(examQuestionDto, teaExamQuestions);
if (baseMapper.queryNumbeSomeCourse(teaExamQuestions) > 0)
throw new CyServiceException(1001, "同一课程下,该题目编号已存在");
if (baseMapper.queryNumberSomeWeiht(teaExamQuestions) > 0)
throw new CyServiceException(1001, "同一课程下,该权重已存在");
// if (baseMapper.queryNumberSomeWeiht(teaExamQuestions) > 0)
// throw new CyServiceException(1001, "同一课程下,该权重已存在");
int line = baseMapper.updateById(teaExamQuestions);
teaExamOptionsRepository.deleteByQuestionsId(examQuestionDto.getBusinessId());
if (!examQuestionDto.getOptionsList().isEmpty()) {
......@@ -218,7 +219,6 @@ public class TeaExamQuestionsServiceImpl extends ServiceImpl<TeaExamQuestionsRep
public IPage<TeaExamQuestions> findAllByPagination(CyPageInfo<TeaExamQuestions> paginationUtility,
TeaExamQuestions teaExamQuestions) {
return baseMapper.queryTeaExamQuestionssPaged(paginationUtility, teaExamQuestions);
}
/**
......@@ -261,7 +261,6 @@ public class TeaExamQuestionsServiceImpl extends ServiceImpl<TeaExamQuestionsRep
Set<String> examCourseSet = allTeaExamQuestionsList.stream()
.map(course -> course.getNumber() + "_" + course.getCourseId())
.collect(Collectors.toCollection(HashSet::new));
// 待保存的数据
List<ExamQuestionDto> savedList = new ArrayList<>();
// 带保存的唯一key
......@@ -424,9 +423,24 @@ public class TeaExamQuestionsServiceImpl extends ServiceImpl<TeaExamQuestionsRep
//让examDTOList通过题目编号和题型进行排序
savedList.sort(Comparator.comparing(TeaExamQuestions::getNumber)
.thenComparing(TeaExamQuestions::getQuestionType));
//查询该课程下的试题中权重最大的权重
TeaExamQuestions question = new TeaExamQuestions();
question.setCourseId(courseId);
List<TeaExamQuestions> teaExamQuestions = baseMapper.queryTeaExamQuestionss(question);
//找出teaExamQuestionss中的最大权重
Integer maxWeight = 0;
if (teaExamQuestions.size() == 0) {
maxWeight = 0;
} else {
TeaExamQuestions maxWeightObj = teaExamQuestions.stream()
.max(Comparator.comparing(TeaExamQuestions::getWeight))
.orElse(null);
maxWeight = maxWeightObj.getWeight();
}
//排序完将权重赋予
for (int i = 0; i < savedList.size(); i++) {
savedList.get(i).setWeight(i + 1);
savedList.get(i).setWeight(i + maxWeight + 1);
}
......
......@@ -29,7 +29,7 @@
</update>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
<select id="queryTeaExamQuestionss" resultMap="BaseResultMap">
<select id="queryTeaExamQuestionss" resultType="org.rcisoft.business.teaexamquestions.entity.TeaExamQuestions">
select * from tea_exam_questions
where 1=1
and del_flag = '0'
......@@ -37,7 +37,7 @@
and flag = #{entity.flag}
</if>
<if test="entity.number !=null and entity.number != '' ">
and number like concat('%',#{entity.number},'%')
and number = #{entity.number}
</if>
<if test="entity.questionType !=null and entity.questionType != '' ">
and question_type = #{entity.questionType}
......
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