package com.ttstd.signaling.model;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

import java.time.Instant;

/**
 * 被控端 SN 白名单：仅白名单内的 SN 允许激活（provision）。
 * 由管理后台批量导入，作为 JPA 实体持久化到 MySQL。
 */
@Entity
@Table(name = "device_allowlist")
public class DeviceAllowlist {

    @Id
    @Column(name = "sn", length = 64, nullable = false)
    private String sn;

    @Column(name = "batch", length = 64)
    private String batch;

    @Column(name = "imported_by", length = 64)
    private String importedBy;

    @Column(name = "imported_at", nullable = false)
    private Instant importedAt;

    protected DeviceAllowlist() {
        this.sn = null;
        this.importedAt = Instant.now();
    }

    public DeviceAllowlist(String sn, String batch, String importedBy) {
        this.sn = sn;
        this.batch = batch;
        this.importedBy = importedBy;
        this.importedAt = Instant.now();
    }

    public String getSn() { return sn; }
    public String getBatch() { return batch; }
    public void setBatch(String batch) { this.batch = batch; }
    public String getImportedBy() { return importedBy; }
    public void setImportedBy(String importedBy) { this.importedBy = importedBy; }
    public Instant getImportedAt() { return importedAt; }
    public void setImportedAt(Instant importedAt) { this.importedAt = importedAt; }
}
