org.iartisan.runtime.api.utils.ApiResUtil Maven / Gradle / Ivy
package org.iartisan.runtime.api.utils;
import org.iartisan.runtime.api.base.BaseRes;
import org.iartisan.runtime.api.code.ResCodeEnum;
import org.iartisan.runtime.api.res.BaseCheckRes;
import org.iartisan.runtime.api.res.BaseListRes;
import org.iartisan.runtime.api.res.BaseOneRes;
import org.iartisan.runtime.api.res.BasePageRes;
import org.iartisan.runtime.bean.PageWrapper;
import org.iartisan.runtime.exception.BizRemoteException;
import java.util.List;
/**
*
* res util
*
* @author King
* @since 2018/1/23
*/
public class ApiResUtil {
public static void getResult(BaseRes t) throws BizRemoteException {
if (!t.getCode().equals(ResCodeEnum.succcess.getCode())) {
throw new BizRemoteException(t);
}
}
public static boolean check(BaseCheckRes t) throws BizRemoteException {
if (!t.getCode().equals(ResCodeEnum.succcess.getCode())) {
throw new BizRemoteException(t);
}
return t.isResult();
}
public static T getBean(BaseOneRes t) throws BizRemoteException {
if (t.getCode().equals(ResCodeEnum.succcess.getCode())) {
return t.getDataObject();
} else {
throw new BizRemoteException(t);
}
}
public static List getDataList(BaseListRes t) throws BizRemoteException {
if (t.getCode().equals(ResCodeEnum.succcess.getCode())) {
return t.getDataList();
} else {
throw new BizRemoteException(t);
}
}
public static PageWrapper getDataPage(BasePageRes t) throws BizRemoteException {
if (t.getCode().equals(ResCodeEnum.succcess.getCode())) {
return t.getDataPage();
} else {
throw new BizRemoteException(t);
}
}
}