package com.ifish.util;

import java.util.List;

import com.ifish.dto.JsonResult;
import com.ifish.dto.PageingDto;
import com.ifish.enums.ResultEnum;

/**
 * 结果工具类
 * @author Administrator
 *
 */
public class ResultUtil {
	
	/**
	 * 错误
	 * @param result
	 * @return
	 */
	public static JsonResult<?> error(String result){
		JsonResult<String> jsonResult = new JsonResult<String>(result);
		return jsonResult;
	}
	/**
	 * 警告
	 * @param result
	 * @param object
	 * @return
	 */
	public static JsonResult<?> warn(String result,Object object){
		JsonResult<Object> jsonResult = new JsonResult<Object>(result,object);
		return jsonResult;
	}
	/**
	 * 成功,有数据
	 * @param object
	 * @return
	 */
	public static JsonResult<?> success(Object object){
		JsonResult<Object> jsonResult = new JsonResult<Object>(ResultEnum.success.getKey(),object);
		return jsonResult;
	}
	
	/**
	 * 成功,无数据
	 * @param object
	 * @return
	 */
	public static JsonResult<?> success(){
		JsonResult<String> jsonResult = new JsonResult<String>(ResultEnum.success.getKey());
		return jsonResult;
	}
	
	/**
	 * 成功，返回分页数据
	 * @param firstResult
	 * @param totalCount
	 * @param list
	 * @return
	 */
	public static <T> PageingDto<T> success(Integer firstResult,Integer totalCount,List<T> list){
		return new PageingDto<T>(ResultEnum.success.getKey(), firstResult, totalCount, list);
	}
	
}
