一般我们传参都是一个参数或者一个实体类。
当我们的需要传参,实体类又没有这个属性,我们又不想在实体类添加那个属性时候我们可以这么写。(一个实体类,一个string)
直接上Mapper层
//使用@Param注解指定入参的名称
List<LwgyBaseStudent> queryStudent(@Param("lwscl") School school,@Param("studentSex") String studentSex);
mapper.xml
<select id="queryStudentByCode" resultType="Student" parameterType="School"> SELECT s.id, s.student_name, s.student_number, s.student_idcard, s.student_sex, s.student_phone, IF (b.id IS NULL, '0', '1') AS isBed, b.`name` AS bedName FROM `lwgy_base_student` s LEFT JOIN lwgy_base_bed b ON s.id = b.student_id <where> s.student_sex = #{studentSex} <if test="lwscl.universitySort=='xq'"> and student_campus = #{lwscl.id} </if> <if test="lwscl.universitySort=='xy'"> and student_college = #{lwscl.id} </if> <if test="lwscl.universitySort=='zy'"> and student_major = #{lwscl.id} </if> <if test="lwscl.universitySort=='bj'"> and student_class = #{lwscl.id} </if> </where> </select>