package com.friday.tooldriver.po.taieoc;

import com.friday.operation.api.keepalive.dto.taieoc.OcInfoDto;
import com.friday.operation.api.keepalive.dto.taieoc.OcPageDto;
import com.friday.operation.api.keepalive.constant.taieoc.TaieOcConstants;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class OcInfoPo {
    private Long id;
    /**
     * 厂商名称
     */
    private String supplier;
    /**
     * 厂商英文名称
     */
    private String supplierEn;
    /**
     * 中控名称
     */
    private String ocInfo;

    private String ocIp;

    private Boolean isValid;
    private Date createTime;
    private Date updateTime;
    private String operator;
    private String userTenant;

    public static OcPageDto createPage(OcInfoPo po){
        SimpleDateFormat sdf = new SimpleDateFormat(TaieOcConstants.DATE_LONG_FORMAT);
        return OcPageDto.builder()
                .supplierCH(po.getSupplier())
                .supplierEn(po.getSupplierEn())
                .ocInfoId(po.getId())
                .ocInfo(po.getOcInfo())
                .ocIp(po.getOcIp())
                .updateTime(sdf.format(po.getUpdateTime()))
                .operations(Arrays.asList(TaieOcConstants.QUERY,TaieOcConstants.DELETE))
                .build();
    }

    public static OcInfoDto createInfo(OcInfoPo po){
        return OcInfoDto.builder()
                .supplierCH(po.getSupplier())
                .supplierEn(po.getSupplierEn())
                .ocInfoId(po.getId())
                .ocInfo(po.getOcInfo())
                .ocIp(po.getOcIp())
                .build();

    }

    public static OcInfoPo createOcInfoPo(OcInfoDto reqDto){
        return  OcInfoPo.builder()
                .id(reqDto.getOcInfoId())
                .ocInfo(reqDto.getOcInfo())
                .supplier(reqDto.getSupplierCH())
                .supplierEn(reqDto.getSupplierEn())
                .ocIp(reqDto.getOcIp())
                .operator(reqDto.getOperator())
                .userTenant(reqDto.getUserTenant())
                .build();
    }

}
