|
@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -43,6 +44,7 @@ public class SearchServiceImpl implements SearchService {
|
|
|
private KnowledgeMapper knowledgeMapper;
|
|
|
|
|
|
@SneakyThrows
|
|
|
+ @Override
|
|
|
public Map<String,Object> search(String keyword, Integer pageIndex, Integer pageSize,
|
|
|
Integer range, Integer secretType,Integer orderFiled,Integer orderSort, HttpServletRequest httpServletRequest) {
|
|
|
Map<String,Object> result = new HashMap<>();
|
|
@@ -80,6 +82,7 @@ public class SearchServiceImpl implements SearchService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @SneakyThrows
|
|
|
@Override
|
|
|
public Map<String,Object> notice(String pkId,String documentId,String documentTitle,String documentName,String documentPath,
|
|
|
String documentUrl, String downloadUrl,String documentMd5,String uploaderName,
|
|
@@ -108,7 +111,7 @@ public class SearchServiceImpl implements SearchService {
|
|
|
headerMap.put("signature", sign);
|
|
|
headerMap.put("businessKey", "knowlege-manager");
|
|
|
headerMap.put("userId",userService.queryLoginUser());
|
|
|
- JSONObject respone = HttpRequestHelper.sendRequest(headerMap,paramMap,searchUrl+"/api-kmsearch/search/notice");
|
|
|
+ JSONObject respone = HttpRequestHelper.sendRequest(headerMap,paramsEncoder(paramMap),searchUrl+"/api-kmsearch/search/notice");
|
|
|
if(null != respone && 200 == respone.getIntValue("code")) {
|
|
|
result.put("code",respone.getIntValue("code"));
|
|
|
result.put("message",respone.getString("message"));
|
|
@@ -230,4 +233,21 @@ public class SearchServiceImpl implements SearchService {
|
|
|
log.info("加密后的secret -> {}",MD5.encrypt(sb.toString()).toLowerCase());
|
|
|
return MD5.encrypt(sb.toString()).toLowerCase();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 参数编码(httpclient处理发送特殊字符)
|
|
|
+ * @param params
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map<String,Object> paramsEncoder(Map<String,Object> params) throws UnsupportedEncodingException {
|
|
|
+ log.info("请求参数 -> {}",params);
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ Set<String> keySet = params.keySet();
|
|
|
+ for (String key : keySet){
|
|
|
+ Object value = params.get(key);
|
|
|
+ value = URLEncoder.encode(value.toString(),"utf-8");
|
|
|
+ result.put(key,value);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|