|
|
@@ -1,7 +1,6 @@
|
|
|
package com.style24.front.biz.thirdparty;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.Collection;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
@@ -16,8 +15,12 @@ import org.springframework.stereotype.Component;
|
|
|
import com.diquest.ir.common.exception.IRException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.google.gson.Gson;
|
|
|
+import com.style24.front.biz.dao.TsfDisplayDao;
|
|
|
import com.style24.front.support.security.session.TsfSession;
|
|
|
+import com.style24.persistence.domain.Cate1;
|
|
|
+import com.style24.persistence.domain.searchengine.CateResponse;
|
|
|
import com.style24.persistence.domain.searchengine.Filter;
|
|
|
+import com.style24.persistence.domain.searchengine.FilterResponse;
|
|
|
import com.style24.persistence.domain.searchengine.SearchEngine;
|
|
|
|
|
|
import istyle.AutoSearch;
|
|
|
@@ -39,12 +42,15 @@ public class SearchEngineDiquest {
|
|
|
private Environment env;
|
|
|
|
|
|
private String ipAddr; // 검색엔진 IP
|
|
|
- private String port; // 검색엔진 포트
|
|
|
+ private Integer port; // 검색엔진 포트
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TsfDisplayDao displayDao;
|
|
|
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
ipAddr = env.getProperty("search.engine.diquest.ip");
|
|
|
- port = env.getProperty("search.engine.diquest.port");
|
|
|
+ port = Integer.valueOf(env.getProperty("search.engine.diquest.port"));
|
|
|
|
|
|
log.debug("\n\n---- NHN Diquest initialization started ----");
|
|
|
log.debug("ipAddr: [{}]", ipAddr);
|
|
|
@@ -62,16 +68,18 @@ public class SearchEngineDiquest {
|
|
|
SearchEngine result = new SearchEngine();
|
|
|
|
|
|
// 인기검색어
|
|
|
- Map<String, Object> map = new HashMap<String, Object>();
|
|
|
- map.put("adminIp", ipAddr);
|
|
|
- map.put("adminPort", port);
|
|
|
+ Map<String, Object> paramMap = new HashMap<String, Object>();
|
|
|
+ paramMap.put("adminIp", ipAddr);
|
|
|
+ paramMap.put("adminPort", port);
|
|
|
+ log.info("///[getTrendKeywordList] paramMap: {}", paramMap);
|
|
|
|
|
|
try {
|
|
|
- JSONObject jsonObj = AutoSearch.trendKeyword(map);
|
|
|
- log.info("jsonObj.toJSONString(): {}", jsonObj.toJSONString());
|
|
|
+ JSONObject jsonObj = AutoSearch.trendKeyword(paramMap);
|
|
|
+ log.info("///[getTrendKeywordList] jsonObj: {}", jsonObj.toJSONString());
|
|
|
|
|
|
Gson gson = new Gson();
|
|
|
result = gson.fromJson(jsonObj.toJSONString(), SearchEngine.class);
|
|
|
+ log.info("///[getTrendKeywordList] result: {}", result);
|
|
|
} catch (IRException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -86,40 +94,36 @@ public class SearchEngineDiquest {
|
|
|
* @author gagamel
|
|
|
* @since 2021. 5. 31
|
|
|
*/
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
- public SearchEngine getCategoryList(SearchEngine params) {
|
|
|
- SearchEngine result = new SearchEngine();
|
|
|
+ public Collection<Cate1> getCategoryList(SearchEngine params) {
|
|
|
+ Collection<Cate1> result = new ArrayList<Cate1>();
|
|
|
|
|
|
- Map<String, Object> paramMap = new HashMap<>();// this.convertObjectToMap(params);
|
|
|
+ Map<String, Object> paramMap = this.convertObjectToMap(params);
|
|
|
paramMap.put("adminIp", ipAddr);
|
|
|
paramMap.put("adminPort", port);
|
|
|
// paramMap.put("cate1No", 1300);
|
|
|
- paramMap.put("brandGroupNo", 0);
|
|
|
+// paramMap.put("brandGroupNo", 0);
|
|
|
paramMap.put("frontGb", TsfSession.getFrontGb());
|
|
|
- paramMap.put("keyword", "키즈");
|
|
|
- paramMap.put("formalGb", "G009_20");
|
|
|
+// paramMap.put("keyword", "키즈");
|
|
|
+// paramMap.put("formalGb", "G009_20");
|
|
|
|
|
|
// 브랜드그룹번호 값이 있으면 (=브랜드메인에서 조회했으면)
|
|
|
paramMap.put("defaultCateYn", "Y");
|
|
|
if (params.getBrandGroupNo() > 0) {
|
|
|
- paramMap.put("defaultCateYn", "Y");
|
|
|
+ paramMap.put("defaultCateYn", displayDao.getBrandGroupDefaultCategoryYn(params.getBrandGroupNo()));
|
|
|
}
|
|
|
-
|
|
|
- log.info("--------------------------1");
|
|
|
- log.info("{}", paramMap);
|
|
|
+ log.info("///[getCategoryList] paramMap: {}", paramMap);
|
|
|
|
|
|
try {
|
|
|
- log.info("--------------------------2");
|
|
|
JSONObject jsonObj = SearchService.getCategoryGoodsList(paramMap);
|
|
|
- log.info("jsonObj: {}", jsonObj.toString());
|
|
|
-
|
|
|
-// Gson gson = new Gson();
|
|
|
-// Map<String, Object> resMap = gson.fromJson(jsonObj.toJSONString(), Map.class);
|
|
|
-// log.info("{}", resMap);
|
|
|
-//
|
|
|
-// if (resMap.get("returnCode").equals("1")) { // 성공
|
|
|
-// result = gson.fromJson(resMap.get("response").toString(), SearchEngine.class);
|
|
|
-// }
|
|
|
+ log.info("///[getCategoryList] jsonObj: {}", jsonObj.toJSONString());
|
|
|
+
|
|
|
+ Gson gson = new Gson();
|
|
|
+ CateResponse response = gson.fromJson(jsonObj.toJSONString(), CateResponse.class);
|
|
|
+
|
|
|
+ if (jsonObj.get("returnCode").toString().equals("1")) { // 성공
|
|
|
+ result = response.getResponse();
|
|
|
+ log.info("///[getCategoryList] result: {}", result);
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -134,28 +138,25 @@ public class SearchEngineDiquest {
|
|
|
* @author gagamel
|
|
|
* @since 2021. 5. 31
|
|
|
*/
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
public Collection<Filter> getFilterList(SearchEngine params) {
|
|
|
Collection<Filter> result = new ArrayList<Filter>();
|
|
|
|
|
|
Map<String, Object> paramMap = this.convertObjectToMap(params);
|
|
|
paramMap.put("adminIp", ipAddr);
|
|
|
paramMap.put("adminPort", port);
|
|
|
- log.info("{}", paramMap);
|
|
|
+ paramMap.put("frontGb", TsfSession.getFrontGb());
|
|
|
+ log.info("///[getFilterList] paramMap: {}", paramMap);
|
|
|
|
|
|
try {
|
|
|
JSONObject jsonObj = SearchService.getFilterList(paramMap);
|
|
|
- log.info("jsonObj.toJSONString(): {}", jsonObj.toJSONString());
|
|
|
+ log.info("///[getFilterList] jsonObj: {}", jsonObj.toJSONString());
|
|
|
|
|
|
Gson gson = new Gson();
|
|
|
- Map<String, Object> resMap = gson.fromJson(jsonObj.toJSONString(), Map.class);
|
|
|
- log.info("{}", resMap);
|
|
|
+ FilterResponse response = gson.fromJson(jsonObj.toJSONString(), FilterResponse.class);
|
|
|
|
|
|
- if (resMap.get("returnCode").equals("1")) { // 성공
|
|
|
- Filter[] arrFilter = gson.fromJson(resMap.get("response").toString(), Filter[].class);
|
|
|
- result = Arrays.asList(arrFilter);
|
|
|
-// result = gson.fromJson(resMap.get("response").toString(), new TypeToken<Collection<Filter>>() {
|
|
|
-// }.getType());
|
|
|
+ if (jsonObj.get("returnCode").toString().equals("1")) { // 성공
|
|
|
+ result = response.getResponse();
|
|
|
+ log.info("///[getFilterList] result: {}", result);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|