xml文件配置 传入对象参数 需要注意的点
1、加注解@Param
2、配置里面的参数获取是staffVo.属性 其中staffVo 是@Param里面加入的值名称
3、使用前 先使用if标签标注是否存在该值
4、大小比较使用
5、使用in时,需要表里数组 使用标签 foreach collection="staffVo.types" index="index" item="item" open="(" separator="," close=")">
其中collection 是获取对象的值 item是 获取属性值里的元素
6、resultType 标注返回值
Integer keyPopulationCount(@Param("staffVo")StaffVo staffVo);
<select id="keyPopulationCount" resultType="java.lang.Integer" parameterType="com.eshore.community.web.vo.StaffVo">
SELECT count(*) as count
FROM
community_warn
<where>
<if test="staffVo.communityId != null">
community_id = #{staffVo.communityId}
</if>
<if test="staffVo.types != null " >
and type in
<foreach collection="staffVo.types" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="staffVo.startTime != null">
and create_time <![CDATA[>]]> #{staffVo.startTime}
</if>
<if test="staffVo.endTime != null">
and create_time <![CDATA[<=]]> #{staffVo.endTime}
</if>
</where>
</select>