ResultUtil.java 1 KB
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);
    }
}