MyBatis--------查询参数携带集合
一、携带参数
Java的查询参数里携带了一个集合。
@Data
public class TeacherParam {
private List<Long> teacherIds;
}
这个参数作为查询Mapper的参数。
@Repository
@Mapper
public interface ClassRoomMapper {
List<Teacher> queryTeacher(TeacherParam teacherParam);
}
以下是调用这个内部集合的例子。
<select id="queryTeacher" resultType="com.tyzhou.stu.model.Teacher">
select
id id,
name name
from
m_teacher
where
1=1
<if test="teacherIds != null and teacherIds.size()>0">
and id in
<foreach item="tId" index="index"
collection="teacherIds" open="(" close=")" separator=",">
#{tId}
</foreach>
</if>
</select>