版权声明:本文为博主原创文章,欢迎转载,转载请注明作者、原文超链接 ,博主地址:https://blog.csdn.net/qq_31122833。 https://blog.csdn.net/qq_31122833/article/details/83894992
废话不多说,直接上代码:
1、xml代码:
<!-- 获取学生列表数据-分页-+count数据 -->
<select id="getStudentManagePage" resultMap="StudentManageVoMap,count">
SELECT sql_calc_found_rows 这里是字段 FROM
tbl_student_infomation AS tsi
LEFT JOIN tbl_college AS tco ON tsi.college_id=tco.id
LEFT JOIN tbl_profession AS tp ON tsi.profession_id=tp.id
LEFT JOIN tbl_class AS tcl ON tsi.class_id=tcl.id
WHERE 1=1
ORDER BY tcs.score DESC,tsi.is_track DESC,tsi.sno DESC limit #{offset},#{limit};
SELECT found_rows() as count;
</select>
<!--接收count数据集-->
<resultMap type="Integer" id="count">
<result column="count" jdbcType="INTEGER" javaType="Integer" />
</resultMap>
<!--接收分页数据集-->
<resultMap type="com.atage.entity.vo.StudentManageVo" id="StudentManageVoMap">
<result column="sno" jdbcType="VARCHAR" property="sno" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="sex" jdbcType="INTEGER" property="sex" />
<result column="imgUrl" jdbcType="VARCHAR" property="imgUrl" />
<result column="brithday" jdbcType="DATE" property="brithday" />
<result column="sourcePlace" jdbcType="VARCHAR" property="sourcePlace" />
<result column="singleton" jdbcType="INTEGER" property="singleton" />
<result column="parentFamily" jdbcType="INTEGER" property="parentFamily" />
<result column="enrollment" jdbcType="VARCHAR" property="enrollment" />
<result column="collegeId" jdbcType="VARCHAR" property="collegeId" />
<result column="professionId" jdbcType="VARCHAR" property="professionId" />
<result column="classId" jdbcType="VARCHAR" property="classId" />
<result column="isTrack" jdbcType="INTEGER" property="isTrack" />
<result column="score" jdbcType="DOUBLE" property="score" />
<result column="gradeC" jdbcType="DOUBLE" property="gradeC" />
<result column="gradeQ" jdbcType="DOUBLE" property="gradeQ" />
<result column="gradeId" jdbcType="VARCHAR" property="gradeId" />
<result column="clollegeName" jdbcType="VARCHAR" property="clollegeName" />
<result column="yearName" jdbcType="VARCHAR" property="yearName" />
<result column="professionName" jdbcType="VARCHAR" property="professionName" />
<result column="className" jdbcType="VARCHAR" property="className" />
<result column="teacherId" jdbcType="VARCHAR" property="teacherId" />
</resultMap>
2、Mapper代码:
//接收用list<?>
List<?> getStudentManagePage(这里是传递的条件参数);
3、service代码:
//接收用list<?>
List<?> getStudentManagePage(这里是传递的条件参数);
4、serviceimpl代码:
@Override
public List<?> getStudentManagePage(参数) {
return tblStudentInfomationMapper.getStudentManagePage(参数);
}
5、controller代码:
//这里是接收数据
List<?> list = tblStudentInfomationService.getStudentManagePage(参数);
List<StudentManageVo> studentManageVoList = new ArrayList<StudentManageVo>();
//接收分页数据
studentManageVoList = (List<StudentManageVo>)list.get(0);
//接收count数据
count = ((List<Integer>) list.get(1)).get(0);
6、看完点个赞,关注下呗~