SearchApiResultUtils.java
1.23 KB
package com.yoho.search.common.utils;
import com.yoho.search.base.utils.JsonUtil;
import com.yoho.search.models.SearchApiResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
public class SearchApiResultUtils {
private static final Logger logger = LoggerFactory.getLogger(SearchApiResultUtils.class);
public static SearchApiResult errorSearchApiResult(final String funName, final Map<String, ?> paramMap, final Exception e) {
logger.error("[※查询]失败:[func={}][param={}][message={}][stack={}]", funName, JsonUtil.toJson(paramMap), e.getMessage(), e);
SearchApiResult searchApiResult = new SearchApiResult();
searchApiResult.setCode(500);
searchApiResult.setMessage(e.getMessage());
searchApiResult.setData(null);
return searchApiResult;
}
public static SearchApiResult errorSearchApiResult(final String funName, final Object param, final Exception e) {
logger.error("[※查询]失败:[func={}][param={}][message={}][stack={}]", funName, JsonUtil.toJson(param), e.getMessage(), e);
SearchApiResult searchApiResult = new SearchApiResult();
searchApiResult.setCode(500);
searchApiResult.setMessage(e.getMessage());
searchApiResult.setData(null);
return searchApiResult;
}
}