package com.muyu.domain.resp;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.muyu.domain.FaultLog;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.util.Date;

/**
 * 故障日志信息响应对象
 * @Author：weiran
 * @Package：com.muyu.cloud.faultmanage.domain.resp
 * @Project：cloud-server-8
 * @name：FaultLogResp
 * @Date：2024/9/20 9:43
 */
@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")
    @Schema(description = "开始报警时间",defaultValue = "2024-8-9 10:47:57",type = "Date")
    private Date startwarningTime;
    /**
     * 结束报警时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(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();
    }
}
