统一接口返回类

2018-06-11  本文已影响7人  Iwantyoutokonw

import lombok.Getter;

import lombok.Setter;

import org.apache.poi.ss.formula.functions.T;

@Setter

@Getter

public class Result {

/**

* 是否成功

*/

    private boolean success;

    /**0 :success 1 :fail

* 结果信息编号,对应字典

*/

    private StringresultCode;

    /**

* 返回的消息

*/

    private StringresultMsg;

    /**

* 返回数据

*/

    private  TdataInfo;

    public Result() {

}

public Result(boolean success, String resultCode, String resultMsg, T dataInfo) {

this.success = success;

        this.resultCode = resultCode;

        this.resultMsg = resultMsg;

        this.dataInfo = dataInfo;

    }

/**

* 统一返回格式

    * @param success

    * @param resultCode

    * @param resultMsg

    * @param dataInfo

    * @return

    */

    public static ResultgetResultInfo(boolean success, String resultCode, String resultMsg, T dataInfo){

        Result result =new Result();

        result.setSuccess(success);

        result.setResultCode(resultCode);

        result.setResultMsg(resultMsg);

        result.setDataInfo(dataInfo);

        return result;

    }

}

上一篇下一篇

猜你喜欢

热点阅读