Commit fb4831ec by yangyang

后台题库查询提交

parent 784f3d1f
...@@ -18,10 +18,10 @@ public class AnswerController { ...@@ -18,10 +18,10 @@ public class AnswerController {
@Autowired @Autowired
private AnswerServiceImpl answerService; private AnswerServiceImpl answerService;
@GetMapping("/answers/{page}/{size}") @GetMapping("/answers/{page}/{size}/{question}")
public ApiResult findAllQuestion(@PathVariable("page") Integer page, @PathVariable("size") Integer size){ public ApiResult findAllQuestion(@PathVariable("page") Integer page, @PathVariable("size") Integer size, @PathVariable("question") String question){
Page<AnswerVO> answerVOPage = new Page<>(page,size); Page<AnswerVO> answerVOPage = new Page<>(page,size);
IPage<AnswerVO> answerVOIPage = answerService.findAll(answerVOPage); IPage<AnswerVO> answerVOIPage = answerService.findAll(answerVOPage,question);
return ApiResultHandler.buildApiResult(200,"查询所有题库",answerVOIPage); return ApiResultHandler.buildApiResult(200,"查询所有题库",answerVOIPage);
} }
......
...@@ -4,13 +4,20 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -4,13 +4,20 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.exam.vo.AnswerVO; import com.exam.vo.AnswerVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
@Mapper @Mapper
public interface AnswerMapper { public interface AnswerMapper {
@Select("select question, subject, score, section,level, \"选择题\" as type from multi_question " + @Select("<script> select questionid,question,answerA,answerB,answerC,answerD,rightAnswer,analysis,subject,score,section,level,oneOrMore,\"选择题\" AS type,\"multi_question\" AS tablename from multi_question " +
"union select question, subject, score, section,level, \"判断题\" as type from judge_question " + "<if test='question != \"null\"'>" +
"union select question, subject, score, section,level, \"填空题\" as type from fill_question") "where question like concat('%',#{question},'%')"
IPage<AnswerVO> findAll(Page page); + "</if>" +
"union " + "select questionid,question,\"\" AS answerA,\"\" AS answerB,\"\" AS answerC,\"\" AS answerD,answer AS rightAnswer,analysis,subject,score,section,level,\"判断题\" AS type ,\"\" AS oneOrMore,\"judge_question\" AS tablename from judge_question" +
"<if test='question != \"null\"'>" +
"where question like concat('%',#{question},'%')"
+ "</if>" +
"</script>")
IPage<AnswerVO> findAll(Page page,@Param("question") String question);
} }
...@@ -6,5 +6,5 @@ import com.exam.vo.AnswerVO; ...@@ -6,5 +6,5 @@ import com.exam.vo.AnswerVO;
public interface AnswerService { public interface AnswerService {
IPage<AnswerVO> findAll(Page<AnswerVO> page); IPage<AnswerVO> findAll(Page<AnswerVO> page,String question);
} }
...@@ -15,7 +15,7 @@ public class AnswerServiceImpl implements AnswerService { ...@@ -15,7 +15,7 @@ public class AnswerServiceImpl implements AnswerService {
private AnswerMapper answerMapper; private AnswerMapper answerMapper;
@Override @Override
public IPage<AnswerVO> findAll(Page<AnswerVO> page) { public IPage<AnswerVO> findAll(Page<AnswerVO> page,String question) {
return answerMapper.findAll(page); return answerMapper.findAll(page,question);
} }
} }
...@@ -4,10 +4,19 @@ import lombok.Data; ...@@ -4,10 +4,19 @@ import lombok.Data;
@Data @Data
public class AnswerVO { public class AnswerVO {
private String questionid;
private String answerA;
private String answerB;
private String answerC;
private String answerD;
private String question; private String question;
private String rightAnswer;
private String analysis;
private String subject; private String subject;
private String score; private String score;
private String section; private String section;
private String level; private String level;
private String type; private String type;
private String oneOrMore;
private String tablename;
} }
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