mybatis传入参为List写法

笔记记录,不喜勿喷
圈重点
1、parameterType=“java.util.List”
2、<foreach item="item" index="index" collection="list" open="(" separator="," close=")"> #{item} </foreach>
1、mapper.java

InspectionLastRecordDto getLastRecordByUserId(List<String> projectIdList);

2、mapper.xml

<select id="getLastRecordByUserId" parameterType="java.util.List" resultType="com.elink.estos.ibms.operation.dto.operation.InspectionLastRecordDto">
		SELECT  ih.id,
				ih.record_name as `title`,
				sc.`name` as projectName,
				DATE_FORMAT(ih.create_date,'%Y-%m-%d %H:%i:%s') as ctime
		from inspection_history ih
		left join sys_case sc
		on(ih.project_id=sc.id)
		where ih.del_flag='0'
		and ih.project_id in
		<foreach item="item" index="index" collection="list"
				 open="(" separator="," close=")">
			#{item}
		</foreach>
		order by ih.create_date desc
		limit 1
	</select>

版权声明:本文为qq_27232885原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。