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.MessageValueAddReq;
import com.muyu.common.core.web.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

/**
 * 报文类型对象 message_type
 *
 * @author muyu
 * @date 2024-09-18
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "message_value", autoResultMap = true)
public class MessageValue extends BaseEntity {

    /**
     * 报文数据主键
     */
    @TableId(value = "message_id", type = IdType.AUTO)
    @Schema(description = "报文数据主键",type = "Long")
    private Long messageId;

    /**
     * 模版主键
     */
    @Schema(description = "模版主键",type = "Long")
    private Long templateId;

    /**
     * 报文类别
     */
    @Schema(description = "报文类别",type = "String")
    private String messageType;

    /**
     * 报文编码
     */
    @Schema(description = "报文编码",type = "String")
    private String messageCode;

    /**
     * 报文标签
     */
    @Schema(description = "报文标签",type = "String")
    private String messageLabel;

    /**
     * 起始下标
     */
    @Schema(description = "起始下标",type = "Integer")
    private Integer messageStartIndex;

    /**
     * 终止下标
     */
    @Schema(description = "终止下标",type = "Integer")
    private Integer messageEndIndex;

    public static MessageValue addBuild(MessageValueAddReq messageValueAddReq){
        return MessageValue.builder()
                .templateId(messageValueAddReq.getTemplateId())
                .messageType(messageValueAddReq.getMessageType())
                .messageCode(messageValueAddReq.getMessageCode())
                .messageLabel(messageValueAddReq.getMessageLabel())
                .messageStartIndex(messageValueAddReq.getMessageStartIndex())
                .messageEndIndex(messageValueAddReq.getMessageEndIndex())
                .build();
    }
}
