first commit
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
package com.yundage.chat.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Table("password_reset_tokens")
|
||||
public class PasswordResetToken {
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
private Long userId;
|
||||
private String token;
|
||||
private LocalDateTime expiresAt;
|
||||
private Boolean used;
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
public PasswordResetToken() {
|
||||
this.used = false;
|
||||
}
|
||||
|
||||
public PasswordResetToken(Long userId, String token, LocalDateTime expiresAt) {
|
||||
this.userId = userId;
|
||||
this.token = token;
|
||||
this.expiresAt = expiresAt;
|
||||
this.used = false;
|
||||
this.createdAt = LocalDateTime.now();
|
||||
}
|
||||
|
||||
// Getters and Setters
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public LocalDateTime getExpiresAt() {
|
||||
return expiresAt;
|
||||
}
|
||||
|
||||
public void setExpiresAt(LocalDateTime expiresAt) {
|
||||
this.expiresAt = expiresAt;
|
||||
}
|
||||
|
||||
public Boolean getUsed() {
|
||||
return used;
|
||||
}
|
||||
|
||||
public void setUsed(Boolean used) {
|
||||
this.used = used;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
return LocalDateTime.now().isAfter(expiresAt);
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return !used && !isExpired();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user