文章预览
传统查询逻辑的问题 在代码评审的过程中,发现有些查询逻辑可读性太差,但是一时又没找到好的方法。复杂的查询往往需要查询大量的信息。例如下面的例子,获取测验的正确率和参与率。还有测验每道题目分别的正确率和参与率。 老师可以在课堂 ( Classroom ) 上发起测验 ( Exam ),一个测验对应多道题目 ( Question ),学生 ( Student ) 可以对题目进行回答 ( StudentQuestionAnswer ) public class ExamInfoQuestionQueryService { private ExamQuestionMapper questionMapper; private StudentQuestionAnswerMapper studentQuestionAnswerMapper; private ExamMapper examMapper; private StudentMapper studentMapper; /** * 获取测验和题目的正确率和参与率 * */ public ExamDto getQuestionByExamId (String examId) { Exam exam = examMapper.selectById(examId);
………………………………