<?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.cloudroam.mapper.LogMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.cloudroam.model.LogDO">
|
<id column="id" property="id"/>
|
<result column="message" property="message"/>
|
<result column="user_id" property="userId"/>
|
<result column="username" property="username"/>
|
<result column="status_code" property="statusCode"/>
|
<result column="method" property="method"/>
|
<result column="path" property="path"/>
|
<result column="permission" property="permission"/>
|
<result column="create_time" property="createTime"/>
|
<result column="update_time" property="updateTime"/>
|
<result column="delete_time" property="deleteTime"/>
|
<result column="is_deleted" property="isDeleted"/>
|
</resultMap>
|
|
<select id="findLogsByUsernameAndRange" resultType="com.cloudroam.model.LogDO">
|
SELECT l.* FROM lin_log l
|
WHERE l.is_deleted = 0
|
<if test="name != null">
|
AND l.username=#{name}
|
</if>
|
<if test="start !=null and end !=null">
|
AND l.create_time BETWEEN #{start} AND #{end}
|
</if>
|
ORDER BY l.create_time DESC
|
</select>
|
|
<select id="searchLogsByUsernameAndKeywordAndRange" resultType="com.cloudroam.model.LogDO">
|
SELECT l.* FROM lin_log l
|
WHERE l.is_deleted = 0
|
<if test="name != ''">
|
AND l.username=#{name}
|
</if>
|
<if test="start !=null and end !=null">
|
AND l.create_time BETWEEN #{start} AND #{end}
|
</if>
|
<if test="keyword != null">
|
AND l.message LIKE #{keyword}
|
</if>
|
ORDER BY l.create_time DESC
|
</select>
|
|
<select id="getUserNames" resultType="java.lang.String">
|
SELECT l.username
|
FROM lin_log l
|
WHERE l.is_deleted = 0
|
GROUP BY l.username
|
HAVING COUNT(l.username) > 0
|
</select>
|
<select id="getLogsByRelationId" resultType="com.cloudroam.model.LogDO">
|
select *
|
FROM lin_log l
|
WHERE l.is_deleted = 0
|
and l.relation_id=#{relationId}
|
order by l.update_time desc
|
</select>
|
|
</mapper>
|