<?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.simuwang.base.mapper.system.SysLogMapper">
    <resultMap id="BaseResultMap" type="com.simuwang.base.pojo.dos.LoggingDO">
        <id column="id" property="id"/>
        <result column="title" property="title"/>
        <result column="type" property="type"/>
        <result column="request_uri" property="requestUri"/>
        <result column="method" property="method"/>
        <result column="remote_addr" property="remoteAddr"/>
        <result column="execute_time" property="executeTime"/>
        <result column="params" property="params"/>
        <result column="user_name" property="userName"/>
        <result column="createtime" property="createTime"/>
    </resultMap>
    <update id="deleteLog">
        delete from  PPW_EMAIL.sys_log where id in
        <foreach item="id" collection="idList" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    <select id="searchLogList" resultMap="BaseResultMap">
          select distinct log.id,log.title,log.type,log.request_uri,log.method,log.remote_addr,log.execute_time,log.params,log.params,log.createtime,u.user_name
          from PPW_EMAIL.sys_log log
          left join PPW_EMAIL.sys_user u
          on log.creatorid=u.user_id and u.isvalid=1
        <where>
            <if test="title != null and title !=''">
                and log.title like concat ('%',#{title},'%')
            </if>
            <if test="userName != null and userName !=''">
                and u.user_name like concat ('%',#{userName},'%')
            </if>
        </where>
        order by log.createtime desc
        limit #{offset},#{pageSize}
    </select>
    <select id="countLogList" resultType="java.lang.Long">
        select count(distinct log.id)
        from PPW_EMAIL.sys_log log
        left join PPW_EMAIL.sys_user u
        on log.creatorid=u.user_id and u.isvalid=1
        <where>
            <if test="title != null and title !=''">
                and log.title like concat ('%',#{title},'%')
            </if>
            <if test="userName != null and userName !=''">
                and u.user_name like concat ('%',#{userName},'%')
            </if>
        </where>
    </select>


</mapper>