패 키 징 인터페이스 통합 반환 데이터 구조

9038 단어
package cn.toroot.bj.utils;

/**
 * Created on 2020-6-10 16:52:10
 * Mr peng
 */

import cn.toroot.bj.core.constant.ResponseCodeConstant;

import java.io.Serializable;


public class HttpResponseBody<E> implements Serializable {

    /**
     * Comment for serialVersionUID
     */
    private static final long serialVersionUID = -5406928126690333502L;

    private String code;

    private String msg;

    private E data;

    public HttpResponseBody(){
    }

    public HttpResponseBody(String code, String msg, E data){
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public HttpResponseBody(String code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

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

    public E getData() {
        return data;
    }

    public void setData(E data) {
        this.data = data;
    }


    public static HttpResponseBody successResponse(String message) {
        return new HttpResponseBody(ResponseCodeConstant.SUCCESS, message);
    }

    public static <T> HttpResponseBody<T> successResponse(String message,T singleData) {
        return new HttpResponseBody<T>(ResponseCodeConstant.SUCCESS, message,singleData);
    }

    public static HttpResponseBody failResponse(String message) {
        return new HttpResponseBody(ResponseCodeConstant.FAIL, message);
    }

}



좋은 웹페이지 즐겨찾기