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.vo.FaultCodeVo;
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;

/**
 * @className: Messages  ️✈️
 * @author: Yang 鹏  🦅
 * @date: 2024/9/22 10:55 ⏰
 * @Version: 1.0
 * @description:
 */

/**
 * 故障码信息响应对象
 */
@Data
@Builder
@AllArgsConstructor
@Tag(name="故障码信息响应对象",description = "故障码查询的响应结果")
@TableName(value = "fault_code_list_resp", autoResultMap = true)
public class FaultCodeListResp {

    /**
     *故障码Id
     */
    @TableId(value = "faultcode_id", type = IdType.AUTO)
    @Schema(description = "故障码Id",example = "1")
    private Long faultcodeId;
    /**
     *故障名称Id
     */
    @Schema(description = "故障名称Id",example = "1")
    private Long messageTypeId;
    /**
     *故障码
     */
    @Schema(description = "故障码",example = "P0001")
    private String faultcodeNumber;
    /**
     *故障组
     */
    @Schema(description = "故障组",example = "1")
    private String faultGroup;
    /**
     *故障位
     */
    @Schema(description = "故障位",example = "1")
    private String faultBit;
    /**
     *故障值
     */
    @Schema(description = "故障值",example = "1")
    private String faultValue;
    /**
     *是否警告
     */
    @Schema(description = "是否警告",example = "1")
    private Integer isWarning;
    /**
     *故障类型名称
     */
    @Schema(description = "故障类型名称",example = "1")
    private String faulttypeName;
    /**
     * 故障名称
     */
    @Schema(description = "故障名称",example = "1")
    private String messageTypeName;
    /**
     * 报文编码
     */
    @Schema(description = "报文编码",example = "1")
    private String messageTypeCode;
    /**
     *报文所属类别
     */
    @Schema(description = "报文所属类别",example = "1")
    private String messageTypeBeLongs;

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