package com.muyu.domain.resp;

import com.muyu.domain.FaultCondition;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.math.BigDecimal;

/**
 * 故障规则信息响应对象
 * @Author：weiran
 * @Package：com.muyu.cloud.faultmanage.domain.resp
 * @Project：cloud-server-8
 * @name：FaultConditionResp
 * @Date：2024/9/21 19:59
 */

@Data
@Builder
@AllArgsConstructor
@Tag(name="故障规则信息响应对象",description = "故障规则查询的响应结果")
public class FaultConditionListResp {

    /**
     * 故障规则表Id
     */
    private long carconditionId;
    /**
     * 车辆类型Id
     */
    private long carTypeId;
    /**
     *故障名称Id
     */
    private long messageTypeId;
    /**
     * 故障条件
     */
    private String faultconditionIdentification;
    /**
     * 故障规则参数
     */
    private BigDecimal faultconditionParameter;
    /**
     * 车辆类型名称
     */
    private String carTypeName;
    /**
     * 故障名称
     */
    private String messageTypeName;
    /**
     * 报文编码
     */
    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();
    }
}
