|  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
 | /**
 * @author fangyaxing
 * @date 2023/3/24
 */
@Data
@AllArgsConstructor
public class ResultVO<T> {
    private String code;
    private String msg;
    private T data;
    public ResultVO(ErrorEnum errorEnum, T data) {
        this.code = errorEnum.getCode();
        this.msg = errorEnum.getMessage();
        this.data = data;
    }
    public static <T> ResultVO<T> success(T data) {
        return new ResultVO<>(ErrorEnum.SUCCESS, data);
    }
    public static <T> ResultVO<T> error(String code, String msg, T data) {
        return new ResultVO<>(code, msg, data);
    }
    public static <T> ResultVO<T> error(String code, String msg) {
        return error(code, msg, null);
    }
    public static <T> ResultVO<T> error(ErrorEnum errorEnum, T data) {
        return new ResultVO<>(errorEnum.getCode(), errorEnum.getMessage(), data);
    }
    public static <T> ResultVO<T> error(ErrorEnum errorEnum) {
        return error(errorEnum, null);
    }
    public static <T> ResultVO<T> error(BizException bizException) {
        return error(bizException.getCode(), bizException.getMessage(), null);
    }
    public static <T> ResultVO<T> error(SysException sysException) {
        return error(sysException.getCode(), sysException.getMessage(), null);
    }
}
 |