|
|
|
|
@ -1,126 +1,126 @@
|
|
|
|
|
package kcc.let.solr.search.web;
|
|
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
|
|
import egovframework.rte.fdl.string.EgovStringUtil;
|
|
|
|
|
import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
|
|
|
|
|
import kcc.let.solr.search.service.SearchService;
|
|
|
|
|
@Controller
|
|
|
|
|
public class SearchContorller {
|
|
|
|
|
|
|
|
|
|
Logger log = LoggerFactory.getLogger(this.getClass());
|
|
|
|
|
|
|
|
|
|
@Resource(name = "searchService")
|
|
|
|
|
protected SearchService searchService;
|
|
|
|
|
|
|
|
|
|
//TODO test URL
|
|
|
|
|
// http://192.168.0.125:8983/solr/kcc_adr_advc/select?q=*:*&wt=json&indent=true
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
@RequestMapping(value = "/web/search/search.do")
|
|
|
|
|
public String search(@RequestParam Map<String, Object> commandMap, ModelMap model) throws Exception {
|
|
|
|
|
log.debug("commandMap : {}", commandMap);
|
|
|
|
|
|
|
|
|
|
String searchWrd = (String) commandMap.get("q");
|
|
|
|
|
|
|
|
|
|
if (searchWrd!= null && !("").equals(searchWrd)) {
|
|
|
|
|
searchService.search(commandMap, model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PaginationInfo paginationInfo = new PaginationInfo();
|
|
|
|
|
int totalRecordCount = 0;
|
|
|
|
|
String rangeView = (String)commandMap.get("rangeView");
|
|
|
|
|
if ( StringUtils.isNotBlank(rangeView) ) {
|
|
|
|
|
Map<String, Long> resultCntMap = (Map<String, Long>)model.get("resultCntMap");
|
|
|
|
|
log.debug("resultCntMap : {}", resultCntMap);
|
|
|
|
|
Long total = resultCntMap.get(rangeView);
|
|
|
|
|
if (total != null) {
|
|
|
|
|
totalRecordCount = total.intValue();
|
|
|
|
|
}
|
|
|
|
|
log.debug("totalRecordCount : {}", totalRecordCount);
|
|
|
|
|
|
|
|
|
|
String pi = (String)commandMap.get("pageIndex");
|
|
|
|
|
if ( StringUtils.isBlank(pi) ) {
|
|
|
|
|
pi = "1";
|
|
|
|
|
}
|
|
|
|
|
int pageIndex = EgovStringUtil.string2integer(pi);
|
|
|
|
|
log.debug("pageIndex : {}", pageIndex);
|
|
|
|
|
paginationInfo.setCurrentPageNo(pageIndex);
|
|
|
|
|
paginationInfo.setRecordCountPerPage(10);
|
|
|
|
|
paginationInfo.setPageSize(10);
|
|
|
|
|
paginationInfo.setTotalRecordCount(totalRecordCount);
|
|
|
|
|
model.addAttribute("paginationInfo", paginationInfo);
|
|
|
|
|
}
|
|
|
|
|
model.addAttribute("totalRecordCount", totalRecordCount);
|
|
|
|
|
|
|
|
|
|
return "web/search/search";
|
|
|
|
|
//return "web/search/search_0529.jsp";
|
|
|
|
|
//return "kopost/search/search";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
@RequestMapping(value = "/{siteId}/web/search/search.do")
|
|
|
|
|
public String siteSearch(@PathVariable("siteId") String siteId , @RequestParam Map<String, Object> commandMap, ModelMap model) throws Exception {
|
|
|
|
|
log.debug("commandMap : {}", commandMap);
|
|
|
|
|
|
|
|
|
|
String searchWrd = (String) commandMap.get("q");
|
|
|
|
|
if (searchWrd!= null && !("").equals(searchWrd)) {
|
|
|
|
|
searchService.search(commandMap, model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PaginationInfo paginationInfo = new PaginationInfo();
|
|
|
|
|
int totalRecordCount = 0;
|
|
|
|
|
String rangeView = (String)commandMap.get("rangeView");
|
|
|
|
|
if ( StringUtils.isNotBlank(rangeView) ) {
|
|
|
|
|
Map<String, Long> resultCntMap = (Map<String, Long>)model.get("resultCntMap");
|
|
|
|
|
log.debug("resultCntMap : {}", resultCntMap);
|
|
|
|
|
Long total = resultCntMap.get(rangeView);
|
|
|
|
|
if (total != null) {
|
|
|
|
|
totalRecordCount = total.intValue();
|
|
|
|
|
}
|
|
|
|
|
log.debug("totalRecordCount : {}", totalRecordCount);
|
|
|
|
|
|
|
|
|
|
String pi = (String)commandMap.get("pageIndex");
|
|
|
|
|
if ( StringUtils.isBlank(pi) ) {
|
|
|
|
|
pi = "1";
|
|
|
|
|
}
|
|
|
|
|
int pageIndex = EgovStringUtil.string2integer(pi);
|
|
|
|
|
log.debug("pageIndex : {}", pageIndex);
|
|
|
|
|
paginationInfo.setCurrentPageNo(pageIndex);
|
|
|
|
|
paginationInfo.setRecordCountPerPage(10);
|
|
|
|
|
paginationInfo.setPageSize(10);
|
|
|
|
|
paginationInfo.setTotalRecordCount(totalRecordCount);
|
|
|
|
|
model.addAttribute("paginationInfo", paginationInfo);
|
|
|
|
|
}
|
|
|
|
|
model.addAttribute("totalRecordCount", totalRecordCount);
|
|
|
|
|
|
|
|
|
|
model.addAttribute("siteId", siteId);
|
|
|
|
|
String siteFolder = "site/"+siteId ;
|
|
|
|
|
model.addAttribute("site_path", "/"+siteFolder);
|
|
|
|
|
|
|
|
|
|
//return "kopost/search/search";
|
|
|
|
|
return "web/"+siteFolder+"/search/search";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/json/ajaxSuggest.do")
|
|
|
|
|
public ModelAndView ajaxEditorCopy(@RequestParam Map<String, Object> commandMap) throws Exception {
|
|
|
|
|
ModelAndView modelAndView = new ModelAndView();
|
|
|
|
|
modelAndView.setViewName("jsonView");
|
|
|
|
|
|
|
|
|
|
Set<String> resultList = searchService.suggest(commandMap);
|
|
|
|
|
modelAndView.addObject("resultList", resultList);
|
|
|
|
|
return modelAndView;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
package kcc.let.solr.search.web;
|
|
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
|
|
import egovframework.rte.fdl.string.EgovStringUtil;
|
|
|
|
|
import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
|
|
|
|
|
import kcc.let.solr.search.service.SearchService;
|
|
|
|
|
@Controller
|
|
|
|
|
public class SearchContorller {
|
|
|
|
|
|
|
|
|
|
Logger log = LoggerFactory.getLogger(this.getClass());
|
|
|
|
|
|
|
|
|
|
@Resource(name = "searchService")
|
|
|
|
|
protected SearchService searchService;
|
|
|
|
|
|
|
|
|
|
//TODO test URL
|
|
|
|
|
// http://192.168.0.125:8983/solr/kcc_adr_advc/select?q=*:*&wt=json&indent=true
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
@RequestMapping(value = "/web/search/search.do")
|
|
|
|
|
public String search(@RequestParam Map<String, Object> commandMap, ModelMap model) throws Exception {
|
|
|
|
|
log.debug("commandMap : {}", commandMap);
|
|
|
|
|
|
|
|
|
|
String searchWrd = (String) commandMap.get("q");
|
|
|
|
|
|
|
|
|
|
if (searchWrd!= null && !("").equals(searchWrd)) {
|
|
|
|
|
searchService.search(commandMap, model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PaginationInfo paginationInfo = new PaginationInfo();
|
|
|
|
|
int totalRecordCount = 0;
|
|
|
|
|
String rangeView = (String)commandMap.get("rangeView");
|
|
|
|
|
if ( StringUtils.isNotBlank(rangeView) ) {
|
|
|
|
|
Map<String, Long> resultCntMap = (Map<String, Long>)model.get("resultCntMap");
|
|
|
|
|
log.debug("resultCntMap : {}", resultCntMap);
|
|
|
|
|
Long total = resultCntMap.get(rangeView);
|
|
|
|
|
if (total != null) {
|
|
|
|
|
totalRecordCount = total.intValue();
|
|
|
|
|
}
|
|
|
|
|
log.debug("totalRecordCount : {}", totalRecordCount);
|
|
|
|
|
|
|
|
|
|
String pi = (String)commandMap.get("pageIndex");
|
|
|
|
|
if ( StringUtils.isBlank(pi) ) {
|
|
|
|
|
pi = "1";
|
|
|
|
|
}
|
|
|
|
|
int pageIndex = EgovStringUtil.string2integer(pi);
|
|
|
|
|
log.debug("pageIndex : {}", pageIndex);
|
|
|
|
|
paginationInfo.setCurrentPageNo(pageIndex);
|
|
|
|
|
paginationInfo.setRecordCountPerPage(10);
|
|
|
|
|
paginationInfo.setPageSize(10);
|
|
|
|
|
paginationInfo.setTotalRecordCount(totalRecordCount);
|
|
|
|
|
model.addAttribute("paginationInfo", paginationInfo);
|
|
|
|
|
}
|
|
|
|
|
model.addAttribute("totalRecordCount", totalRecordCount);
|
|
|
|
|
|
|
|
|
|
return "web/search/search";
|
|
|
|
|
//return "web/search/search_0529.jsp";
|
|
|
|
|
//return "kopost/search/search";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
@RequestMapping(value = "/{siteId}/web/search/search.do")
|
|
|
|
|
public String siteSearch(@PathVariable("siteId") String siteId , @RequestParam Map<String, Object> commandMap, ModelMap model) throws Exception {
|
|
|
|
|
log.debug("commandMap : {}", commandMap);
|
|
|
|
|
|
|
|
|
|
String searchWrd = (String) commandMap.get("q");
|
|
|
|
|
if (searchWrd!= null && !("").equals(searchWrd)) {
|
|
|
|
|
searchService.search(commandMap, model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PaginationInfo paginationInfo = new PaginationInfo();
|
|
|
|
|
int totalRecordCount = 0;
|
|
|
|
|
String rangeView = (String)commandMap.get("rangeView");
|
|
|
|
|
if ( StringUtils.isNotBlank(rangeView) ) {
|
|
|
|
|
Map<String, Long> resultCntMap = (Map<String, Long>)model.get("resultCntMap");
|
|
|
|
|
log.debug("resultCntMap : {}", resultCntMap);
|
|
|
|
|
Long total = resultCntMap.get(rangeView);
|
|
|
|
|
if (total != null) {
|
|
|
|
|
totalRecordCount = total.intValue();
|
|
|
|
|
}
|
|
|
|
|
log.debug("totalRecordCount : {}", totalRecordCount);
|
|
|
|
|
|
|
|
|
|
String pi = (String)commandMap.get("pageIndex");
|
|
|
|
|
if ( StringUtils.isBlank(pi) ) {
|
|
|
|
|
pi = "1";
|
|
|
|
|
}
|
|
|
|
|
int pageIndex = EgovStringUtil.string2integer(pi);
|
|
|
|
|
log.debug("pageIndex : {}", pageIndex);
|
|
|
|
|
paginationInfo.setCurrentPageNo(pageIndex);
|
|
|
|
|
paginationInfo.setRecordCountPerPage(10);
|
|
|
|
|
paginationInfo.setPageSize(10);
|
|
|
|
|
paginationInfo.setTotalRecordCount(totalRecordCount);
|
|
|
|
|
model.addAttribute("paginationInfo", paginationInfo);
|
|
|
|
|
}
|
|
|
|
|
model.addAttribute("totalRecordCount", totalRecordCount);
|
|
|
|
|
|
|
|
|
|
model.addAttribute("siteId", siteId);
|
|
|
|
|
String siteFolder = "site/"+siteId ;
|
|
|
|
|
model.addAttribute("site_path", "/"+siteFolder);
|
|
|
|
|
|
|
|
|
|
//return "kopost/search/search";
|
|
|
|
|
return "web/"+siteFolder+"/search/search";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/json/ajaxSuggest.do")
|
|
|
|
|
public ModelAndView ajaxEditorCopy(@RequestParam Map<String, Object> commandMap) throws Exception {
|
|
|
|
|
ModelAndView modelAndView = new ModelAndView();
|
|
|
|
|
modelAndView.setViewName("jsonView");
|
|
|
|
|
|
|
|
|
|
Set<String> resultList = searchService.suggest(commandMap);
|
|
|
|
|
modelAndView.addObject("resultList", resultList);
|
|
|
|
|
return modelAndView;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|