UserOperateLogMapper.xml 2.07 KB
<?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.monitor.mysql.mapper.UserOperateLogMapper" >
  <resultMap id="BaseResultMap" type="com.model.UserOperateLog" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="user_name" property="userName" jdbcType="VARCHAR" />
    <result column="operate" property="operate" jdbcType="VARCHAR" />
    <result column="operate_desc" property="operateDesc" jdbcType="VARCHAR" />
    <result column="params" property="params" jdbcType="VARCHAR" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  </resultMap>

  <sql id="Base_Column_List" >
    id, user_name, operate,operate_desc,params,create_time
  </sql>


  <select id="selectCount" resultType="java.lang.Integer">
    select
    count(1)
    from user_operate_logs
    where 1=1
    <if test="params.beginTime !=null &amp;&amp; params.beginTime !=''">
      and  create_time &gt;= #{params.beginTime,jdbcType=TIMESTAMP}
    </if>
    <if test="params.endTime !=null &amp;&amp; params.endTime !=''">
      and  create_time &lt;= #{params.endTime,jdbcType=TIMESTAMP}
    </if>
  </select>

  <select id="selectByPage" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from user_operate_logs
    where 1=1
    <if test="params.beginTime !=null &amp;&amp; params.beginTime !=''">
      and  create_time &gt;= #{params.beginTime,jdbcType=TIMESTAMP}
    </if>
    <if test="params.endTime !=null &amp;&amp; params.endTime !=''">
      and  create_time &lt;= #{params.endTime,jdbcType=TIMESTAMP}
    </if>
    order by id desc
    limit #{startIndex},#{pageSize}
  </select>

  <insert id="insert" parameterType="com.model.UserOperateLog" >
    insert into user_operate_logs
     (user_name, operate,operate_desc,params,create_time)
    values
     (#{userName,jdbcType=VARCHAR},#{operate,jdbcType=VARCHAR},#{operateDesc,jdbcType=VARCHAR},
     #{params,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP})
  </insert>

</mapper>