<select id="query" resultMap="wetlandResultMap">
SELECT * from
(
SELECT * from bio_wetland
<if test="wetland.wetlandType != null ">
WHERE FIND_IN_SET(#{wetland.wetlandType},wetland_type)
</if>
<if test="wetland.wetlandTypes != null ">
<foreach collection="wetland.wetlandTypes" item="item" index="index">
or FIND_IN_SET(#{item},wetland_type)
</foreach>
</if>
) r
WHERE r.is_deleted = 0
<if test="wetland.type != null ">
and r.type = #{wetland.type}
</if>
<if test="wetland.name != null ">
and r.name like concat('%',#{wetland.name},'%')
</if>
<if test="wetland.wetlandLevelCodes != null">
AND r.wetland_level in
<foreach collection="wetland.wetlandLevelCodes" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="wetland.regionTypeList != null and wetland.regionTypeList !='' and wetland.regionTypeList.size()>0">
AND r.region_type in
<foreach collection="wetland.regionTypeList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="wetland.cityCodeList != null and wetland.cityCodeList !='' and wetland.cityCodeList.size()>0">
AND r.city_code in
<foreach collection="wetland.cityCodeList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="wetland.districtCodeList != null and wetland.districtCodeList !='' and wetland.districtCodeList.size()>0">
AND r.district_code in
<foreach collection="wetland.districtCodeList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
Mybatis foreach用法
最新推荐文章于 2024-02-18 17:02:23 发布