package com.friday.tooldriver.po.taieoc;

import com.friday.operation.api.keepalive.dto.smartrpa.MachineLicenseRespDto;
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.Date;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class MachineLicensePo {
    /**
     * 主键
     */
    private Long id;
    /**
     * 机器信息key
     */
    private String machineKey;
    /**
     * 机器类型
     */
    private String machineType;
    /**
     * 许可信息
     */
    private String license;
    /**
     * 许可类型
     */
    private String licenseType;
    /**
     * 许可生效时间
     */
    private Date startTime;
    /**
     * 许可到期时间
     */
    private Date endTime;

    private int isValid;

    /**
     * 请求参数
     */
    private String requestParam;

    public MachineLicenseRespDto createRespDto(String authState){
        return MachineLicenseRespDto.builder()
                .license(this.license)
                .licenseType(this.licenseType)
                .expireTime(new SimpleDateFormat(TaieOcConstants.DATE_LONG_FORMAT).format(this.getEndTime()))
                .authState(authState)
                .build();
    }
}

