Result.java 1.9 KB
Newer Older
1
package cn.wisenergy.common.utils;
m1991's avatar
m1991 committed
2 3


4 5 6
import cn.wisenergy.common.enums.ResultEnum;
import org.springframework.stereotype.Component;

m1991's avatar
m1991 committed
7
import java.io.Serializable;
8
import java.util.Map;
m1991's avatar
m1991 committed
9 10 11 12 13

/**
 * 返回信息包装类
 * Created by m1991 on 2021/2/28 23:08
 */
14
@Component
15
public class Result<T> implements Serializable {
m1991's avatar
m1991 committed
16 17 18 19 20 21
    public String code;

    public String msg;

    private T data;

22 23
    private T wyz;

m1991's avatar
m1991 committed
24 25 26 27
    /**
     * 无参构造
     */
    public Result() {}
m1991's avatar
m1991 committed
28 29
    /**
     * 无参构造
30 31 32
     * @param i
     * @param success
     * @param shopZxPage
m1991's avatar
m1991 committed
33
     */
34
    public Result(int i, String success, Page shopZxPage) {}
m1991's avatar
m1991 committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

    /**
     * 根据code,msg创建一个Resutl
     * @param code
     * @param msg
     */
    public Result(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 根据code,msg,data创建一个Resutl
     * @param code
     * @param msg
     * @param data
     */
    public Result(String code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
    public T getWyz() {
        return wyz;
    }

    public void setWyz(T wyz) {
        this.wyz = wyz;
    }

    public Result(String code, String msg, T data, T wyz) {
        this.code = code;
        this.msg = msg;
        this.data = data;
        this.wyz = wyz;
    }

m1991's avatar
m1991 committed
73 74 75 76 77 78 79 80 81
    /**
     * 根据枚举创建一个Result
     * @param resultEnum
     */
    public Result(ResultEnum resultEnum) {
        this.code = resultEnum.getCode();
        this.msg = resultEnum.getMsg();
    }

82 83 84
    public String getCode() {
        return code;
    }
m1991's avatar
m1991 committed
85 86 87 88 89 90 91 92 93 94 95 96 97

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

    public String getMsg() {
        return msg;
    }

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

98 99 100
    public T getData() {
        return data;
    }
m1991's avatar
m1991 committed
101

102 103 104
    public void setData(T data) {
        this.data = data;
    }
m1991's avatar
m1991 committed
105 106 107


}