package com.ruoyi.web.controller.customer.dto;

import java.util.List;

/**
 * 转人工服务请求DTO
 * 
 * @author ruoyi
 */
public class TransferToManualRequest
{
    /** 用户ID */
    private String userId;
    
    /** 转人工原因 */
    private Object reason;
    
    public TransferToManualRequest()
    {
    }
    
    public TransferToManualRequest(String userId, Object reason)
    {
        this.userId = userId;
        this.reason = reason;
    }
    
    public String getUserId()
    {
        return userId;
    }
    
    public void setUserId(String userId)
    {
        this.userId = userId;
    }
    
    public Object getReason()
    {
        return reason;
    }
    
    public void setReason(Object reason)
    {
        this.reason = reason;
    }
    
    /**
     * 获取转换后的用户ID（Long类型）
     */
    public Long getUserIdAsLong()
    {
        if (userId == null || userId.trim().isEmpty())
        {
            return null;
        }
        try
        {
            return Long.parseLong(userId.trim());
        }
        catch (NumberFormatException e)
        {
            return null;
        }
    }
    
    /**
     * 获取转换后的原因（String类型）
     */
    public String getReasonAsString()
    {
        if (reason == null)
        {
            return null;
        }
        
        if (reason instanceof String)
        {
            return (String) reason;
        }
        else if (reason instanceof List)
        {
            // 如果是消息列表，转换为字符串描述
            List<?> messageList = (List<?>) reason;
            return "用户最近" + messageList.size() + "条消息记录";
        }
        else
        {
            return reason.toString();
        }
    }
    
    @Override
    public String toString()
    {
        return "TransferToManualRequest{" +
                "userId='" + userId + '\'' +
                ", reason=" + reason +
                '}';
    }
}