package com.fs.live.util;

import com.alibaba.fastjson.JSONObject;
import com.fs.common.core.domain.R;

import java.util.LinkedHashMap;
import java.util.Map;

/** 构造与 fs-live-app SendMsgVo 结构一致的 WebSocket 外层 JSON */
public final class LiveCommentWsMessageBuilder {

    private LiveCommentWsMessageBuilder() {}

    public static String build(Long liveId, String cmd, Object dataObject) {
        Map<String, Object> vo = new LinkedHashMap<>();
        vo.put("liveId", liveId);
        vo.put("cmd", cmd);
        vo.put("data", dataObject instanceof String ? dataObject : JSONObject.toJSONString(dataObject));
        vo.put("on", true);
        return JSONObject.toJSONString(R.ok().put("data", vo));
    }
}
