package com.aip.gateway.api.entity;

import com.aip.gateway.api.dto.LinkedApiKeyDto;
import lombok.Builder;
import lombok.Data;
import lombok.ToString;

import java.time.LocalDateTime;
import java.util.concurrent.ConcurrentHashMap;

@Data
@Builder
@ToString
public class TbLinkedApiKey {

    private int apiKeyId;
    private String apiKey;
    private boolean policyLookupYn;
    private boolean fileInfoLookupYn;
    private boolean applyLabelYn;
    private boolean releaseLabelYn;
    private boolean encryptionFileYn;
    private boolean decryptionFileYn;

    private LocalDateTime expiredAt;
    private int serverId;
    private String serverIpAddr;
    private String serverDesc;
    private int systemId;
    private String systemName;

    public LinkedApiKeyDto toDto() {
        return LinkedApiKeyDto.builder()
                .apiKeyId(this.apiKeyId)
                .apiKey(this.apiKey)
                .policyLookupYn(this.policyLookupYn)
                .fileInfoLookupYn(this.fileInfoLookupYn)
                .applyLabelYn(this.applyLabelYn)
                .releaseLabelYn(this.releaseLabelYn)
                .encryptionFileYn(this.encryptionFileYn)
                .decryptionFileYn(this.decryptionFileYn)
                .expiredAt(this.expiredAt)
                .serverId(this.serverId)
                .serverIpAddr(this.serverIpAddr)
                .serverDesc(this.serverDesc)
                .systemId(this.systemId)
                .systemName(this.systemName)
                .serverMap(new ConcurrentHashMap<>())
                .build();
    }
}
