doum
8 小时以前 f2b6fdd955f8ac6e5b351e0b5e3a9f583ed6da2e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.doumee.config.xyy.vo;
 
import lombok.Data;
 
/**
 * 返回公共参数
 *
 * @param <T>
 * @author RabyGao
 * @date Aug 7, 2019
 */
@Data
public class ObjectRestResponse<T> {
 
    public static final String REST_RESPONSE_OK = "ok";
 
    /**
     * 返回码,正确返回0,【注意:结果正确与否的判断请用此返回参数】,错误返回非零
     */
    private int code;
    /**
     * 结果提示信息,正确返回”ok”,如果有错误,返回错误信息
     */
    private String msg;
    /**
     * 数据类型和内容详看私有返回参数data,如果有错误,返回null
     */
    private T data;
    /**
     * 服务器程序执行时间,单位:毫秒
     */
    private long serverExecutedTime;
 
    public ObjectRestResponse() {
        this.setCode(0);
        this.setMsg(REST_RESPONSE_OK);
    }
 
    public ObjectRestResponse code(int code) {
        this.setCode(code);
        return this;
    }
 
    public ObjectRestResponse data(T data) {
        this.setData(data);
        return this;
    }
 
    public ObjectRestResponse msg(String msg) {
        this.setMsg(msg);
        return this;
    }
 
    public ObjectRestResponse setResult(int code, T data) {
        this.setCode(code);
        this.setData(data);
        return this;
    }
 
    public ObjectRestResponse setResult(int code, T data, String msg) {
        this.setCode(code);
        this.setData(data);
        this.setMsg(msg);
        return this;
    }
 
 
}