OnlineMapper.xml 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.juxiao.xchat.module.monitor.mapper.UserOnlineMapper">
  6. <resultMap type="com.juxiao.xchat.module.monitor.domain.UserOnline" id="UserOnlineResult">
  7. <id property="sessionId" column="sessionId" />
  8. <result property="loginName" column="login_name" />
  9. <result property="deptName" column="dept_name" />
  10. <result property="ipaddr" column="ipaddr" />
  11. <result property="loginLocation" column="login_location" />
  12. <result property="browser" column="browser" />
  13. <result property="os" column="os" />
  14. <result property="status" column="status" />
  15. <result property="startTimestamp" column="start_timestamp" />
  16. <result property="lastAccessTime" column="last_access_time" />
  17. <result property="expireTime" column="expire_time" />
  18. <association property="session" javaType="com.juxiao.xchat.module.monitor.domain.OnlineSession" resultMap="OnlineSessionResult" />
  19. </resultMap>
  20. <resultMap type="com.juxiao.xchat.module.monitor.domain.OnlineSession" id="OnlineSessionResult">
  21. <result property="host" column="ipaddr" />
  22. <result property="browser" column="browser" />
  23. <result property="os" column="os" />
  24. <result property="status" column="status" />
  25. </resultMap>
  26. <sql id="selectOnlineVo">
  27. select sessionId, login_name, dept_name, ipaddr, login_location, browser, os, status, start_timestamp, last_access_time, expire_time
  28. from sys_user_online
  29. </sql>
  30. <select id="selectOnlineById" parameterType="java.lang.String" resultMap="UserOnlineResult">
  31. <include refid="selectOnlineVo"/>
  32. where sessionid = #{sessionid}
  33. </select>
  34. <insert id="saveOnline" parameterType="com.juxiao.xchat.module.monitor.domain.UserOnline">
  35. replace into sys_user_online(sessionId, login_name, dept_name, ipaddr, login_location, browser, os, status, start_timestamp, last_access_time, expire_time)
  36. values (#{sessionId}, #{loginName}, #{deptName}, #{ipaddr}, #{loginLocation}, #{browser}, #{os}, #{status}, #{startTimestamp}, #{lastAccessTime}, #{expireTime})
  37. </insert>
  38. <delete id="deleteOnlineById" parameterType="java.lang.String">
  39. delete from sys_user_online where sessionId = #{sessionId}
  40. </delete>
  41. <select id="selectUserOnlineList" parameterType="com.juxiao.xchat.module.monitor.domain.UserOnline" resultMap="UserOnlineResult">
  42. <include refid="selectOnlineVo"/>
  43. <where>
  44. <if test="ipaddr != null and ipaddr != ''">
  45. AND ipaddr like concat('%', #{ipaddr}, '%')
  46. </if>
  47. <if test="loginName != null and loginName != ''">
  48. AND login_name like concat('%', #{loginName}, '%')
  49. </if>
  50. </where>
  51. </select>
  52. <select id="selectOnlineByExpired" parameterType="java.lang.String" resultMap="UserOnlineResult">
  53. <include refid="selectOnlineVo"/> o
  54. WHERE o.last_access_time <![CDATA[ <= ]]> #{lastAccessTime} ORDER BY o.last_access_time ASC
  55. </select>
  56. </mapper>