package com.xhpc.pp.tx;

import java.util.HashMap;
import java.util.Map;

public class ServiceResult {

    public static final String OK = "0";
    public static final String FAIL = "1";
    public static final String HEX_00 = "00";
    public static final String HEX_01 = "01";

    private String code;
    private byte[] binary;
    private Object json;
    private String msg;

    public ServiceResult(String code) {
        this.code = code;
    }

    public ServiceResult(String code, String body) {

        Map<String, String> map = new HashMap<>();
        String messageCode = "0101";
        if (code != null && code.trim().length() > 0) {
            messageCode = code;
        }
        map.put("ErrCode", messageCode);
        map.put("ErrMsg", body);
        this.json = map;
    }

    public ServiceResult(Map<String, String> json) {

        this.json = json;
    }

    public ServiceResult(Object json) {

        this.json = json;
    }

    public ServiceResult(byte[] binary) {

        this.binary = binary;
        this.code = OK;
    }

    public ServiceResult(byte[] binary, String code, String msg) {

        this.binary = binary;
        this.code = code;
        this.msg = msg;
    }

    public ServiceResult(byte[] binary, String code) {

        this.binary = binary;
        this.code = code;
    }

    public ServiceResult(byte[] binary, String code, Object json) {

        this.binary = binary;
        this.code = code;
        this.json = json;
    }

    public String getCode() {

        return code;
    }

    public void setCode(String code) {

        this.code = code;
    }

    public byte[] getBinary() {

        return binary;
    }

    public void setBinary(byte[] binary) {

        this.binary = binary;
    }

    public Object getJson() {

        return json;
    }

    public void setJson(Object json) {

        this.json = json;
    }

    public String getMsg() {

        return msg;
    }

    public void setMsg(String msg) {

        this.msg = msg;
    }

}
