package com.muyu.fault.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.fault.domain.req.FaultCodeAddReq;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

/**
 * @className: FaultCode  ️✈️
 * @author: Yang 鹏  🦅
 * @date: 2024/9/23 22:21 ⏰
 * @Version: 1.0
 * @description:
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@TableName(value = "car_faultcode", autoResultMap = true)
public class FaultCode {
    /**
     * 故障码Id
     */
    @TableId(value = "faultcode_id", type = IdType.AUTO)
    private long faultcodeId;
    /**
     * 故障名称Id
     */
    private long messageTypeId;
    /**
     * 故障码
     */
    private String faultcodeNumber;
    /**
     * 故障组
     */
    private String faultGroup;
    /**
     * 故障位
     */
    private String faultBit;
    /**
     * 故障值
     */
    private String faultValue;
    /**
     * 是否警告
     */
    private Integer isWarning;

    private String faulttypeName;
    private String messageTypeName;
    private String messageTypeCode;
    private String messageTypeBelongs;

    public static FaultCode addfaultcode(FaultCodeAddReq faultCodeAddReq) {
        return FaultCode.builder()
                .faultcodeId(0)
                .messageTypeId(faultCodeAddReq.getMessageTypeId())
                .faultcodeNumber(faultCodeAddReq.getFaultcodeNumber())
                .faultGroup(faultCodeAddReq.getFaultGroup())
                .faultBit(faultCodeAddReq.getFaultBit())
                .faultValue(faultCodeAddReq.getFaultValue())
                .isWarning(faultCodeAddReq.getIsWarning())
                .build();
    }
}
