package com.arms.api.serverinfo.model.vo;

import com.arms.api.serverinfo.model.entity.ServerInfoEntity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.*;

import java.util.Date;

@Builder
@NoArgsConstructor
@AllArgsConstructor
@Getter
@JsonIgnoreProperties(ignoreUnknown = true)
public class ServerInfoVO {

    private String connectId;

    private String type;

    private String userId;

    private String passwordOrToken;

    private String uri;

    private Date createdDate;

    private Date updatedDate;

    public static ServerInfoVO fromEntityPublic(ServerInfoEntity serverInfoEntity){
        return ServerInfoVO.builder()
                .connectId(serverInfoEntity.getConnectId())
                .type(serverInfoEntity.getType())
                .uri(serverInfoEntity.getUri())
                .createdDate(serverInfoEntity.getCreatedDate())
                .updatedDate(serverInfoEntity.getUpdatedDate())
                .build();
    }

    public static ServerInfoVO fromEntity(ServerInfoEntity serverInfoEntity){
        return ServerInfoVO.builder()
                .connectId(serverInfoEntity.getConnectId())
                .userId(serverInfoEntity.getUserId())
                .passwordOrToken(serverInfoEntity.getPasswordOrToken())
                .type(serverInfoEntity.getType())
                .uri(serverInfoEntity.getUri())
                .createdDate(serverInfoEntity.getCreatedDate())
                .updatedDate(serverInfoEntity.getUpdatedDate())
                .build();
    }
}
