1
0

feat(web): 增加账号最后登陆时间

This commit is contained in:
2024-11-19 19:14:32 +08:00
parent 9a01d74d78
commit 323d326e8d
9 changed files with 154 additions and 44 deletions

View File

@@ -46,6 +46,7 @@ public class User {
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private State state = State.CHECKING;
private LocalDateTime lastLoginTime;
@CreatedDate
private LocalDateTime createTime;
@LastModifiedDate

View File

@@ -79,6 +79,8 @@ public class UserService {
throw new LoginFailureException();
} else {
StpUtil.login(user.getId());
user.setLastLoginTime(LocalDateTime.now());
userRepository.save(user);
return new UserInformation(user, StpUtil.getTokenInfo());
}
}
@@ -232,16 +234,16 @@ public class UserService {
private String username;
private User.Role role;
private User.State state;
private LocalDateTime lastLoginTime;
private LocalDateTime createTime;
private LocalDateTime updateTime;
public UserListItem(User user) {
this.id = user.getId();
this.username = user.getUsername();
this.role = user.getRole();
this.state = user.getState();
this.lastLoginTime = user.getLastLoginTime();
this.createTime = user.getCreateTime();
this.updateTime = user.getUpdateTime();
}
}
@@ -250,15 +252,15 @@ public class UserService {
private String username;
private User.Role role;
private User.State state;
private LocalDateTime lastLoginTime;
private LocalDateTime createTime;
private LocalDateTime updateTime;
public UserDetail(User user) {
this.username = user.getUsername();
this.role = user.getRole();
this.state = user.getState();
this.lastLoginTime = user.getLastLoginTime();
this.createTime = user.getCreateTime();
this.updateTime = user.getUpdateTime();
}
}
}