package com.muyu.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.domain.req.FaultConditionAddReq;
import com.muyu.domain.req.FaultConditionUpdReq;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.math.BigDecimal;
import java.util.function.Supplier;

/**
 * 故障规则表
 *  * @className: FaultCondition  ️✈️
 *  * @author: Yang 鹏  🦅
 *  * @date: 2024/9/23 21:07 ⏰
 *  * @Version: 1.0
 *  * @description:
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@TableName(value = "car_fault_condition",autoResultMap = true)
@Tag(name = "故障规则管理")
public class FaultCondition {
    /**
     * 故障规则表Id
     */
    @TableId(value = "carcondition_id",type = IdType.AUTO)
    @Schema(name = "故障规则表Id")
    private Long carconditionId;
    /**
     * 车辆类型Id
     */
    @Schema(name = "车辆类型Id")
    private Long carTypeId;
    /**
     *故障名称Id
     */
    @Schema(name = "故障名称Id")
    private Long messageTypeId;
    /**
     * 故障条件
     */
    @Schema(name = "故障条件")
    private String faultconditionIdentification;
    /**
     * 故障规则参数
     */
    @Schema(name = "故障规则参数")
    private BigDecimal faultconditionParameter;
    /**
     * 车辆类型名称
     */
    @Schema(name = "车辆类型名称")
    private String carTypeName;
    /**
     * 故障名称
     */
    @Schema(name = "故障名称")
    private String messageTypeName;
    /**
     * 报文编码
     */
    @Schema(name = "报文编码")
    private String messageTypeCode;


    public static FaultCondition faultConditionadd(FaultConditionAddReq faultConditionAddReq){
        return FaultCondition.builder()
                .carTypeId(faultConditionAddReq.getCarTypeId())
                .messageTypeId(faultConditionAddReq.getMessageTypeId())
                .faultconditionIdentification(faultConditionAddReq.getFaultconditionIdentification())
                .faultconditionParameter(faultConditionAddReq.getFaultconditionParameter())
                .build();
    }

    public static FaultCondition faultConditionupd(FaultConditionUpdReq faultConditionUpdReq, Supplier<Long> idSupplier){
        return FaultCondition.builder()
                .carconditionId(faultConditionUpdReq.getCarconditionId())
                .carTypeId(faultConditionUpdReq.getCarTypeId())
                .messageTypeId(faultConditionUpdReq.getMessageTypeId())
                .faultconditionIdentification(faultConditionUpdReq.getFaultconditionIdentification())
                .faultconditionParameter(faultConditionUpdReq.getFaultconditionParameter())
                .build();
    }





}
