package cn.axzo.msg.center.message.domain.dto;

import cn.axzo.im.center.api.vo.resp.MessageDispatchResp;
import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;

/**
 * @author cold_blade
 * @date 2023/10/25
 * @version 1.0
 */
@Setter
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SendImMessageDTO implements Serializable {

    private static final long serialVersionUID = 3385679937092148803L;

    /**
     * 自然人id
     */
    private Long personId;
    /**
     * im消息id
     */
    private String imMsgId;

    public static SendImMessageDTO from(MessageDispatchResp resp) {
        return SendImMessageDTO.builder()
                .imMsgId(resp.getMsgid())
                .personId(Long.parseLong(resp.getPersonId()))
                .build();
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
