mybatis使用注解实现一对多关联查询
@Select("select id,mockexam_section as section,id as sectionId"
+ " from t_p_qb_mockexam_section"
+ " where mockexam_charpter_id = #{charpterId} and is_delete = 0"
+ " order by mockexam_section_idx asc")
@Results({
@Result(property = "questionList",column = "sectionId",many = @Many(select = "com.zikaoshu.baseinfo.mapper.BaseinfoQuestionMapper.listQuestionResDto"))})
List<SectionQuestionDto> listSectionQuestionDto(@Param("charpterId") Integer charpterId);
@Select("select id,type,discuss_title as discussTitle,stem1,material,a,b,c,d,e,answer,analysis,mockeaxm_section_id as sectionId"
+ " from t_p_qb_question_mockexam"
+ " where mockeaxm_section_id = #{id} and is_delete = 0"
+ " order by q_sequence,gmt_create asc")
List<QuestionResDto> listQuestionResDto(@Param("id") Integer id);