<?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="net.lab1024.smartadmin.module.business.log.useroperatelog.UserOperateLogDao">

    <resultMap id="UserOperateLogEntity" type="net.lab1024.smartadmin.module.business.log.useroperatelog.domain.UserOperateLogEntity"></resultMap>


    <select id="queryByPage" resultMap="UserOperateLogEntity">
        select
          id,
          user_id,
          user_name,
          module,
          content,
          url,
          method,
          param,
          result,
          fail_reason,
          update_time,
          create_time
        from t_user_operate_log
        <where>
            <if test="queryDTO.startDate != null and queryDTO.startDate != ''">
                AND DATE_FORMAT(create_time, '%Y-%m-%d') &gt;= #{queryDTO.startDate}
            </if>
            <if test="queryDTO.endDate != null and queryDTO.endDate != ''">
                AND DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{queryDTO.endDate}
            </if>
            <if test="queryDTO.userName != null and queryDTO.userName != ''">
                AND INSTR(user_name,#{queryDTO.userName})
            </if>
            <if test="queryDTO.resultFlag != null">
                AND result = #{queryDTO.resultFlag}
            </if>
        </where>
        order by create_time desc
    </select>

    <delete id="deleteById">
        delete from t_user_operate_log where id = #{id}
    </delete>

    <delete id="deleteByIds">
        delete from t_user_operate_log where id in
        <foreach collection="idList" open="(" close=")" separator="," item="item">
            #{item}
        </foreach>
    </delete>

</mapper>