package com.zt.plat.module.qms.iot.tcpserver.core;

import com.alibaba.fastjson.JSONObject;

import java.io.Serializable;

/**
 * <b>ReplyResult</b>
 * 回复结果
 * <p>更新历史：</p>
 * <pre> 版本         更新时间            更新者        更新内容
 * V1.0      2021-7-1          王兴荣         Add</pre>
 * <b>Copyright (C)  云南志者竟成科技有限公司</b> 
 * @author 王兴荣 &lt;xingrong_wang@will-way.cn&gt;
 * @version V1.0 
 * @since 2021-7-1
 */
public class ReplyResult implements Serializable {

    private static final long serialVersionUID = 502081586271036395L;
    
    /** 计量点id **/
    private String measurePointId;
    
    /** 是否成功 **/
    private Boolean success;
    
    /** 消息 **/
    private String msg;

    private ReplyResult() {
    }

    private ReplyResult(Boolean success, String msg) {
        this.success = success;
        this.msg = msg;
    }

    /**
     * 成功
     * @param msgId 消息id
     * @param clientType 客户端类型
     * @param cmd 命令
     * @return
     */
    public static String success(String msgId, String clientType, String cmd) {
        JSONObject object = new JSONObject();
        object.put("msgId", msgId);
        object.put("clientType", clientType);
        object.put("cmd", cmd);
        object.put("data", new ReplyResult(true, null));
        return object.toJSONString();
    }
    
    /**
     * 成功
     * @param msgId 消息id
     * @param clientType 客户端类型
     * @param cmd 命令
     * @param msg 消息
     * @return
     */
    public static String success(String msgId, String clientType, String cmd, String msg) {
        JSONObject object = new JSONObject();
        object.put("msgId", msgId);
        object.put("clientType", clientType);
        object.put("cmd", cmd);
        object.put("data", new ReplyResult(true, msg));
        return object.toJSONString();
    }

    /**
     * 失败
     * @param msgId 消息id
     * @param clientType 客户端类型
     * @param cmd 命令
     * @param msg 消息
     */
    public static String fail(String msgId, String clientType, String cmd, String msg) {
        JSONObject object = new JSONObject();
        object.put("msgId", msgId);
        object.put("clientType", clientType);
        object.put("cmd", cmd);
        object.put("data", new ReplyResult(false, msg));
        return object.toJSONString();
    }

    public String getMeasurePointId() {
        return measurePointId;
    }

    public void setMeasurePointId(String measurePointId) {
        this.measurePointId = measurePointId;
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
    
    
}
