Helius
2020-06-03 def723a6fa9cbe05734afe9011a6f90d2fa32196
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
69
70
71
package com.xcong.excoin.common.response;
 
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
 
import java.io.Serializable;
 
/**
 * @author wzy
 * @date 2020-04-29 11:27
 **/
@Data
@ApiModel(value = "返回基类", description = "基础返回类")
public class Result implements Serializable {
 
    private static final long serialVersionUID = 1L;
 
    private static final int SUCCESS = 0;
 
    private static final String SUCCESS_MSG = "success";
 
    private static final int FAIL = -1;
 
    private static final int LOGIN_FAIL = -2;
 
    @ApiModelProperty(value = "状态码", example = "0")
    private int code;
 
    @ApiModelProperty(value = "提示消息")
    private String msg;
 
    @ApiModelProperty(value = "数据对象")
    private Object data;
 
    public static Result ok(String msg) {
        Result result = new Result();
        result.code = SUCCESS;
        result.msg = msg;
        return result;
    }
 
    public static Result ok(String msg, Object data) {
        Result result = new Result();
        result.code = SUCCESS;
        result.msg = msg;
        result.data = data;
        return result;
    }
    public static Result ok(Object data) {
        Result result = new Result();
        result.code = SUCCESS;
        result.msg = SUCCESS_MSG;
        result.data = data;
        return result;
    }
 
    public static Result fail(String msg) {
        Result result = new Result();
        result.code = FAIL;
        result.msg = msg;
        return result;
    }
 
    public static Result loginFail(String msg) {
        Result result = new Result();
        result.code = LOGIN_FAIL;
        result.msg = msg;
        return result;
    }
}