OnlineMapper.xml
3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?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.huaheng.pc.monitor.online.mapper.UserOnlineMapper">
<resultMap type="UserOnline" id="UserOnlineResult">
<id property="sessionId" column="sessionId" />
<result property="loginName" column="loginName" />
<result property="deptName" column="deptName" />
<result property="ipaddr" column="ipaddr" />
<result property="longinLocation" column="loginLocation" />
<result property="browser" column="browser" />
<result property="os" column="os" />
<result property="status" column="status" />
<result property="startTimestamp" column="startTimestsamp" />
<result property="lastAccessTime" column="lastAccessTime" />
<result property="expireTime" column="expireTime" />
<result property="warehouseCode" column="warehouseCode" />
<association property="session" javaType="OnlineSession" resultMap="OnlineSessionResult" />
</resultMap>
<resultMap type="OnlineSession" id="OnlineSessionResult">
<result property="host" column="ipaddr" />
<result property="browser" column="browser" />
<result property="os" column="os" />
<result property="status" column="status" />
</resultMap>
<sql id="selectOnlineVo">
select sessionId,loginName,deptName,ipaddr,loginLocation,browser,os,status,status,startTimestsamp,lastAccessTime,expireTime,warehouseCode
from sys_user_online
</sql>
<select id="selectOnlineById" parameterType="String" resultMap="UserOnlineResult">
<include refid="selectOnlineVo"/>
where sessionid = #{sessionid}
</select>
<insert id="saveOnline" parameterType="UserOnline">
replace into sys_user_online(sessionId, loginName, deptName, ipaddr, loginLocation, browser, os, status, startTimestsamp, lastAccessTime, expireTime,warehouseCode)
values (#{sessionId}, #{loginName}, #{deptName}, #{ipaddr}, #{longinLocation}, #{browser}, #{os}, #{status}, #{startTimestamp}, #{lastAccessTime}, #{expireTime},#{warehouseCode})
</insert>
<delete id="deleteOnlineById" parameterType="String">
delete from sys_user_online where sessionId = #{sessionId}
</delete>
<select id="selectUserOnlineList" parameterType="UserOnline" resultMap="UserOnlineResult">
<include refid="selectOnlineVo"/>
<where>
<if test="ipaddr != null and ipaddr != ''">
AND ipaddr like concat('%', #{ipaddr}, '%')
</if>
<if test="warehouseCode != null and warehouseCode != ''">
AND warehouseCode = #{warehouseCode}
</if>
<if test="loginName != null and loginName != ''">
AND loginName like concat('%', #{loginName}, '%')
</if>
</where>
</select>
<select id="selectOnlineByExpired" parameterType="String" resultMap="UserOnlineResult">
<include refid="selectOnlineVo"/> o
WHERE o.lastAccessTime <![CDATA[ <= ]]> #{lastAccessTime} ORDER BY o.lastAccessTime ASC
</select>
</mapper>