<?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="com.yunfeiyun.agmp.common.web.system.mapper.SysLogininLogMapper">

	<resultMap type="SysLoginLog" id="SysLogininLogResult">
		<id     property="loggId"        column="loggId"           />
		<result property="loggLoginname"      column="loggLoginname"         />
		<result property="loggIpaddr"        column="loggIpaddr"            />
		<result property="loggLoginlocation" column="loggLoginlocation"    />
		<result property="loggBrowser"       column="loggBrowser"           />
		<result property="loggOs"            column="loggOs"                />
		<result property="loggLoginmsg"           column="loggLoginmsg"               />
		<result property="loggLoginTime"     column="loggLoginTime"        />
	</resultMap>

	<insert id="insertLoginLog" parameterType="SysLoginLog">
		insert into SysLoginLog (loggId,loggLoginname, loggLoginstatus, loggIpaddr, loggLoginlocation, loggBrowser, loggOs, loggLoginmsg, loggLoginTime)
		values (#{loggId}, #{loggLoginname}, #{loggLoginstatus}, #{loggIpaddr}, #{loggLoginlocation}, #{loggBrowser}, #{loggOs}, #{loggLoginmsg}, date_format(sysdate(),'%Y-%m-%d %H:%i:%s'))
	</insert>
	
	<select id="selectLoginLogList" parameterType="SysLoginLog" resultMap="SysLogininLogResult">
		select loggId, loggLoginname, loggIpaddr, loggLoginlocation, loggBrowser, loggOs, loggLoginstatus, loggLoginmsg, loggLoginTime from SysLoginLog
		<where>
			<if test="loggIpaddr != null and loggIpaddr != ''">
				AND loggIpaddr like concat('%', #{loggIpaddr}, '%')
			</if>
			<if test="loggLoginstatus != null and loggLoginstatus != ''">
				AND loggLoginstatus = #{loggLoginstatus}
			</if>
			<if test="loggLoginname != null and loggLoginname != ''">
				AND loggLoginname like concat('%', #{loggLoginname}, '%')
			</if>
			<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
				AND loggLoginmsg &gt;= #{params.beginTime}
			</if>
			<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
				AND loggLoginmsg &lt;= #{params.endTime}
			</if>
		</where>
		order by loggId desc
	</select>
	
	<delete id="deleteLoginLogByIds" parameterType="String">
 		delete from SysLoginLog where loggId in
 		<foreach collection="array" item="infoId" open="(" separator="," close=")">
 			#{infoId}
        </foreach> 
 	</delete>
    
    <update id="cleanLoginLog">
        truncate table SysLoginLog
    </update>
    
</mapper> 