gasWellWatch/src/main/resources/mapper/UserOperationRecordDao.xml

75 lines
3.4 KiB
XML

<?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.isu.gaswellwatch.dao.UserOperationRecordDao">
<resultMap id="userVOResultMap" type="com.isu.gaswellwatch.vo.UserOperationRecordVO">
<id column="id" property="id"/>
<result column="username" property="username"/>
<result column="type" property="type"/>
<result column="uri" property="uri"/>
<result column="menu" property="menu"/>
<result column="nickname" property="nickname"/>
<result column="create_time" property="createTime"/>
<result column="request" property="request"/>
<result column="request_type" property="requestType"/>
<result column="result" property="result"/>
<result column="ip" property="ip"/>
<result column="name" property="name"/>
<result column="error_msg" property="errorMsg"/>
<result column="cost_time" property="costTime"/>
</resultMap>
<select id="page" resultMap="userVOResultMap">
select r.id, r.username, u.nickname, r.type, r.uri, r.create_time, r.menu , r.name , r.request ,r.request_type,r.result,r.ip,r.error_msg,r.cost_time
from user_operation_record r
left join user u on u.username = r.username
<where>
<if test="type!=null">
and r.type =#{type}
</if>
<if test="username!=null and username!='' ">
and r.username LIKE CONCAT('%',#{username},'%')
</if>
<if test="nickname!=null and nickname!='' ">
and u.nickname LIKE CONCAT('%',#{nickname},'%')
</if>
<if test="result!=null">
and r.result = #{result}
</if>
<if test="startTime!=null and startTime!='' ">
and date_format(r.create_time,'%Y-%m-%d') &gt;= date_format(#{startTime},'%Y-%m-%d')
</if>
<if test="endTime!=null and endTime!='' ">
and date_format(r.create_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d ')
</if>
</where>
order by r.create_time desc
</select>
<select id="list" resultMap="userVOResultMap">
select r.id, r.username, u.nickname, r.type, r.uri, r.create_time, r.menu , r.name , r.request ,r.request_type,r.result,r.ip,r.error_msg,r.cost_time
from user_operation_record r
left join user u on u.username = r.username
<where>
<if test="type!=null">
and r.type =#{type}
</if>
<if test="username!=null and username!='' ">
and r.username LIKE CONCAT('%',#{username},'%')
</if>
<if test="nickname!=null and nickname!='' ">
and u.nickname LIKE CONCAT('%',#{nickname},'%')
</if>
<if test="result!=null">
and r.result = #{result}
</if>
<if test="startTime!=null and startTime!='' ">
and date_format(r.create_time,'%Y-%m-%d') &gt;= date_format(#{startTime},'%Y-%m-%d')
</if>
<if test="endTime!=null and endTime!='' ">
and date_format(r.create_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
</if>
</where>
order by r.create_time desc
</select>
</mapper>