2
sunshine
2024-11-05 d1f9fb55a136e589a5ad588ed9a93ce9272917da
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
72
73
74
package com.nova.sankuai.domain.api.yangqianguan;
 
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
 
/**
 * @Description: 洋钱罐响应类
 * @Author: Very
 * @Date: 2022/4/24 19:58
 */
@Data
public class MoneyPotResultJson<T> {
 
    private static final long serialVersionUID = 783015033603078674L;
 
    @ApiModelProperty(value = "返回代码")
    private int code;
 
    @ApiModelProperty(value = "返回处理消息")
    private String message;
 
    @ApiModelProperty(value = "返回数据对象")
    private T data;
 
    /**
     * 成功
     *
     * @param <T>
     * @return
     */
    public static <T> MoneyPotResultJson<T> success() {
        MoneyPotResultJson<T> moneyPotResultJson = new MoneyPotResultJson<>();
        moneyPotResultJson.setCode(0);
        moneyPotResultJson.setMessage("ok");
        return moneyPotResultJson;
    }
 
    /**
     * 成功
     *
     * @param <T>
     * @return
     */
    public static <T> MoneyPotResultJson<T> success(T data) {
        MoneyPotResultJson<T> moneyPotResultJson = new MoneyPotResultJson<>();
        moneyPotResultJson.setCode(0);
        moneyPotResultJson.setMessage("OK");
        moneyPotResultJson.setData(data);
        return moneyPotResultJson;
    }
 
    /**
     * 失败
     *
     * @param <T>
     * @return
     */
    public static <T> MoneyPotResultJson<T> error(int code, String msg) {
        MoneyPotResultJson<T> moneyPotResultJson = new MoneyPotResultJson<>();
        moneyPotResultJson.setCode(code);
        moneyPotResultJson.setMessage(msg);
        return moneyPotResultJson;
    }
 
    @Override
    public String toString() {
        return "{" +
                "\"code\":" + code +
                ", \"msg\":\"" + message + '\"' +
                ", \"data\":\"" + data + '\"' +
                '}';
    }
 
}