ResultUtil.java
1 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
package vion.utils;
import vion.enums.ResultEnum;
import vion.vo.ResultVO;
public class ResultUtil {
public static ResultVO<Object> success(Object o) {
ResultVO<Object> resultVO = new ResultVO<Object>();
resultVO.setCode(ResultEnum.SUCCESS.getCode());
resultVO.setMsg(ResultEnum.SUCCESS.getMessage());
resultVO.setData(o);
return resultVO;
}
public static ResultVO<Object> error(ResultEnum e) {
ResultVO<Object> resultVO = new ResultVO<Object>();
resultVO.setCode(e.getCode());
resultVO.setMsg(e.getMessage());
return resultVO;
}
public static ResultVO<Object> error(Object o) {
ResultVO<Object> resultVO = new ResultVO<Object>();
resultVO.setCode(500);
resultVO.setMsg("error");
resultVO.setData(o);
return resultVO;
}
public static ResultVO<Object> success() {
return success(null);
}
public static ResultVO<Object> error() {
return error(null);
}
}