검색엔진 중간저장

master
강석 최 2023-06-13 18:30:25 +09:00
parent 77f2758497
commit dd3453887d
13 changed files with 223 additions and 32 deletions

View File

@ -41,6 +41,7 @@ dependencies {
implementation 'com.oracle.database.jdbc:ojdbc8:21.7.0.0'
implementation files('libs/tibero6-jdbc.jar')
// json
implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'

View File

@ -4,7 +4,10 @@ import com.dbnt.faisp.main.codeMgt.service.CodeMgtService;
import com.dbnt.faisp.main.publicBoard.model.PublicBoard;
import com.dbnt.faisp.main.publicBoard.model.PublicComment;
import com.dbnt.faisp.main.publicBoard.service.PublicBoardService;
import com.dbnt.faisp.main.searchEngine.model.SearchParams;
import com.dbnt.faisp.main.searchEngine.service.SearchEngineService;
import com.dbnt.faisp.main.userInfo.model.UserInfo;
import com.dbnt.faisp.util.Utils;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
@ -20,9 +23,28 @@ import java.util.List;
@RequestMapping("/search")
public class SearchEngineController {
private final SearchEngineService searchEngineService;
@GetMapping("/searchPage")
public ModelAndView organMgtPage(@AuthenticationPrincipal UserInfo loginUser, PublicBoard publicBoard) {
public ModelAndView organMgtPage(@AuthenticationPrincipal UserInfo loginUser, SearchParams params) {
ModelAndView mav = new ModelAndView("searchEngine/search");
if (Utils.isEmpty(params.getActiveTab())){
params.setActiveTab("all");
}
switch (params.getActiveTab()){
case "all":
params.setOffset("0");
params.setLimit("5");
params.setForm("search_menu_view.search_menu_view");
break;
case "menu":
break;
case "board":
break;
case "file":
break;
}
return mav;
}

View File

@ -0,0 +1,37 @@
package com.dbnt.faisp.main.searchEngine.model;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@Data
@NoArgsConstructor
public class SearchBoardView {
private Integer menuKey;
private Integer mainKey;
private String category;
private String title1Nm;
private String title1;
private String title2Nm;
private String title2;
private String content1Nm;
private String content1;
private String content2Nm;
private String content2;
private String content3Nm;
private String content3;
private String content4Nm;
private String content4;
private String content5Nm;
private String content5;
private String description;
private String hashTag;
private String wrtOrgan;
private String wrtPart;
private Integer wrtUserSeq;
private String wrtUserGrd;
private String wrtUserNm;
private LocalDateTime wrtDt;
private String readAbleUser;
}

View File

@ -0,0 +1,18 @@
package com.dbnt.faisp.main.searchEngine.model;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class SearchFileView {
private Integer menuKey;
private Integer mainKey;
private Integer fileSeq;
private String origNm;
private String convNm;
private String fileExtn;
private String fileSize;
private String savePath;
private String fullPath;
}

View File

@ -0,0 +1,12 @@
package com.dbnt.faisp.main.searchEngine.model;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class SearchMenuView {
private Integer menuKey;
private String menuUrl;
private String menuNm;
}

View File

@ -0,0 +1,14 @@
package com.dbnt.faisp.main.searchEngine.model;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class SearchParams {
private String form;
private String keyword;
private String offset;
private String limit;
private String activeTab;
}

View File

@ -0,0 +1,15 @@
package com.dbnt.faisp.main.searchEngine.model;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.json.JSONArray;
import java.util.List;
@Data
@NoArgsConstructor
public class SearchResult {
private Long totalCount;
private JSONArray rows;
private List<?> rowList;
}

View File

@ -0,0 +1,73 @@
package com.dbnt.faisp.main.searchEngine.service;
import com.dbnt.faisp.main.searchEngine.model.SearchParams;
import com.dbnt.faisp.main.searchEngine.model.SearchResult;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
import java.net.URI;
import java.time.Duration;
@Slf4j
@Service
public class SearchEngineService {
@Value("${search.engine.url}")
private String engineUrl;
public SearchResult requestToSearchEngine(SearchParams params){
URI uri = UriComponentsBuilder.fromHttpUrl(engineUrl)
.path("/search5")
.queryParam("select", "*")
.queryParam("from", params.getForm())
.queryParam("where", "text_idx = '"+params.getKeyword()+"' allword synonym order by $relevance desc")
.queryParam("offset", params.getOffset())
.queryParam("limit", params.getLimit())
.queryParam("charset", "UTF-8")
.queryParam("hilite-keywords", params.getKeyword())
.encode()
.build()
.toUri();
RestTemplate restTemplate = new RestTemplateBuilder()
.setConnectTimeout(Duration.ofMillis(5000))
.setReadTimeout(Duration.ofMillis(5000))
.build();
HttpHeaders header = new HttpHeaders();
header.setContentType(MediaType.APPLICATION_JSON);
header.setAccept(MediaType.parseMediaTypes(MediaType.ALL_VALUE));
header.setConnection("keep-alive");
RequestEntity<Void> req = RequestEntity
.get(uri)
.headers(header)
.build();
ResponseEntity<String> response = restTemplate.exchange(req, String.class);
JSONObject jsonObj = null;
try {
jsonObj = (JSONObject) new JSONParser().parse(response.getBody());
} catch (ParseException e) {
e.printStackTrace();
}
/*이 근처에서 한번 분리할까...?*/
JSONObject resultJSON = (JSONObject) jsonObj.get("result");
SearchResult result = new SearchResult();
result.setTotalCount((Long) resultJSON.get("total_count"));
result.setRows((JSONArray) resultJSON.get("rows"));
return result;
}
}

View File

@ -12,6 +12,7 @@ spring.servlet.multipart.max-request-size=500MB
site.domain=http://localhost:8080
clipReport.print.url=http://118.219.150.34:50570/ClipReport5
search.engine.url=http://118.219.150.34:7577
#file
file.dir.publicBoard=/publicBoard

View File

@ -1,10 +1,10 @@

html, body, div, span, applet, object, iframe,h1, h2, h3, h4, h5, h6, p, blockquote, pre,a, abbr, acronym, address, big, cite, code,del,
dfn, em, img, ins, kbd, q, s, samp,small, strike, strong, sub, sup, tt, var,b, u, i, center,dl, dt, dd, ol, ul, li,fieldset, form, label,
legend, table, caption, tbody, tfoot, thead, tr, th, td,article, aside, canvas, details, embed, figure, figcaption,
footer, header, hgroup, menu, nav, output, ruby, section, summary,time, mark, audio, video {
margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline;
}
/*html, body, div, span, applet, object, iframe,h1, h2, h3, h4, h5, h6, p, blockquote, pre,a, abbr, acronym, address, big, cite, code,del,*/
/* dfn, em, img, ins, kbd, q, s, samp,small, strike, strong, sub, sup, tt, var,b, u, i, center,dl, dt, dd, ol, ul, li,fieldset, form, label, */
/*legend, table, caption, tbody, tfoot, thead, tr, th, td,article, aside, canvas, details, embed, figure, figcaption, */
/*footer, header, hgroup, menu, nav, output, ruby, section, summary,time, mark, audio, video {*/
/* margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline;*/
/*}*/
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
display: block;

View File

@ -1,7 +1,7 @@
html, body {font-family: 'Noto Sans KR','맑은고딕','돋움','Sans-serif',arial; -webkit-text-size-adjust: 100%; min-width:1200px; }
/*html, body {font-family: 'Noto Sans KR','맑은고딕','돋움','Sans-serif',arial; -webkit-text-size-adjust: 100%; min-width:1200px; }*/
body{position:relative; background:#eeeef4;}
.hide{display:none !important;}
*{color:#222;}
/**{color:#222;}*/
.red{color:#e42029 !important; }
.blue{color:#2a6de8 !important; }
.bold{font-weight:bold !important; color:#000;}
@ -19,18 +19,18 @@ input::-moz-placeholder { color: #aaa; }
/*헤더부분------------------------------------------------------------------------*/
.headerArea{border-bottom:1px dashed #bbb;}
header {height:80px; position:relative;}
header h1{padding:15px;}
#searchHeader {height:80px; position:relative;}
#searchHeader h1{padding:15px;}
header .searchPagetop{position:absolute; top:12px; left:50%; margin-left:-400px; width:800px;}
header .searchPagetop .searchBox{width:100%; position:relative; padding-right:175px; box-sizing:border-box; height:56px; background:#fff; border-radius:5px; box-shadow:rgba(60, 90, 130, 0.2) 1px 1px 5px;}
header .searchPagetop .searchBox > input{width:100%; padding:0 20px; box-sizing:border-box; height:56px; line-height:50px; background:url(../images/board/boardSchBul.png) #fff right 10px center no-repeat; border:none; border-radius:5px;}
header .searchPagetop .searchBox > input::-ms-clear {display: none;}
header .searchPagetop .searchBox > input:focus{background:url(../images/board/boardSchBul.png) right 10px center no-repeat;}
header .searchPagetop .searchBox > a{width:78px; position:absolute; top:5px; right:90px; background:#377fe7; color:#fff; text-align:center; display:block; height:44px; line-height:44px; border-radius:5px; border:1px solid #377fe7;}
header .searchPagetop .searchBox > a:last-of-type{right:5px; color:#377fe7; background:#fff; }
header .searchPagetop .searchBox .autoSearchList{position:absolute; top:56px; left:0; display:none; background:#fff; box-sizing:border-box; border:1px solid #bec8d8; border-top:none; z-index:9990; width:calc(100% - 175px);}
header .searchPagetop .searchBox > input:focus ~ .autoSearchList{display:block;}
#searchHeader .searchPagetop{position:absolute; top:12px; left:50%; margin-left:-400px; width:800px;}
#searchHeader .searchPagetop .searchBox{width:100%; position:relative; padding-right:175px; box-sizing:border-box; height:56px; background:#fff; border-radius:5px; box-shadow:rgba(60, 90, 130, 0.2) 1px 1px 5px;}
#searchHeader .searchPagetop .searchBox > input{width:100%; padding:0 20px; box-sizing:border-box; height:56px; line-height:50px; background:url(../../img/searchEngine/board/boardSchBul.png) #fff right 10px center no-repeat; border:none; border-radius:5px;}
#searchHeader .searchPagetop .searchBox > input::-ms-clear {display: none;}
#searchHeader .searchPagetop .searchBox > input:focus{background:url(../../img/searchEngine/board/boardSchBul.png) right 10px center no-repeat;}
#searchHeader .searchPagetop .searchBox > a{width:78px; position:absolute; top:5px; right:90px; background:#377fe7; color:#fff; text-align:center; display:block; height:44px; line-height:44px; border-radius:5px; border:1px solid #377fe7;}
#searchHeader .searchPagetop .searchBox > a:last-of-type{right:5px; color:#377fe7; background:#fff; }
#searchHeader .searchPagetop .searchBox .autoSearchList{position:absolute; top:56px; left:0; display:none; background:#fff; box-sizing:border-box; border:1px solid #bec8d8; border-top:none; z-index:9990; width:calc(100% - 175px);}
#searchHeader .searchPagetop .searchBox > input:focus ~ .autoSearchList{display:block;}
.autoSearchList > p{padding:20px; font-size:15px; color:#284d7e;}
.autoSearchList > ul{padding:13px 0;}
@ -38,9 +38,9 @@ header .searchPagetop .searchBox > input:focus ~ .autoSearchList{display:block;}
.autoSearchList > ul li:hover a, .autoSearchList > ul li a:focus{background-color:#f6f8fb;}
header .searchPagetop .searchBox .sRightBox{position:absolute; right:-140px; top:15px;}
header .searchPagetop .searchBox .sRightBox span{display:block;}
header .searchPagetop .searchBox .sRightBox span label{font-size:16px; vertical-align:middle;}
#searchHeader .searchPagetop .searchBox .sRightBox{position:absolute; right:-140px; top:15px;}
#searchHeader .searchPagetop .searchBox .sRightBox span{display:block;}
#searchHeader .searchPagetop .searchBox .sRightBox span label{font-size:16px; vertical-align:middle;}
/*결과 내 재검색*/
/*헤더부분------------------------------------------------------------------------*/
@ -106,13 +106,13 @@ header .searchPagetop .searchBox .sRightBox span label{font-size:16px; vertical-
.boardList li dd .searchFileList a{display:block; line-height:22px; font-size:14px; color:#777; margin-bottom:4px;}
.boardList li dd .searchFileList a:last-of-type{margin-bottom:0px;}
.boardFileList >li dl dt{padding-left:25px; background:url(../images/board/boardFile.png) left center no-repeat; background-size:20px;}
.boardFileList >li dl dt .downBtn{background:url(../images/board/down.png) 5px center no-repeat; border:1px solid #377fe7; color:#377fe7; font-size:14px; font-weight:normal; padding:2px 5px 2px 22px; margin-left:5px; background-size:21px;}
.boardFileList >li dl dt{padding-left:25px; background:url(../../img/searchEngine/board/boardFile.png) left center no-repeat; background-size:20px;}
.boardFileList >li dl dt .downBtn{background:url(../../img/searchEngine/board/down.png) 5px center no-repeat; border:1px solid #377fe7; color:#377fe7; font-size:14px; font-weight:normal; padding:2px 5px 2px 22px; margin-left:5px; background-size:21px;}
/*게시판*/
.openBul{position:relative; top:0; left:0;}
.openBul:after{content:''; width:10px; height:10px; background:url(../images/common/optionBg01.png)center center no-repeat; position:absolute; top:9px; right:8px;}
dd.focus .openBul:after{background:url(../images/common/optionBg03.png)center center no-repeat;}
.openBul:after{content:''; width:10px; height:10px; background:url(../../img/searchEngine/common/optionBg01.png)center center no-repeat; position:absolute; top:9px; right:8px;}
dd.focus .openBul:after{background:url(../../img/searchEngine/common/optionBg03.png)center center no-repeat;}
/*일반*/
@ -136,7 +136,7 @@ dd.focus .openBul:after{background:url(../images/common/optionBg03.png)center ce
.footerArea p:last-of-type{font-size:13px; color:#999;}
.emptyBox{margin:50px 0; border-radius:5px; box-shadow:rgba(60, 90, 130, 0.2) 1px 1px 5px; box-sizing:border-box; padding:310px 30px 30px 30px; text-align:center; background:url(../images/common/empty.png) #fff center 10px no-repeat;}
.emptyBox{margin:50px 0; border-radius:5px; box-shadow:rgba(60, 90, 130, 0.2) 1px 1px 5px; box-sizing:border-box; padding:310px 30px 30px 30px; text-align:center; background:url(../../img/searchEngine/common/empty.png) #fff center 10px no-repeat;}
.emptyBox h3{color:#2a6de8; font-size:24px; line-height:30px; margin-bottom:20px; font-weight:bold;}
.emptyBox p{ box-sizing:border-box; padding:8px; font-size:16px; line-height:22px;}
/*검색내용부분------------------------------------------------------------------------*/
@ -156,7 +156,7 @@ dd.focus .openBul:after{background:url(../images/common/optionBg03.png)center ce
.guideBox {width:95%; margin:0 auto;}
header .searchPagetop{margin-left:-300px; width:600px;}
#searchHeader .searchPagetop{margin-left:-300px; width:600px;}
.searchWideBox > li{padding:13px 0 13px 130px; float:none; margin-left:0px; border-left:none;}
.searchWideBox > li p{left:55px; }

View File

@ -45,8 +45,6 @@
<script type="text/javascript" th:src="@{/js/common.js}"></script>
<!-- 컨텐츠페이지의 스크립트 영역이 들어감 -->
<th:block layout:fragment="script"></th:block>
</head>
<body class="d-flex flex-column h-100 ">
<!--<header th:replace="fragments/header :: headerFragment"></header>

View File

@ -13,7 +13,7 @@
<div layout:fragment="content">
<main>
<div class="headerArea">
<header>
<header id="searchHeader">
<div class="searchPagetop guideBox">
<form>
<div class="searchBox">