替换fastjson为jackson

This commit is contained in:
zlt2000
2020-10-09 00:21:39 +08:00
parent 381b36c31c
commit 72ec878480
24 changed files with 257 additions and 63 deletions
@@ -1,10 +1,10 @@
package com.central.search.client.feign;
import com.alibaba.fastjson.JSONObject;
import com.central.common.constant.ServiceNameConstants;
import com.central.common.model.PageResult;
import com.central.search.client.feign.fallback.SearchServiceFallbackFactory;
import com.central.search.model.SearchDto;
import com.fasterxml.jackson.databind.JsonNode;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
@@ -19,5 +19,5 @@ public interface SearchService {
* @param searchDto 搜索Dto
*/
@PostMapping(value = "/search/{indexName}")
PageResult<JSONObject> strQuery(@PathVariable("indexName") String indexName, @RequestBody SearchDto searchDto);
PageResult<JsonNode> strQuery(@PathVariable("indexName") String indexName, @RequestBody SearchDto searchDto);
}
@@ -1,8 +1,8 @@
package com.central.search.client.feign.fallback;
import com.alibaba.fastjson.JSONObject;
import com.central.common.model.PageResult;
import com.central.search.client.feign.SearchService;
import com.fasterxml.jackson.databind.JsonNode;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
@@ -17,7 +17,7 @@ public class SearchServiceFallbackFactory implements FallbackFactory<SearchServi
public SearchService create(Throwable throwable) {
return (indexName, searchDto) -> {
log.error("通过索引{}搜索异常:{}", indexName, throwable);
return PageResult.<JSONObject>builder().build();
return PageResult.<JsonNode>builder().build();
};
}
}
@@ -1,9 +1,9 @@
package com.central.search.client.service;
import com.alibaba.fastjson.JSONObject;
import com.central.common.model.PageResult;
import com.central.search.model.LogicDelDto;
import com.central.search.model.SearchDto;
import com.fasterxml.jackson.databind.JsonNode;
import java.util.Map;
@@ -19,7 +19,7 @@ public interface IQueryService {
* @param indexName 索引名
* @param searchDto 搜索Dto
*/
PageResult<JSONObject> strQuery(String indexName, SearchDto searchDto);
PageResult<JsonNode> strQuery(String indexName, SearchDto searchDto);
/**
* 查询文档列表
@@ -27,7 +27,7 @@ public interface IQueryService {
* @param searchDto 搜索Dto
* @param logicDelDto 逻辑删除Dto
*/
PageResult<JSONObject> strQuery(String indexName, SearchDto searchDto, LogicDelDto logicDelDto);
PageResult<JsonNode> strQuery(String indexName, SearchDto searchDto, LogicDelDto logicDelDto);
/**
* 访问统计聚合查询
@@ -1,13 +1,13 @@
package com.central.search.client.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.central.common.model.PageResult;
import com.central.search.client.feign.AggregationService;
import com.central.search.client.feign.SearchService;
import com.central.search.client.service.IQueryService;
import com.central.search.model.LogicDelDto;
import com.central.search.model.SearchDto;
import com.fasterxml.jackson.databind.JsonNode;
import javax.annotation.Resource;
import java.util.Map;
@@ -26,12 +26,12 @@ public class QueryServiceImpl implements IQueryService {
private AggregationService aggregationService;
@Override
public PageResult<JSONObject> strQuery(String indexName, SearchDto searchDto) {
public PageResult<JsonNode> strQuery(String indexName, SearchDto searchDto) {
return strQuery(indexName, searchDto, null);
}
@Override
public PageResult<JSONObject> strQuery(String indexName, SearchDto searchDto, LogicDelDto logicDelDto) {
public PageResult<JsonNode> strQuery(String indexName, SearchDto searchDto, LogicDelDto logicDelDto) {
setLogicDelQueryStr(searchDto, logicDelDto);
return searchService.strQuery(indexName, searchDto);
}