All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.memfactory.utils.ResponseVoUtil Maven / Gradle / Ivy

There is a newer version: 0.0.25
Show newest version
/**
 * 
 */
package com.memfactory.utils;

import com.memfactory.pub.commom.ResponseVo;
import com.memfactory.pub.constant.OperationEnum;

/**
 * ResponseV工具类
 * 
 * @author zhairp
 * @since 0.0.1
 * createDate: 2018年8月30日
 */
public final class ResponseVoUtil {
	private ResponseVoUtil() {
	}

	/**
	 * 统一生产ResponseVo实例
	 * 
	 * @param result 结果数据
	 * @return ResponseVo实例
	 */
	public static ResponseVo getResponse(Object result) {
		ResponseVo responseVo = new ResponseVo();
		responseVo.setSuccess(true);
		responseVo.setMsg(OperationEnum.SUCCESS.getMsg());
		responseVo.setStatus(OperationEnum.SUCCESS.getCode());
		responseVo.setResult(result);
		return responseVo;
	}

	/**
	 * 统一生产ResponseVo实例
	 * 
	 * @param success   操作是否成功
	 * @param operation 操作提示信息
	 * @return ResponseVo实例
	 */
	public static ResponseVo getResponse(boolean success, OperationEnum operation) {
		ResponseVo responseVo = new ResponseVo();
		responseVo.setSuccess(success);
		responseVo.setMsg(operation.getMsg());
		responseVo.setStatus(operation.getCode());
		return responseVo;
	}

    /*
     * 生产默认ResponseVo实例
     */
	public static ResponseVo getDefaultResponse() {
		ResponseVo responseVo = new ResponseVo();
		responseVo.setSuccess(true);
		responseVo.setMsg(OperationEnum.SUCCESS.getMsg());
		responseVo.setStatus(OperationEnum.SUCCESS.getCode());
		return responseVo;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy