diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserOnlineMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserOnlineMapper.java index 5bd68ed..94aec47 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserOnlineMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserOnlineMapper.java @@ -34,6 +34,16 @@ public interface SysUserOnlineMapper */ public int saveOnline(SysUserOnline online); + + /** + * + * 修改 + * @param online + * @return int + */ + + public int updateOnline(SysUserOnline online); + /** * 查询会话集合 * diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java index ae6087a..91c13c2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java @@ -82,9 +82,16 @@ public class SysUserOnlineServiceImpl implements ISysUserOnlineService @Override public void saveOnline(SysUserOnline online) { - userOnlineDao.saveOnline(online); + SysUserOnline sysUserOnline = userOnlineDao.selectOnlineById(online.getSessionId()); + if(StringUtils.isNull(sysUserOnline)){ + userOnlineDao.saveOnline(online); + }else{ + userOnlineDao.updateOnline(online); + } + } + /** * 查询会话集合 * diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserOnlineMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserOnlineMapper.xml index ff85fd8..47f7295 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserOnlineMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserOnlineMapper.xml @@ -29,9 +29,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - replace into sys_user_online(sessionId, login_name, dept_name, ipaddr, login_location, browser, os, status, start_timestamp, last_access_time, expire_time) + insert into sys_user_online(sessionId, login_name, dept_name, ipaddr, login_location, browser, os, status, start_timestamp, last_access_time, expire_time) values (#{sessionId}, #{loginName}, #{deptName}, #{ipaddr}, #{loginLocation}, #{browser}, #{os}, #{status}, #{startTimestamp}, #{lastAccessTime}, #{expireTime}) + + + update sys_user_online + + login_name = #{loginName}, + dept_name = #{deptName}, + ipaddr = #{ipaddr}, + login_location = #{loginLocation}, + browser = #{browser}, + os = #{os}, + status = #{status}, + start_timestamp = #{startTimestamp}, + last_access_time = #{lastAccessTime}, + expire_time = #{expireTime}, + + where sessionId = #{sessionId} + delete from sys_user_online where sessionId = #{sessionId}