mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
bugfix: 最后活跃时间
This commit is contained in:
@@ -17,7 +17,7 @@ public interface LoginUserRepository extends BaseRepository<LoginUserEntity> {
|
||||
@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);
|
||||
|
||||
|
||||
@@ -124,12 +124,14 @@ public class LoginUserService extends BaseService<LoginUserEntity, LoginUserRepo
|
||||
|
||||
public void newLogin(LoginUserEntity entity) {
|
||||
|
||||
entity.setLoginTime(LocalDateTime.now());
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
entity.setLoginTime(now);
|
||||
int seconds =
|
||||
Integer.parseInt(
|
||||
sysConfigService.getConfigVal(Constants.SYSCONFIG_SESSION_TIMEOUT));
|
||||
entity.setTimeout(seconds);
|
||||
entity.setExpireTime(LocalDateTime.now().plusSeconds(seconds));
|
||||
entity.setExpireTime(now.plusSeconds(seconds));
|
||||
entity.setLastActiveTime(now);
|
||||
|
||||
List<LoginUserEntity> exists = this.repository.findAllByUser(entity.getUser());
|
||||
|
||||
@@ -181,9 +183,9 @@ public class LoginUserService extends BaseService<LoginUserEntity, LoginUserRepo
|
||||
|
||||
for (Map.Entry<String, LocalDateTime> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user