OnlineMapper.xml 3.15 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.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>