auth-server-java/service/src/main/resources/mapper/UserLoginLogMapper.xml

75 lines
3.2 KiB
XML
Raw Normal View History

2024-10-18 22:25:41 +08:00
<?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="cn.bunny.services.mapper.UserLoginLogMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.bunny.dao.entity.log.UserLoginLog">
<id column="id" property="id"/>
<id column="create_time" property="createTime"/>
<id column="update_time" property="updateTime"/>
<id column="create_user" property="createUser"/>
<id column="update_user" property="updateUser"/>
<id column="is_deleted" property="isDeleted"/>
<id column="user_id" property="userId"/>
<id column="username" property="username"/>
<id column="token" property="token"/>
<id column="ip_address" property="ipAddress"/>
2024-10-19 02:37:30 +08:00
<id column="ip_region" property="ipRegion"/>
<id column="user_agent" property="userAgent"/>
2024-10-19 02:37:30 +08:00
<id column="type" property="type"/>
<id column="x_requested_with" property="xRequestedWith"/>
2024-10-18 22:25:41 +08:00
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, create_time, update_time, create_user, update_user, is_deleted, user_id, username, token, ip_address, ip_region, user_agent, type, x_requested_with
2024-10-18 22:25:41 +08:00
</sql>
2024-10-18 23:09:29 +08:00
<!-- 分页查询用户登录日志内容 -->
2024-10-31 10:01:58 +08:00
<select id="selectListByPage" resultType="cn.bunny.dao.vo.log.UserLoginLogVo">
2024-10-18 23:09:29 +08:00
select
2024-10-31 10:01:58 +08:00
user_login.*,
create_user.username as create_username,
update_user.username as update_username
from log_user_login user_login
left join sys_user create_user on create_user.id = user_login.create_user
left join sys_user update_user on update_user.id = user_login.update_user
2024-10-18 23:09:29 +08:00
<where>
2024-10-31 10:01:58 +08:00
user_login.is_deleted = 0
<if test="dto.username != null and dto.username != ''">
2024-10-31 10:01:58 +08:00
and user_login.username like CONCAT('%',#{dto.username},'%')
</if>
<if test="dto.ipAddress != null and dto.ipAddress != ''">
2024-10-31 10:01:58 +08:00
and user_login.ip_address like CONCAT('%',#{dto.ipAddress},'%')
</if>
2024-10-19 02:37:30 +08:00
<if test="dto.ipRegion != null and dto.ipRegion != ''">
2024-10-31 10:01:58 +08:00
and user_login.ip_region like CONCAT('%',#{dto.ipRegion},'%')
2024-10-19 02:37:30 +08:00
</if>
<if test="dto.type != null and dto.type != ''">
2024-10-31 10:01:58 +08:00
and user_login.type like CONCAT('%',#{dto.type},'%')
2024-10-19 02:37:30 +08:00
</if>
<if test="dto.xRequestedWith != null and dto.xRequestedWith != ''">
2024-10-31 10:01:58 +08:00
and user_login.x_requested_with like CONCAT('%',#{dto.xRequestedWith},'%')
2024-10-19 02:37:30 +08:00
</if>
2024-10-18 23:09:29 +08:00
</where>
</select>
<!-- 分页查询根据用户Id用户登录日志内容 -->
<select id="selectListByPageWithLocalUser" resultType="cn.bunny.dao.entity.log.UserLoginLog">
select
<include refid="Base_Column_List"/>
2024-10-31 10:01:58 +08:00
from log_user_login where user_id = #{id}
</select>
2024-10-18 23:09:29 +08:00
<!-- 物理删除用户登录日志 -->
<delete id="deleteBatchIdsWithPhysics">
delete
from log_user_login
where id in
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
2024-10-18 22:25:41 +08:00
</mapper>