package com.changhong.autoform.entity.system;
|
|
import com.changhong.autoform.constant.system.ErrCode;
|
|
/**
|
* API接口返回格式类
|
* @author yangrx
|
*
|
*/
|
public class RestResultGenerator implements ErrCode{
|
|
/**
|
* normal
|
* @param rspCode
|
* @param data
|
* @param message
|
* @param <T>
|
* @return
|
*/
|
private static <T> RestResult<T> genResult(String rspCode, T data) {
|
RestResult<T> result = RestResult.newInstance();
|
result.setRspCode(rspCode);
|
result.setData(data);
|
return result;
|
}
|
|
/**
|
* success
|
*
|
* @param data
|
* @param <T>
|
* @return
|
*/
|
public static <T> RestResult<T> ok(T data) {
|
return genResult(SUCCESS, data);
|
}
|
|
/**
|
* success
|
* @param data
|
* @param <T>
|
* @return
|
*/
|
public static <T> RestResult<T> err(String code, T data) {
|
return genResult(code, data);
|
}
|
|
}
|