实体类:
@Data
public class EvaluateRequest {
private String id;
private List<String> clazzIdList = new ArrayList<>();
private List<CourseTypeView> courseList = new ArrayList<CourseTypeView>();
private List<String> examIdList = new ArrayList<>();
}
@Data
public class CourseTypeView {
private String id;
private String name;
List<CourseExperimentView> courseList;
}
@Data
public class CourseExperimentView {
private String courseId;
private String courseName;
List<ExperimentView> experimentList;
}
xml:
<resultMap id="evaluateRequestResult" type="com.model.request.exercises.EvaluateRequest">
<result property="id" column="id"></result>
<result property="name" column="name"></result>
<result property="flag" column="flag"></result>
<collection property="courseList" ofType="com.model.response.CourseTypeView">
<result property="id" column="type_id"></result>
<collection property="courseList" ofType="com.model.response.CourseExperimentView">
<result property="courseId" column="course_id"></result>
<result property="courseName" column="course_name"></result>
</collection>
</collection>
<collection property="clazzIdList" resultMap="clazzIdMap" />
<collection property="examIdList" resultMap="examIdMap" />
</resultMap>
<resultMap id="clazzIdMap" type="String">
<result column="clazz_id" />
</resultMap>
<resultMap id="examIdMap" type="String">
<result column="exam_id" />
</resultMap>
<select id="selectOneById" parameterType="String" resultMap="evaluateRequestResult">
select distinct e.id, e.name, e.flag, becr.type_id, becr.course_id, becr.course_name, ecr.clazz_id, eer.exam_id
from bde_evaluate e
left join bde_evaluate_clazz_rel ecr on e.id = ecr.evaluate_id
left join bde_evaluate_course_rel becr on e.id = becr.evaluate_id
left join bde_evaluate_exam_rel eer on e.id = eer.evaluate_id
where e.id = #{id}
</select>