ResultVo.java
1.19 KB
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
package com.viontech.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
/**
* Created with IntelliJ IDEA.
*
* @author: zhuhai
* Date: 2023-04-04
* Time: 16:08
*/
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ResultVo<T> {
private String code;
private String message;
private T data;
public static ResultVo<Void> success() {
return success("success", null);
}
public static <T> ResultVo<T> success(T data) {
return success("success", data);
}
public static <T> ResultVo<T> success(String message, T data) {
ResultVo<T> resultVo = new ResultVo<>();
resultVo.setCode("200");
resultVo.setMessage(message);
resultVo.setData(data);
return resultVo;
}
public static ResultVo<Void> error() {
return error("System error!");
}
public static ResultVo<Void> error(String code, String message) {
ResultVo<Void> resultVo = new ResultVo<>();
resultVo.setCode(code);
resultVo.setMessage(message);
return resultVo;
}
public static ResultVo<Void> error(String message) {
return error("500", message);
}
}