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.muyu.domain.FaultCondition;
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.math.BigDecimal;

/**
 * @className: FaultLog  ️✈️
 * @author: Yang 鹏  🦅
 * @date: 2024/9/23 21:06 ⏰
 * @Version: 1.0
 * @description:
 */
/**
 * 故障规则信息响应对象
 */
@Data
@Builder
@AllArgsConstructor
@Tag(name="故障规则信息响应对象",description = "故障规则查询的响应结果")
@NoArgsConstructor
@TableName(value = "car_fault_condition",autoResultMap = true)
public class FaultConditionListResp {

    /**
     * 故障规则表Id
     */
    @TableId(value = "carcondition_id",type = IdType.AUTO)
    @Schema(description = "故障规则表Id")
    private Long carconditionId;
    /**
     * 车辆类型Id
     */
    @Schema(description = "车辆类型Id")
    private Long carTypeId;
   /**
     *故障名称Id
     */
    @Schema(description = "故障名称Id")
    private Long messageTypeId;
    /**
     * 故障条件
     */
    @Schema(description = "故障条件")
    private String faultconditionIdentification;
    /**
     * 故障规则参数
     */
    @Schema(description = "故障规则参数")
    private BigDecimal faultconditionParameter;
    /**
     * 车辆类型名称
     */
    @Schema(description = "车辆类型名称")
    private String carTypeName;
    /**
     * 故障名称
     */
    @Schema(description = "故障名称")
    private String messageTypeName;
    /**
     * 报文编码
     */
    @Schema(description = "报文编码")
    private String messageTypeCode;

    /**
     * 数据库对象构建为返回结果对象
     * @param faultCondition
     * @return
     */
    public static FaultConditionListResp faultConditionListResp(FaultCondition faultCondition){
        return FaultConditionListResp.builder()
                .carconditionId(faultCondition.getCarconditionId())
                .carTypeId(faultCondition.getCarTypeId())
                .messageTypeId(faultCondition.getMessageTypeId())
                .faultconditionParameter(faultCondition.getFaultconditionParameter())
                .faultconditionIdentification(faultCondition.getFaultconditionIdentification())
                .carTypeName(faultCondition.getCarTypeName())
                .messageTypeName(faultCondition.getMessageTypeName())
                .messageTypeCode(faultCondition.getMessageTypeCode())
                .build();
    }
}
