package thyyxxk.webserver.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import thyyxxk.webserver.constants.Message;

import java.util.Map;


/**
 * 发送系统消息
 *
 * @author 肖蟾
 */
public class SocketMsg {

    public static String socketVo(Message messageName, JSONObject map) {
        JSONObject msg = new JSONObject();
        msg.put("name", messageName.getName());
        msg.put("code", messageName.getName());
        msg.put("message", map);
        return msg.toJSONString();
    }

    public static String socketVo(Message messageName, Map<String, Object> map) {
        JSONObject msg = new JSONObject();
        msg.put("name", messageName.getName());
        msg.put("code", messageName.getName());
        msg.put("message", map);
        return JSON.toJSONStringWithDateFormat(msg, DateUtil.DEFAULT_PATTERN);
    }


    public static String socketVo(Message messageName, String data) {
        JSONObject msg = new JSONObject();
        msg.put("name", messageName.getName());
        msg.put("code", messageName.getName());
        msg.put("message", data);
        return msg.toJSONString();
    }

}
