diff --git a/src/main/java/cn/lihongjie/coal/loginUser/repository/LoginUserRepository.java b/src/main/java/cn/lihongjie/coal/loginUser/repository/LoginUserRepository.java index 96612c31..6ccc0210 100644 --- a/src/main/java/cn/lihongjie/coal/loginUser/repository/LoginUserRepository.java +++ b/src/main/java/cn/lihongjie/coal/loginUser/repository/LoginUserRepository.java @@ -17,7 +17,7 @@ public interface LoginUserRepository extends BaseRepository { @Transactional @Modifying @Query( - "update LoginUserEntity l set l.lastActiveTime = ?1 where l.id = ?2 and l.lastActiveTime < ?3") + "update LoginUserEntity l set l.lastActiveTime = ?1 where l.id = ?2 and (l.lastActiveTime < ?3 or l.lastActiveTime is null)") int updateLastActiveTimeByIdAndLastActiveTimeLessThan( LocalDateTime lastActiveTime, String id, LocalDateTime lastActiveTime1); diff --git a/src/main/java/cn/lihongjie/coal/loginUser/service/LoginUserService.java b/src/main/java/cn/lihongjie/coal/loginUser/service/LoginUserService.java index 65b76fa4..141aee39 100644 --- a/src/main/java/cn/lihongjie/coal/loginUser/service/LoginUserService.java +++ b/src/main/java/cn/lihongjie/coal/loginUser/service/LoginUserService.java @@ -124,12 +124,14 @@ public class LoginUserService extends BaseService exists = this.repository.findAllByUser(entity.getUser()); @@ -181,9 +183,9 @@ public class LoginUserService extends BaseService entry : copy.entrySet()) { - repository.updateLastActiveTimeByIdAndLastActiveTimeLessThan( + int count = repository.updateLastActiveTimeByIdAndLastActiveTimeLessThan( entry.getValue(), entry.getKey(), entry.getValue()); - log.info("更新会话最后活跃时间: {} to {}", entry.getKey(), entry.getValue()); + log.info("更新会话最后活跃时间: {} to {}, count:{}", entry.getKey(), entry.getValue(), count); } }