package de.oaa.xxx.passwordreset;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;
import java.util.UUID;

@Getter
@Setter
@Entity
@Table(name = "password_reset")
public class PasswordResetEntity {

    @Id
    @Column
    private UUID tokenId;

    @Column(unique = true)
    private String email;

    @Column
    private LocalDateTime createdAt;

    @Override
    public String toString() {
        return "PasswordResetEntity[tokenId=" + tokenId + ", email=" + email + ", createdAt=" + createdAt + "]";
    }

    public static PasswordResetEntity create(String email) {
        PasswordResetEntity entity = new PasswordResetEntity();
        entity.setTokenId(UUID.randomUUID());
        entity.setEmail(email);
        entity.setCreatedAt(LocalDateTime.now());
        return entity;
    }
}
