package com.muyu.domain.resp;


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

/**
 * 故障码信息响应对象
 * @Author：weiran
 * @Package：com.muyu.cloud.faultmanage.domain.resp
 * @Project：cloud-faultmanage
 * @name：FaultCodeListResp
 * @Date：2024/9/17 15:41
 */

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

    /**
     *故障码Id
     */
    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 messageTypeCode;
    /**
     *报文名称
     */
    private String messageTypeName;
    /**
     *报文所属类别
     */
    private String messageTypeBelongs;

    /**
     * 数据库对象构建为返回结果对象
     * @param faultCode
     * @return
     */
    public static FaultCodeListResp faultCodeListResp(FaultCode faultCode){
        return FaultCodeListResp.builder()
                .faultcodeId(faultCode.getFaultcodeId())
                .messageTypeId(faultCode.getMessageTypeId())
                .faultcodeNumber(faultCode.getFaultcodeNumber())
                .faultGroup(faultCode.getFaultGroup())
                .faultBit(faultCode.getFaultBit())
                .faultValue(faultCode.getFaultValue())
                .isWarning(faultCode.getIsWarning())
                .faulttypeName(faultCode.getFaulttypeName())
                .messageTypeName(faultCode.getMessageTypeName())
                .messageTypeCode(faultCode.getMessageTypeCode())
                .messageTypeBelongs(faultCode.getMessageTypeBelongs())
                .build();
    }
}
