1、使用实体类对象包装参数:
/* seviceImpl层 */
public List<SysDept> getFaculty() { SysDept dept = new SysDept(); dept.setDeptType(2); dept.setStatus("0"); return deptMapper.selectDeptList(dept); }
/*.xml层对应 */
<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
<include refid="selectDeptVo"/>
where d.del_flag = '0'
<if test="status != null and status != ''">
AND status = #{status}
</if>
<if test="deptType != null and deptType != 0 ">
AND dept_type = #{deptType}
</if>
</select>
2、使用@Param注解
/* mapper层对应接口 */ List<SysDept> queryDeptForMajorOrGrade(@Param("deptId") Long deptId, @Param("deptType") String deptType);
/* .xml层对应 (不用写参数类型 parameterType的值 )*/
<select id="queryDeptForMajorOrGrade" resultMap="SysDeptResult">
select d.dept_id, d.dept_name from sys_dept d where d.del_flag = '0' and d.status = '0' and find_in_set(#{deptId}, ancestors) and dept_type = #{deptType}
</select>
3、其他。。。 集合等