SearchApiResultUtils.java
1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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;
}
public static SearchApiResult defaultErrorSearchApiResult(final Exception e) {
SearchApiResult searchApiResult = new SearchApiResult();
searchApiResult.setCode(500);
searchApiResult.setMessage(e.getMessage());
searchApiResult.setData(null);
return searchApiResult;
}
}