package com.aip.gateway.api.entity;

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

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

@Data
@Builder
@ToString
public class TbLinkedDecryptKey {

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


    public LinkedDecryptKeyDto toDto() {
        return LinkedDecryptKeyDto.builder()
                .decryptKeyId(this.decryptKeyId)
                .decryptKey(this.decryptKey)
                .expiredAt(this.expiredAt)
                .serverId(this.serverId)
                .serverIpAddr(this.serverIpAddr)
                .serverDesc(this.serverDesc)
                .systemId(this.systemId)
                .systemName(this.systemName)
                .serverMap(new ConcurrentHashMap<>())
                .build();
    }
}
