AsyncMessage.java 958 Bytes
package com.diligrp.assistant.shared.domain;

import com.diligrp.assistant.shared.util.JsonUtils;

/**
 * MQ异步消息模型
 */
public class AsyncMessage {
    // 消息类型
    private Integer type;
    // 消息体
    private String payload;
    // 消息参数
    private String params;

    public static AsyncMessage of(Integer type, String payload, String params) {
        AsyncMessage message = new AsyncMessage();
        message.type = type;
        message.payload = payload;
        message.params = params;
        return message;
    }

    public static AsyncMessage from(String message) {
        return JsonUtils.fromJsonString(message, AsyncMessage.class);
    }

    public Integer getType() {
        return type;
    }

    public String getPayload() {
        return payload;
    }

    public String getParams() {
        return params;
    }

    public String toString() {
        return JsonUtils.toJsonString(this);
    }
}