package de.oaa.xxx.games.chastity.keyholder;

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

import de.oaa.xxx.games.chastity.common.Verification;
import de.oaa.xxx.games.chastity.common.VerificationCommonDTO;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
@Table(name = "keyholder_verification")
public class KeyholderVerificationEntity implements Verification {

	@Id
	@Column
	private UUID verificationId;
	@Column(nullable = false)
	private UUID lockId;
	@Column(nullable = false)
	private String code;
	@Column(nullable = false)
	private LocalDateTime createdAt;
	@Column(columnDefinition = "MEDIUMBLOB")
	private byte[] image;
	@Column(nullable = false)
	private UUID lockeeId;
	@Column(nullable = false)
	private UUID keyholderId;
	@Column
	private boolean accepted;

	@Override
	public LocalDate getVerificationDate() {
		return createdAt.toLocalDate();
	}

	@Override
	public boolean isValid() {
		return accepted;
	}

	@Override
	public VerificationCommonDTO toCommonVerification() {
		return new VerificationCommonDTO(verificationId, lockId, code, createdAt, image, lockeeId, keyholderId);
	}

	@Override
	public UUID getId() {
		return verificationId;
	}

	@Override
	public void setId(UUID id) {
		setVerificationId(id);
	}	
}
