package com.muyu.fault.domain.resp;

import com.fasterxml.jackson.annotation.JsonFormat;

import com.muyu.fault.domain.FaultLog;
import com.muyu.common.core.annotation.Excel;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.util.Date;

/**
 * @className: Messages  ️✈️
 * @author: Yang 鹏  🦅
 * @date: 2024/9/22 10:55 ⏰
 * @Version: 1.0
 * @description:
 */
@Data
@Builder
@AllArgsConstructor
@Tag(name="故障日志信息响应对象",description = "故障日志的响应结果")
public class FaultLogListResp {


    /**
     * 故障日志Id
     */
    private long logId;
    /**
     * 故障码Id
     */
    private long faultcodeId;
    /**
     * 车辆Id
     */
    private long carInformationId;
    /**
     * 车辆VIN
     */
    private String carVin;
    /**
     * 开始报警时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(description = "开始报警时间",defaultValue = "2024-8-9 10:47:57",type = "Date")
    private Date startwarningTime;
    /**
     * 结束报警时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(description = "结束报警时间",defaultValue = "2024-8-9 10:47:57",type = "Date")
    private Date endwarningTime;
    /**
     * 故障码
     */
    private String faultcodeNumber;
    /**
     * 车辆vin
     */
    private String carInformationVIN;


    /**
     * 数据库对象构建为返回结果对象
     * @param faultLog
     * @return
     */
    public static FaultLogListResp faultLogListResp(FaultLog faultLog){
        return FaultLogListResp.builder()
                .logId(faultLog.getLogId())
                .faultcodeId(faultLog.getFaultcodeId())
                .carInformationId(faultLog.getCarInformationId())
                .carVin(faultLog.getCarVin())
                .startwarningTime(faultLog.getStartwarningTime())
                .endwarningTime(faultLog.getEndwarningTime())
                .faultcodeNumber(faultLog.getFaultcodeNumber())
                .carInformationVIN(faultLog.getCarInformationVIN())
                .build();
    }
}
