改为模糊查询

master
xiaoCJ
parent 8e86f7cf0c
commit ed0d7abada

@ -25,6 +25,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@Api(tags = "课程方面API")
@ -318,6 +319,22 @@ public class ObjectiveApi {
* chapterId
* return:List<SysObjectiveQuestions>
*/
@AnonymousAccess
@ApiOperation("根据章节ID随机获取十道内置题目")
@PostMapping("selectRandomObjectiveByChapterId")
private List<SysObjectiveQuestions> selectRandomObjectiveByChapterId(@RequestParam String chapterId) {
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
example.createCriteria().andThreeIdEqualTo(chapterId);
List<SysTopicAndCourse> sysTopicAndCourses = sysTopicAndCourseMapper.selectByExample(example);
List<String> ids = sysTopicAndCourses.stream().map(SysTopicAndCourse::getTopicId).collect(Collectors.toList());
SysObjectiveQuestionsExample example1 = new SysObjectiveQuestionsExample();
example1.createCriteria().andObjectiveIdIn(ids).andSourceEqualTo("管理员");
List<SysObjectiveQuestions> sysObjectiveQuestions = sysObjectiveQuestionMapper.selectByExample(example1);
Collections.shuffle(sysObjectiveQuestions);
return sysObjectiveQuestions.stream().limit(10).collect(Collectors.toList());
}
/**
* ID
@ -325,6 +342,21 @@ public class ObjectiveApi {
* chapterId
* return:List<SysObjectiveQuestions>
*/
@AnonymousAccess
@ApiOperation("根据章节I查询所有内置题目")
@PostMapping("selectObjectQuestionListByChapterId")
private List<SysObjectiveQuestions> selectObjectQuestionListByChapterId(@RequestParam String chapterId) {
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
example.createCriteria().andThreeIdEqualTo(chapterId);
List<SysTopicAndCourse> sysTopicAndCourses = sysTopicAndCourseMapper.selectByExample(example);
List<String> ids = sysTopicAndCourses.stream().map(SysTopicAndCourse::getTopicId).collect(Collectors.toList());
SysObjectiveQuestionsExample example1 = new SysObjectiveQuestionsExample();
example1.createCriteria().andObjectiveIdIn(ids).andSourceEqualTo("管理员");
List<SysObjectiveQuestions> sysObjectiveQuestions = sysObjectiveQuestionMapper.selectByExample(example1);
return sysObjectiveQuestions;
}
/**
* 35
@ -333,19 +365,78 @@ public class ObjectiveApi {
* return:List<SysObjectiveQuestions>
*/
@AnonymousAccess
@ApiOperation("随机获取35道内置单选题")
@PostMapping("selectRandomObjectiveSingle")
private List<SysObjectiveQuestions> selectRandomObjectiveSingle(@RequestParam String systemOwner) {
SysOneCatalog sysOneCatalogs = getSysOneCatalogs(systemOwner);
String oneId = sysOneCatalogs.getOneId();
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
example.createCriteria().andOneIdEqualTo(oneId);
List<SysTopicAndCourse> sysTopicAndCourses = sysTopicAndCourseMapper.selectByExample(example);
List<String> ids = sysTopicAndCourses.stream().map(SysTopicAndCourse::getTopicId).collect(Collectors.toList());
SysObjectiveQuestionsExample example1 = new SysObjectiveQuestionsExample();
example1.createCriteria().andObjectiveIdIn(ids).andSourceEqualTo("管理员").andTypeEqualTo("0");
List<SysObjectiveQuestions> sysObjectiveQuestions = sysObjectiveQuestionMapper.selectByExample(example1);
Collections.shuffle(sysObjectiveQuestions);
return sysObjectiveQuestions.stream().limit(35).collect(Collectors.toList());
}
/**
* 5
* selectRandomObjectiveSingle
* selectRandomObjectiveMany
* systemOwner
* return:List<SysObjectiveQuestions>
*/
@AnonymousAccess
@ApiOperation("随机获取5道内置多选题")
@PostMapping("selectRandomObjectiveMany")
private List<SysObjectiveQuestions> selectRandomObjectiveMany(@RequestParam String systemOwner) {
SysOneCatalog sysOneCatalogs = getSysOneCatalogs(systemOwner);
String oneId = sysOneCatalogs.getOneId();
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
example.createCriteria().andOneIdEqualTo(oneId);
List<SysTopicAndCourse> sysTopicAndCourses = sysTopicAndCourseMapper.selectByExample(example);
List<String> ids = sysTopicAndCourses.stream().map(SysTopicAndCourse::getTopicId).collect(Collectors.toList());
SysObjectiveQuestionsExample example1 = new SysObjectiveQuestionsExample();
example1.createCriteria().andObjectiveIdIn(ids).andSourceEqualTo("管理员").andTypeEqualTo("1");
List<SysObjectiveQuestions> sysObjectiveQuestions = sysObjectiveQuestionMapper.selectByExample(example1);
Collections.shuffle(sysObjectiveQuestions);
return sysObjectiveQuestions.stream().limit(5).collect(Collectors.toList());
}
/**
* 10
* selectRandomObjectiveJudge
* systemOwner
* return:List<SysObjectiveQuestions>
*/
@AnonymousAccess
@ApiOperation("随机获取5道内置多选题")
@PostMapping("selectRandomObjectiveJudge")
private List<SysObjectiveQuestions> selectRandomObjectiveJudge(@RequestParam String systemOwner) {
SysOneCatalog sysOneCatalogs = getSysOneCatalogs(systemOwner);
String oneId = sysOneCatalogs.getOneId();
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
example.createCriteria().andOneIdEqualTo(oneId);
List<SysTopicAndCourse> sysTopicAndCourses = sysTopicAndCourseMapper.selectByExample(example);
List<String> ids = sysTopicAndCourses.stream().map(SysTopicAndCourse::getTopicId).collect(Collectors.toList());
SysObjectiveQuestionsExample example1 = new SysObjectiveQuestionsExample();
example1.createCriteria().andObjectiveIdIn(ids).andSourceEqualTo("管理员").andTypeEqualTo("2");
List<SysObjectiveQuestions> sysObjectiveQuestions = sysObjectiveQuestionMapper.selectByExample(example1);
Collections.shuffle(sysObjectiveQuestions);
return sysObjectiveQuestions.stream().limit(10).collect(Collectors.toList());
}
/**
*
@ -353,6 +444,29 @@ public class ObjectiveApi {
* schoolId systemOwner
* return:Integer
*/
@AnonymousAccess
@ApiOperation("获取客观题库单选题数量")
@PostMapping("selectCountSingle")
private Integer selectCountSingle(@RequestParam String systemOwner,
@RequestParam String schoolId) {
SysOneCatalog sysOneCatalogs = getSysOneCatalogs(systemOwner);
String oneId = sysOneCatalogs.getOneId();
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
example.createCriteria().andOneIdEqualTo(oneId);
List<SysTopicAndCourse> sysTopicAndCourses = sysTopicAndCourseMapper.selectByExample(example);
List<String> ids = sysTopicAndCourses.stream().map(SysTopicAndCourse::getTopicId).collect(Collectors.toList());
SysObjectiveQuestionsExample example1 = new SysObjectiveQuestionsExample();
List<String> list = new ArrayList();
list.add(schoolId);
list.add("管理员");
example1.createCriteria().andObjectiveIdIn(ids).andSourceIn(list).andTypeEqualTo("0");
List<SysObjectiveQuestions> sysObjectiveQuestions = sysObjectiveQuestionMapper.selectByExample(example1);
return sysObjectiveQuestions.size();
}
/**
*
@ -360,6 +474,29 @@ public class ObjectiveApi {
* schoolId systemOwner
* return:Integer
*/
@AnonymousAccess
@ApiOperation("获取客观题库多选题数量")
@PostMapping("selectCountMany")
private Integer selectCountMany(@RequestParam String systemOwner,
@RequestParam String schoolId) {
SysOneCatalog sysOneCatalogs = getSysOneCatalogs(systemOwner);
String oneId = sysOneCatalogs.getOneId();
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
example.createCriteria().andOneIdEqualTo(oneId);
List<SysTopicAndCourse> sysTopicAndCourses = sysTopicAndCourseMapper.selectByExample(example);
List<String> ids = sysTopicAndCourses.stream().map(SysTopicAndCourse::getTopicId).collect(Collectors.toList());
SysObjectiveQuestionsExample example1 = new SysObjectiveQuestionsExample();
List<String> list = new ArrayList();
list.add(schoolId);
list.add("管理员");
example1.createCriteria().andObjectiveIdIn(ids).andSourceIn(list).andTypeEqualTo("1");
List<SysObjectiveQuestions> sysObjectiveQuestions = sysObjectiveQuestionMapper.selectByExample(example1);
return sysObjectiveQuestions.size();
}
/**
*
@ -367,4 +504,26 @@ public class ObjectiveApi {
* schoolId systemOwner
* return:Integer
*/
@AnonymousAccess
@ApiOperation("获取客观题库单选题数量")
@PostMapping("selectCountJudge")
private Integer selectCountJudge(@RequestParam String systemOwner,
@RequestParam String schoolId) {
SysOneCatalog sysOneCatalogs = getSysOneCatalogs(systemOwner);
String oneId = sysOneCatalogs.getOneId();
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
example.createCriteria().andOneIdEqualTo(oneId);
List<SysTopicAndCourse> sysTopicAndCourses = sysTopicAndCourseMapper.selectByExample(example);
List<String> ids = sysTopicAndCourses.stream().map(SysTopicAndCourse::getTopicId).collect(Collectors.toList());
SysObjectiveQuestionsExample example1 = new SysObjectiveQuestionsExample();
List<String> list = new ArrayList();
list.add(schoolId);
list.add("管理员");
example1.createCriteria().andObjectiveIdIn(ids).andSourceIn(list).andTypeEqualTo("2");
List<SysObjectiveQuestions> sysObjectiveQuestions = sysObjectiveQuestionMapper.selectByExample(example1);
return sysObjectiveQuestions.size();
}
}

@ -45,7 +45,7 @@ public class AdminDataController {
@PostMapping("add")
@ApiOperation("新增")
@Transactional
ResultEntity<String> add(@ModelAttribute AdminDataDto adminDataDto) {
ResultEntity<String> add(@RequestBody AdminDataDto adminDataDto) {
if (StringUtils.isBlank(adminDataDto.getName())) {
return new ResultEntity<>(HttpStatus.OK, "请输入名称!");
}
@ -200,7 +200,7 @@ public class AdminDataController {
@ApiOperation("编辑")
@AnonymousAccess
@Transactional
ResultEntity<String> updateAdminData(@ModelAttribute AdminDataDto adminDataDto) {
ResultEntity<String> updateAdminData(@RequestBody AdminDataDto adminDataDto) {
//新增
try {
AdminDataWithBLOBs adminDataWithBLOBs = adminDataMapper.selectByPrimaryKey(adminDataDto.getDataId());

Loading…
Cancel
Save