package com.muyu.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.function.Supplier;

/**
 * 车辆报文模板实体类
 *
 * @author 17353
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Tag(name = "车辆报文模板实体类")
@TableName(value = "car_message", autoResultMap = true)
public class CarMessage {
    //报文类型模块表
    /**
     * 自增主键
     */
    @TableId(value = "message_type_id",type = IdType.AUTO)
    private Long messageTypeId;
    /**
     * 报文编码
     */
    private String messageTypeCode;
    /**
     * 报文名称
     */
    private String messageTypeName;
    /**
     * 报文所属类别
     */
    private String messageTypeBelongs;

    //报文拆分位置主表
    /**
     * 自增主键
     */
    private Long carMessageId;
    /**
     * 车辆类型外键
     */
    private Integer carMessageCartype;
    /**
     * 车辆报文类型外键
     */
    private Integer carMessageType;
    /**
     * 开始位下标
     */
    private Integer carMessageStartIndex;
    /**
     * 结束位下标
     */
    private Integer carMessageEndIndex;
    /**
     * 报文数据类型 (固定值 区间随机值)
     */
    private String messageTypeClass;
    /**
     * 报文是否开启故障检测(0默认未开启  1开启)
     */
    private Integer carMessageState;

    private String carMessageName;

    /**
     * 修改方法
     *
     * @param carMessage
     * @param supplier
     * @return
     */
    public static CarMessage carMessageUpdBuilder(CarMessage carMessage, Supplier<Long> supplier) {
        return CarMessage.builder()
                .messageTypeId(supplier.get())
                .messageTypeCode(carMessage.messageTypeCode)
                .messageTypeName(carMessage.messageTypeName)
                .messageTypeBelongs(carMessage.messageTypeBelongs)
                .carMessageId(carMessage.carMessageId)
                .carMessageCartype(carMessage.carMessageCartype)
                .carMessageType(carMessage.carMessageType)
                .carMessageStartIndex(carMessage.carMessageStartIndex)
                .carMessageEndIndex(carMessage.carMessageEndIndex)
                .messageTypeClass(carMessage.messageTypeClass)
                .carMessageState(carMessage.carMessageState)
                .build();
    }

    /**
     * 添加方法
     *
     * @param carMessage
     * @return
     */
    public static CarMessage carMessageAddBuilder(CarMessage carMessage) {
        return CarMessage.builder()
                .messageTypeCode(carMessage.messageTypeCode)
                .messageTypeName(carMessage.messageTypeName)
                .messageTypeBelongs(carMessage.messageTypeBelongs)
                .carMessageId(carMessage.carMessageId)
                .carMessageCartype(carMessage.carMessageCartype)
                .carMessageType(carMessage.carMessageType)
                .carMessageStartIndex(carMessage.carMessageStartIndex)
                .carMessageEndIndex(carMessage.carMessageEndIndex)
                .messageTypeClass(carMessage.messageTypeClass)
                .carMessageState(carMessage.carMessageState)
                .build();
    }



/*
    private Long    messageTypeId  ;
    private String  messageTypeCode  ;
    private String  messageTypeName  ;
    private String  messageTypeBelongs ;
    private String  messageTypeClass  ;
    private Long    carMessageId  ;
    private Integer carMessageCartype  ;
    private Integer carMessageType  ;
    private Integer carMessageStartIndex  ;
    private Integer carMessageEndIndex  ;
    private Integer carMessageState  ;
 */


}
