package com.muyu.domain.resp;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
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 lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @className: Messages  ️✈️
 * @author: Yang 鹏  🦅
 * @date: 2024/9/22 10:55 ⏰
 * @Version: 1.0
 * @description:
 */

/**
 * 故障日志信息响应对象
 */
@Data
@Builder
@AllArgsConstructor
@Tag(name="故障日志信息响应对象",description = "故障日志的响应结果")
@NoArgsConstructor
@TableName(value = "car_fault_log",autoResultMap = true)
public class FaultLogListResp {


    /**
     * 故障日志Id
     */
    @TableId(value = "log_id",type = IdType.AUTO)
    @Schema(description = "故障日志Id",example = "1")
    private Long logId;
    /**
     * 故障码Id
     */
    @Schema(name = "故障码Id")
    private Long faultcodeId;
    /**
     * 车辆Id
     */
    @Schema(name = "车辆Id")
    private Long carInformationId;
    /**
     * 车辆VIN
     */
    @Schema(name = "车辆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;
    /**
     * 故障码
     */
    @Schema(name = "故障码")
    private String faultcodeNumber;
    /**
     * 车辆vin
     */
    @Schema(name = "车辆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();
    }
}
