com.dingtalk.baymax.framework.sdk.mercury.util.ServiceResultUtils Maven / Gradle / Ivy
package com.dingtalk.baymax.framework.sdk.mercury.util;
import java.util.Map;
import java.util.Objects;
/**
* @Author xiaoyan
* @Date 2023-07-21 20:56:33
*/
public class ServiceResultUtils {
public static boolean isSuccess(Object serviceResult) {
if (Objects.isNull(serviceResult)) {
return false;
}
if (!Map.class.isAssignableFrom(serviceResult.getClass())) {
return false;
}
Map map = Map.class.cast(serviceResult);
Object success = map.get("success");
if (Objects.isNull(success)) {
return false;
}
return Boolean.parseBoolean(success.toString());
}
public static Object getResult(Object serviceResult) {
if (Objects.isNull(serviceResult)) {
return null;
}
Map map = Map.class.cast(serviceResult);
return map.get("result");
}
public static Object getErrorCode(Object serviceResult) {
if (Objects.isNull(serviceResult)) {
return null;
}
Map map = Map.class.cast(serviceResult);
return map.get("errorCode");
}
public static Object getErrorMsg(Object serviceResult) {
if (Objects.isNull(serviceResult)) {
return null;
}
Map map = Map.class.cast(serviceResult);
return map.get("errorMsg");
}
}