package com.ruoyi.system.domain;

import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

/**
 * 聊天记录对象 chat_history
 * 
 * @author ruoyi
 * @date 2024-01-01
 */
public class ChatHistory extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 主键ID */
    private Long id;

    /** 消息ID */
    @Excel(name = "消息ID")
    private Long messageId;

    /** 用户ID */
    @Excel(name = "用户ID")
    private String userId;

    /** 会话ID */
    @Excel(name = "会话ID")
    private String sessionId;

    /** 会话ID（Long类型，兼容customer包）*/
    @Excel(name = "会话ID")
    private Long sessionIdLong;

    /** 消息类型 */
    @Excel(name = "消息类型", readConverterExp = "user=用户消息,service=客服消息")
    private String messageType;

    /** 消息内容 */
    @Excel(name = "消息内容")
    private String content;

    /** 消息内容（兼容customer包字段名）*/
    @Excel(name = "消息内容")
    private String messageContent;

    /** 是否包含链接 */
    @Excel(name = "是否包含链接", readConverterExp = "0=否,1=是")
    private Integer isLink;

    /** 是否为按钮消息 */
    @Excel(name = "是否为按钮消息", readConverterExp = "0=否,1=是")
    private Integer isButton;

    /** 发送者ID */
    @Excel(name = "发送者ID")
    private Long senderId;

    /** 接收者ID */
    @Excel(name = "接收者ID")
    private Long receiverId;

    /** 发送时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "发送时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date sentAt;

    /** 是否已读 */
    @Excel(name = "是否已读")
    private String isRead;

    /** 发送者类型 */
    @Excel(name = "发送者类型")
    private String senderType;

    public void setId(Long id) 
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }
    public void setUserId(String userId) 
    {
        this.userId = userId;
    }

    public String getUserId() 
    {
        return userId;
    }
    public void setSessionId(String sessionId) 
    {
        this.sessionId = sessionId;
    }

    public String getSessionId() 
    {
        return sessionId;
    }
    public void setMessageType(String messageType) 
    {
        this.messageType = messageType;
    }

    public String getMessageType() 
    {
        return messageType;
    }
    public void setContent(String content) 
    {
        this.content = content;
    }

    public String getContent() 
    {
        return content;
    }
    public void setIsLink(Integer isLink) 
    {
        this.isLink = isLink;
    }

    public Integer getIsLink() 
    {
        return isLink;
    }
    public void setIsButton(Integer isButton) 
    {
        this.isButton = isButton;
    }

    public Integer getIsButton() 
    {
        return isButton;
    }
    public void setSenderId(Long senderId) 
    {
        this.senderId = senderId;
    }

    public Long getSenderId() 
    {
        return senderId;
    }
    public void setReceiverId(Long receiverId) 
    {
        this.receiverId = receiverId;
    }

    public Long getReceiverId() 
    {
        return receiverId;
    }
    public void setSentAt(Date sentAt) 
    {
        this.sentAt = sentAt;
    }

    public Date getSentAt() 
    {
        return sentAt;
    }
    public void setIsRead(String isRead) 
    {
        this.isRead = isRead;
    }

    public String getIsRead() 
    {
        return isRead;
    }
    public void setMessageId(Long messageId) 
    {
        this.messageId = messageId;
    }

    public Long getMessageId() 
    {
        return messageId;
    }
    public void setSessionIdLong(Long sessionIdLong) 
    {
        this.sessionIdLong = sessionIdLong;
    }

    public Long getSessionIdLong() 
    {
        return sessionIdLong;
    }
    public void setMessageContent(String messageContent) 
    {
        this.messageContent = messageContent;
    }

    public String getMessageContent() 
    {
        return messageContent != null ? messageContent : content;
    }
    public void setSenderType(String senderType) 
    {
        this.senderType = senderType;
    }

    public String getSenderType() 
    {
        return senderType;
    }

    // 兼容性方法：支持Long类型的sessionId
    public void setSessionId(Long sessionId) 
    {
        this.sessionIdLong = sessionId;
        this.sessionId = sessionId != null ? sessionId.toString() : null;
    }

    // 兼容性方法：同时设置content和messageContent
    public void setMessage(String message) 
    {
        this.content = message;
        this.messageContent = message;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("messageId", getMessageId())
            .append("userId", getUserId())
            .append("sessionId", getSessionId())
            .append("sessionIdLong", getSessionIdLong())
            .append("messageType", getMessageType())
            .append("content", getContent())
            .append("messageContent", getMessageContent())
            .append("isLink", getIsLink())
            .append("isButton", getIsButton())
            .append("senderId", getSenderId())
            .append("receiverId", getReceiverId())
            .append("sentAt", getSentAt())
            .append("isRead", getIsRead())
            .append("senderType", getSenderType())
            .append("createTime", getCreateTime())
            .append("updateTime", getUpdateTime())
            .toString();
    }
}