package com.ihooyah.common.msg;

/**
 * 描述
 *
 * @author fatiaojie
 * @date 2020/4/1 9:44
 */
public class ObjectRespInfo <T> extends BaseRespInfo {

    T result;
    String endpoint ="";

    public ObjectRespInfo(){

    }

    public ObjectRespInfo(T result,String endpoint){
        this.setResult(result);
        this.setEndpoint(endpoint);
    }

    public ObjectRespInfo(Integer code, String msg) {
        this.setCode(code);
        this.setMsg(msg);
        this.result = result;
    }

    public ObjectRespInfo(Integer code, String msg, T result){
        this.setCode(code);
        this.setMsg(msg);
        this.result = result;
    }

    public static ObjectRespInfo out(RespEnum respEnum) {
//        this.setCode(respEnum.getCode());
//        this.setMsg(respEnum.getMsg());
//        return this;
        return new ObjectRespInfo(respEnum.getCode(), respEnum.getMsg());
    }

    public static ObjectRespInfo out(RespEnum respEnum, Object object) {
        ObjectRespInfo respInfo = new ObjectRespInfo(respEnum.getCode(), respEnum.getMsg(), object);
        respInfo.setEndpoint("web");
        return respInfo;
    }

    public static ObjectRespInfo mobiSuccess(RespEnum respEnum, Object object) {
        ObjectRespInfo respInfo = new ObjectRespInfo(respEnum.getCode(), respEnum.getMsg(), object);
        respInfo.setEndpoint("mobi");
        return respInfo;
    }

    public static ObjectRespInfo mobiSuccess() {
        ObjectRespInfo respInfo = new ObjectRespInfo(RespEnum.SUCCESS.getCode(), "", "");
        respInfo.setEndpoint("mobi");
        return respInfo;
    }

    public static ObjectRespInfo mobiSuccess(Object obj) {
        ObjectRespInfo respInfo = new ObjectRespInfo(RespEnum.SUCCESS.getCode(), "", obj);
        respInfo.setEndpoint("mobi");
        return respInfo;
    }

    public static ObjectRespInfo mobiSuccess(String msg, Object obj) {
        ObjectRespInfo respInfo = new ObjectRespInfo(RespEnum.SUCCESS.getCode(), msg, obj);
        respInfo.setEndpoint("mobi");
        return respInfo;
    }

    public static ObjectRespInfo mobiSuccess(String msg) {
        ObjectRespInfo respInfo = new ObjectRespInfo(RespEnum.SUCCESS.getCode(), msg);
        respInfo.setEndpoint("mobi");
        return respInfo;
    }

    public static ObjectRespInfo mobiError() {
        ObjectRespInfo respInfo = new ObjectRespInfo(RespEnum.ERROR.getCode(), RespEnum.ERROR.getMsg());
        respInfo.setEndpoint("mobi");
        return respInfo;
    }

    public static ObjectRespInfo mobiError(String msg) {
        ObjectRespInfo respInfo = new ObjectRespInfo(RespEnum.ERROR.getCode(), msg);
        respInfo.setEndpoint("mobi");
        return respInfo;
    }

    public static ObjectRespInfo mobiError(String msg, Object object) {
        ObjectRespInfo respInfo = new ObjectRespInfo(RespEnum.ERROR.getCode(), msg, object);
        respInfo.setEndpoint("mobi");
        return respInfo;
    }

    public static ObjectRespInfo mobiError(RespEnum respEnum, String errorMsg) {
        ObjectRespInfo respInfo = null;
        respInfo = new ObjectRespInfo(respEnum.getCode(), errorMsg, "");
        respInfo.setEndpoint("mobi");
        return respInfo;
    }

    public static ObjectRespInfo mobiError(RespEnum respEnum) {
        ObjectRespInfo respInfo = new ObjectRespInfo(respEnum.getCode(), respEnum.getMsg(), "");
        respInfo.setEndpoint("mobi");
        return respInfo;
    }





    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public String getEndpoint() {
        return endpoint;
    }

    public void setEndpoint(String endpoint) {
        this.endpoint = endpoint;
    }
}
