package de.cannamanage.domain.entity;

import de.cannamanage.domain.enums.DevicePlatform;
import jakarta.persistence.*;
import lombok.*;

import java.time.Instant;
import java.util.UUID;

/**
 * Push notification device token — stores Web Push subscriptions and mobile push tokens.
 * A user can have multiple device tokens (multi-device support, max 10 per user).
 */
@Entity
@Table(name = "device_tokens", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"user_id", "token"})
})
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class DeviceToken extends AbstractTenantEntity {

    @Column(name = "user_id", nullable = false)
    private UUID userId;

    @Enumerated(EnumType.STRING)
    @Column(name = "platform", nullable = false, length = 20)
    private DevicePlatform platform;

    @Column(name = "token", nullable = false, columnDefinition = "TEXT")
    private String token;

    @Column(name = "device_name", length = 100)
    private String deviceName;

    @Column(name = "last_used_at")
    private Instant lastUsedAt;
}
