From a9dcb6cf7c4c0f1d64c962726fd93ed6813074ec Mon Sep 17 00:00:00 2001
From: wangxy <1356089412@qq.com>
Date: Wed, 5 Jun 2024 14:05:13 +0800
Subject: [PATCH] =?UTF-8?q?fix:=E4=BC=9A=E8=AF=9D=E4=BF=A1=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../system/mapper/SysUserOnlineMapper.java | 10 ++++++++++
.../impl/SysUserOnlineServiceImpl.java | 9 ++++++++-
.../mapper/system/SysUserOnlineMapper.xml | 19 ++++++++++++++++++-
3 files changed, 36 insertions(+), 2 deletions(-)
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}