package com.dcit.common.utils;

import com.dcit.common.enums.ResultEnum;
import com.dcit.common.vo.ResultVO;

/**
* <p>Title: ResultVOUtil</p>
* <p>Description: 返回结果工具类</p>
* <p>Company: SJZ DC-IT co. LTD</p> 
* @author ZZZ
* @date 2018年8月28日 上午11:30:44
 */
public class ResultVOUtil {
	
	public static ResultVO success(Object object){
		ResultVO resultVO = new ResultVO();
		resultVO.setCode(ResultEnum.SUCCESS.getCode());
		resultVO.setMsg(ResultEnum.SUCCESS.getMessage());
		resultVO.setData(object);
		return resultVO;
	}
	
	public static ResultVO success(){
		return success(null);
	}
	
	public static ResultVO error(ResultEnum resultEnum, String msg){
		ResultVO resultVO = new ResultVO();
		resultVO.setCode(resultEnum.getCode());
		resultVO.setMsg(msg);
		return resultVO;
	}
	
	public static ResultVO error(int code, String msg){
		ResultVO resultVO = new ResultVO();
		resultVO.setCode(code);
		resultVO.setMsg(msg);
		return resultVO;
	}
	
	public static ResultVO error(ResultEnum resultEnum){
		ResultVO resultVO = new ResultVO();
		resultVO.setCode(resultEnum.getCode());
		resultVO.setMsg(resultEnum.getMessage());
		return resultVO;
	}
	
	public static ResultVO error(int code, String msg, Object object){
		ResultVO resultVO = new ResultVO();
		resultVO.setCode(code);
		resultVO.setMsg(msg);
		resultVO.setData(object);
		return resultVO;
	}

}
