<?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="cn.stylefeng.guns.modular.system.mapper.LoginLogMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.stylefeng.guns.modular.system.entity.LoginLog">
        <id column="LOGIN_LOG_ID" property="loginLogId"/>
        <result column="LOG_NAME" property="logName"/>
        <result column="USER_ID" property="userId"/>
        <result column="CREATE_TIME" property="createTime"/>
        <result column="SUCCEED" property="succeed"/>
        <result column="MESSAGE" property="message"/>
        <result column="IP_ADDRESS" property="ipAddress"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        LOGIN_LOG_ID AS loginLogId, LOG_NAME AS logName, USER_ID AS userId, CREATE_TIME AS createTime, SUCCEED AS succeed, MESSAGE AS message, IP_ADDRESS AS ipAddress
    </sql>

    <select id="getLoginLogs" resultType="map" parameterType="com.baomidou.mybatisplus.extension.plugins.pagination.Page">
        select
        <include refid="Base_Column_List"/>
        from sys_login_log where 1 = 1
        <if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
            and (CREATE_TIME between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
        </if>
        <if test="logName != null and logName !=''">
            and LOG_NAME like CONCAT('%',#{logName},'%')
        </if>
    </select>

</mapper>
