package com.jianshui.invoice.domain.dto;

import com.alibaba.fastjson.JSONObject;
import com.jianshui.common.utils.StringUtils;
import lombok.Data;

/**
 * @Description 航信济南的返回报文
 * @Author 巩权林
 * @Date 2022/3/26 23:00
 **/
@Data
public class HXResponse extends JSONObject {

    public HXResponse(String status, String message) {
        this.status = status;
        this.message = message;
        this.put("status", this.status);
        this.put("message", this.message);
    }

    public HXResponse(String message, Object data) {
        this.message = message;
        this.data = data;
        this.put("message", this.message);
        this.put("data", this.data);
    }




    public HXResponse(String message) {
        this.status = "9999";
        this.message = message;
        this.put("status", this.status);
        this.put("message", this.message);
    }

    public HXResponse(String status, String message, Object data) {
        this.status = status;
        this.message = message;
        this.data = data;
        this.put("status", this.status);
        this.put("message", this.message);
        this.put("data", this.data);
    }

    //传输布尔符的就返回标准的接口，true有data，false无data
    public HXResponse( String code,String msg,Object data,boolean isCode) {
        if(isCode){
            this.message = msg;
            this.data = data;
            this.code = code;
            this.put("msg", this.message);
            this.put("code", this.code);
            this.put("data", this.data);
        }else{
            this.message = msg;
            this.code = code;
            this.put("msg", this.message);
            this.put("code", this.code);
        }
    }

    public HXResponse( String status,String message,Object data,boolean isCode,String a) {
        if(isCode){
            this.message = message;
            this.data = data;
            this.code = status;
            this.put("message", this.message);
            this.put("status", this.code);
            this.put("data", this.data);
        }else{
            this.message = message;
            this.code = status;
            this.put("message", this.message);
            this.put("status", this.code);
        }
    }

    public boolean isSuccess() {
        return StringUtils.equals(this.status, "0000");
    }

    private String status;
    private String message;
    private Object data;
    private String code;
}
