<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="lingtao.net.dao.LoginIpMapper">

	<select id="getLoginIpList" parameterType="LoginIp" resultType="LoginIp">
		select * from tbl_login_ip
		<where>
			<if test="agreeIp != null and agreeIp != ''">
  				and agreeIp like '%${agreeIp}%'
  			</if>
			<if test="remark != null and remark != ''">
  				and remark like '%${remark}%'
  			</if>
		</where>
		order by createDate desc
	</select>

	<!-- 新增 -->
	<insert id="addIp" parameterType="LoginIp">
		insert into tbl_login_ip
		(agreeIp,remark,createBy,createDate,updateBy,updateTime)
		values
		(#{agreeIp},#{remark},#{createBy},now(),#{createBy},now())
	</insert>
	
	<!-- 修改 -->
	<update id="updateIp" parameterType="LoginIp">
		update tbl_login_ip
		<set>
			<if test="agreeIp != null">
				agreeIp = #{agreeIp,jdbcType=VARCHAR},
			</if>
			<if test="remark != null">
				remark = #{remark,jdbcType=VARCHAR},
			</if>
			<if test="updateBy != null">
				updateBy = #{updateBy,jdbcType=VARCHAR},
			</if>
				updateTime = now()
		</set>
		where id = #{id,jdbcType=INTEGER}
	</update>

	<!-- 删除 -->
	<delete id="deleteIpById">
		delete from tbl_login_ip where id = #{id}
	</delete>
	
	<!-- 批量删除数据 -->
  	<delete id="deleteBatch" parameterType="int">
		<!-- delete from tbl_finance where financeId in(7789,7790) -->
		<!-- forEach:用来循环; collection:用来指定循环的数据的类型; 可以填的值有：array,list,map 
			 item:循环中为每个循环的数据指定一个别名; index:循环中循环的下标 ; open:开始; close:结束; separator:数组中元素之间的分隔符 -->
		delete from tbl_login_ip where id in
		<foreach collection="array" item="id" open="(" separator="," close=")">
			#{id}
		</foreach>
  	</delete>
</mapper>