单点登陆
parent
8926ac4236
commit
e3158205b0
|
@ -6,6 +6,7 @@ import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 曹林
|
* @author 曹林
|
||||||
|
@ -18,10 +19,20 @@ public class TestQuestionTypeDto {
|
||||||
|
|
||||||
//科目
|
//科目
|
||||||
private String subject;
|
private String subject;
|
||||||
//判断题
|
|
||||||
private Integer judgeNum;
|
private List<TestOfChapter> chapterList;
|
||||||
//单选题
|
|
||||||
private Integer radioNum;
|
@Data
|
||||||
//多选题
|
@Accessors(chain = true)
|
||||||
private Integer multipleChoiceNum;
|
public static class TestOfChapter {
|
||||||
|
//章节
|
||||||
|
private String chapter;
|
||||||
|
//判断题
|
||||||
|
private Integer judgeNum;
|
||||||
|
//单选题
|
||||||
|
private Integer radioNum;
|
||||||
|
//多选题
|
||||||
|
private Integer multipleChoiceNum;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,24 +110,36 @@ public class TdQuestionServiceImpl extends ServiceImpl<TdQuestionMapper, TdQuest
|
||||||
Optional<TestQuestionTypeDto> optional = testQuestionTypeDtos.stream().filter(s -> StrUtil.equals(s.getSubject(), queryDto.getSubject())).findFirst();
|
Optional<TestQuestionTypeDto> optional = testQuestionTypeDtos.stream().filter(s -> StrUtil.equals(s.getSubject(), queryDto.getSubject())).findFirst();
|
||||||
if (optional.isPresent()) {
|
if (optional.isPresent()) {
|
||||||
TestQuestionTypeDto testQuestionTypeDto = optional.get();
|
TestQuestionTypeDto testQuestionTypeDto = optional.get();
|
||||||
//判断题
|
List<TestQuestionTypeDto.TestOfChapter> chapterList = testQuestionTypeDto.getChapterList();
|
||||||
if (Objects.nonNull(testQuestionTypeDto.getJudgeNum()) && testQuestionTypeDto.getJudgeNum() > 0) {
|
if (CollectionUtil.isEmpty(chapterList)){
|
||||||
queryDto.setType(Constants.QUESTION_TYPE_ONE)
|
return resultList;
|
||||||
.setNum(testQuestionTypeDto.getJudgeNum());
|
|
||||||
resultList.addAll(this.getBaseMapper().queryQuestionByRandom(queryDto));
|
|
||||||
}
|
}
|
||||||
//单选
|
for (TestQuestionTypeDto.TestOfChapter testOfChapter : chapterList) {
|
||||||
if (Objects.nonNull(testQuestionTypeDto.getRadioNum()) && testQuestionTypeDto.getRadioNum() > 0) {
|
//判断题
|
||||||
queryDto.setType(Constants.QUESTION_TYPE_TWO)
|
if (Objects.nonNull(testOfChapter.getJudgeNum()) && testOfChapter.getJudgeNum() > 0) {
|
||||||
.setNum(testQuestionTypeDto.getRadioNum());
|
queryDto.setType(Constants.QUESTION_TYPE_ONE)
|
||||||
resultList.addAll(this.getBaseMapper().queryQuestionByRandom(queryDto));
|
.setChapter(testOfChapter.getChapter())
|
||||||
|
.setNum(testOfChapter.getJudgeNum());
|
||||||
|
resultList.addAll(this.getBaseMapper().queryQuestionByRandom(queryDto));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
for (TestQuestionTypeDto.TestOfChapter testOfChapter : chapterList) {
|
||||||
//多选
|
//单选
|
||||||
if (Objects.nonNull(testQuestionTypeDto.getMultipleChoiceNum()) && testQuestionTypeDto.getMultipleChoiceNum() > 0) {
|
if (Objects.nonNull(testOfChapter.getRadioNum()) && testOfChapter.getRadioNum() > 0) {
|
||||||
queryDto.setType(Constants.QUESTION_TYPE_THREE)
|
queryDto.setType(Constants.QUESTION_TYPE_TWO)
|
||||||
.setNum(testQuestionTypeDto.getMultipleChoiceNum());
|
.setChapter(testOfChapter.getChapter())
|
||||||
resultList.addAll(this.getBaseMapper().queryQuestionByRandom(queryDto));
|
.setNum(testOfChapter.getRadioNum());
|
||||||
|
resultList.addAll(this.getBaseMapper().queryQuestionByRandom(queryDto));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (TestQuestionTypeDto.TestOfChapter testOfChapter : chapterList) {
|
||||||
|
//多选
|
||||||
|
if (Objects.nonNull(testOfChapter.getMultipleChoiceNum()) && testOfChapter.getMultipleChoiceNum() > 0) {
|
||||||
|
queryDto.setType(Constants.QUESTION_TYPE_THREE)
|
||||||
|
.setChapter(testOfChapter.getChapter())
|
||||||
|
.setNum(testOfChapter.getMultipleChoiceNum());
|
||||||
|
resultList.addAll(this.getBaseMapper().queryQuestionByRandom(queryDto));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
questionOptionHandler(resultList);
|
questionOptionHandler(resultList);
|
||||||
|
@ -151,24 +163,36 @@ public class TdQuestionServiceImpl extends ServiceImpl<TdQuestionMapper, TdQuest
|
||||||
Optional<TestQuestionTypeDto> optional = testQuestionTypeDtos.stream().filter(s -> StrUtil.equals(s.getSubject(), queryDto.getSubject())).findFirst();
|
Optional<TestQuestionTypeDto> optional = testQuestionTypeDtos.stream().filter(s -> StrUtil.equals(s.getSubject(), queryDto.getSubject())).findFirst();
|
||||||
if (optional.isPresent()) {
|
if (optional.isPresent()) {
|
||||||
TestQuestionTypeDto testQuestionTypeDto = optional.get();
|
TestQuestionTypeDto testQuestionTypeDto = optional.get();
|
||||||
//判断题
|
List<TestQuestionTypeDto.TestOfChapter> chapterList = testQuestionTypeDto.getChapterList();
|
||||||
if (Objects.nonNull(testQuestionTypeDto.getJudgeNum()) && testQuestionTypeDto.getJudgeNum() > 0) {
|
if (CollectionUtil.isEmpty(chapterList)){
|
||||||
queryDto.setType(Constants.QUESTION_TYPE_ONE)
|
return resultList;
|
||||||
.setNum(testQuestionTypeDto.getJudgeNum());
|
|
||||||
resultList.addAll(this.getBaseMapper().queryQuestionIdByRandom(queryDto));
|
|
||||||
}
|
}
|
||||||
//单选
|
for (TestQuestionTypeDto.TestOfChapter testOfChapter : chapterList) {
|
||||||
if (Objects.nonNull(testQuestionTypeDto.getRadioNum()) && testQuestionTypeDto.getRadioNum() > 0) {
|
//判断题
|
||||||
queryDto.setType(Constants.QUESTION_TYPE_TWO)
|
if (Objects.nonNull(testOfChapter.getJudgeNum()) && testOfChapter.getJudgeNum() > 0) {
|
||||||
.setNum(testQuestionTypeDto.getRadioNum());
|
queryDto.setType(Constants.QUESTION_TYPE_ONE)
|
||||||
resultList.addAll(this.getBaseMapper().queryQuestionIdByRandom(queryDto));
|
.setChapter(testOfChapter.getChapter())
|
||||||
|
.setNum(testOfChapter.getJudgeNum());
|
||||||
|
resultList.addAll(this.getBaseMapper().queryQuestionIdByRandom(queryDto));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
for (TestQuestionTypeDto.TestOfChapter testOfChapter : chapterList) {
|
||||||
//多选
|
//单选
|
||||||
if (Objects.nonNull(testQuestionTypeDto.getMultipleChoiceNum()) && testQuestionTypeDto.getMultipleChoiceNum() > 0) {
|
if (Objects.nonNull(testOfChapter.getRadioNum()) && testOfChapter.getRadioNum() > 0) {
|
||||||
queryDto.setType(Constants.QUESTION_TYPE_THREE)
|
queryDto.setType(Constants.QUESTION_TYPE_TWO)
|
||||||
.setNum(testQuestionTypeDto.getMultipleChoiceNum());
|
.setChapter(testOfChapter.getChapter())
|
||||||
resultList.addAll(this.getBaseMapper().queryQuestionIdByRandom(queryDto));
|
.setNum(testOfChapter.getRadioNum());
|
||||||
|
resultList.addAll(this.getBaseMapper().queryQuestionIdByRandom(queryDto));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (TestQuestionTypeDto.TestOfChapter testOfChapter : chapterList) {
|
||||||
|
//多选
|
||||||
|
if (Objects.nonNull(testOfChapter.getMultipleChoiceNum()) && testOfChapter.getMultipleChoiceNum() > 0) {
|
||||||
|
queryDto.setType(Constants.QUESTION_TYPE_THREE)
|
||||||
|
.setChapter(testOfChapter.getChapter())
|
||||||
|
.setNum(testOfChapter.getMultipleChoiceNum());
|
||||||
|
resultList.addAll(this.getBaseMapper().queryQuestionIdByRandom(queryDto));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resultList;
|
return resultList;
|
||||||
|
@ -312,18 +336,6 @@ public class TdQuestionServiceImpl extends ServiceImpl<TdQuestionMapper, TdQuest
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
List<TestQuestionTypeDto> testQuestionTypeDtos = new ArrayList<>();
|
List<TestQuestionTypeDto> testQuestionTypeDtos = new ArrayList<>();
|
||||||
TestQuestionTypeDto dto1 = new TestQuestionTypeDto()
|
|
||||||
.setSubject("1")
|
|
||||||
.setJudgeNum(40)
|
|
||||||
.setRadioNum(60)
|
|
||||||
.setMultipleChoiceNum(0);
|
|
||||||
TestQuestionTypeDto dto2 = new TestQuestionTypeDto()
|
|
||||||
.setSubject("4")
|
|
||||||
.setJudgeNum(20)
|
|
||||||
.setRadioNum(20)
|
|
||||||
.setMultipleChoiceNum(10);
|
|
||||||
testQuestionTypeDtos.add(dto1);
|
|
||||||
testQuestionTypeDtos.add(dto2);
|
|
||||||
String jsonString = JSONArray.toJSONString(testQuestionTypeDtos);
|
String jsonString = JSONArray.toJSONString(testQuestionTypeDtos);
|
||||||
System.out.println(jsonString);
|
System.out.println(jsonString);
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,9 @@
|
||||||
<if test="queryDto.type !=null">
|
<if test="queryDto.type !=null">
|
||||||
and tq.TYPE = #{queryDto.type}
|
and tq.TYPE = #{queryDto.type}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="queryDto.chapter !=null and queryDto.chapter !=''">
|
||||||
|
and tq.CHAPTER = #{queryDto.chapter}
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
order by rand() limit ${queryDto.num};
|
order by rand() limit ${queryDto.num};
|
||||||
</select>
|
</select>
|
||||||
|
@ -273,6 +276,9 @@
|
||||||
<if test="queryDto.type !=null">
|
<if test="queryDto.type !=null">
|
||||||
and tq.TYPE = #{queryDto.type}
|
and tq.TYPE = #{queryDto.type}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="queryDto.chapter !=null and queryDto.chapter !=''">
|
||||||
|
and tq.CHAPTER = #{queryDto.chapter}
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
order by rand() limit ${queryDto.num};
|
order by rand() limit ${queryDto.num};
|
||||||
</select>
|
</select>
|
||||||
|
|
Loading…
Reference in New Issue