Commit 78661966 by wang_jiaxing

修改全国ES接口工具类,增加范型限制

parent 4c76ae89
......@@ -15,9 +15,9 @@ public enum QgEsEnum {
//全国ES接口url
private final String url;
//返回类型(实体类class对象)
private final Class<?> type;
private final Class<? extends QgEsEntity> type;
QgEsEnum(String url, Class<?> type) {
QgEsEnum(String url, Class<? extends QgEsEntity> type) {
this.url = url;
this.type = type;
}
......@@ -26,7 +26,7 @@ public enum QgEsEnum {
return url;
}
public Class<?> getType() {
public Class<? extends QgEsEntity> getType() {
return type;
}
}
......@@ -91,9 +91,10 @@ public class QgEsUtil {
String resultJson = HttpUtils.doPostJson(url + qgEsEnum.getUrl(), headers, json.toString());
HashMap<String, Object> map = getResultMapByJsonAndType(qgEsEnum.getType(), resultJson);
List<T> javaList = (List<T>) map.get("rows");
if (javaList == null || javaList.isEmpty()) {
return javaList == null ? new ArrayList<>(0) : javaList;
if (javaList == null) {
return new ArrayList<>(0);
}
return javaList;
} catch (Exception e) {
log.error("查询全国ES接口报错", e);
}
......@@ -211,7 +212,7 @@ public class QgEsUtil {
* @author lystar
* 2022/5/6 16:29
*/
private static HashMap<String, Object> getResultMapByJsonAndType(Class<?> type, String json) throws Exception {
private static HashMap<String, Object> getResultMapByJsonAndType(Class<? extends QgEsEntity> type, String json) throws Exception {
if (type == null) {
throw new Exception("查询案件是否存在请直接使用asjApiIsExist方法");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment