97 lines
2.0 KiB
Java
97 lines
2.0 KiB
Java
package com.yundage.chat.entity;
|
|
|
|
import com.mybatisflex.annotation.Id;
|
|
import com.mybatisflex.annotation.KeyType;
|
|
import com.mybatisflex.annotation.Table;
|
|
import com.mybatisflex.annotation.Column;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
@Table("password_reset_tokens")
|
|
public class PasswordResetToken {
|
|
|
|
@Id(keyType = KeyType.Auto)
|
|
private Long id;
|
|
|
|
@Column("user_id")
|
|
private Long userId;
|
|
|
|
private String token;
|
|
|
|
@Column("expires_at")
|
|
private LocalDateTime expiresAt;
|
|
|
|
private Boolean used;
|
|
|
|
@Column("created_at")
|
|
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();
|
|
}
|
|
} |