공통코드 조회 기능 추가, Paging 처리 보완 (중간백업)
This commit is contained in:
parent
7ad2cb9eed
commit
43af6f01dc
18
data/dataxml/uac.service.code.list.PAGE_SIZE_GET.xml
Normal file
18
data/dataxml/uac.service.code.list.PAGE_SIZE_GET.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<!-- uac.service.board.qna_GET.xml -->
|
||||||
|
<result>
|
||||||
|
<records>3</records>
|
||||||
|
<results>
|
||||||
|
<code>010</code>
|
||||||
|
<name>10개씩</name>
|
||||||
|
</results>
|
||||||
|
<results>
|
||||||
|
<code>050</code>
|
||||||
|
<name>50개씩</name>
|
||||||
|
</results>
|
||||||
|
<results>
|
||||||
|
<code>100</code>
|
||||||
|
<name>100개씩</name>
|
||||||
|
</results>
|
||||||
|
</result>
|
||||||
|
|
||||||
@ -23,6 +23,7 @@ import nlib.bbs.service.BoardService;
|
|||||||
import nlib.cmm.NlibCommonController;
|
import nlib.cmm.NlibCommonController;
|
||||||
import nlib.cmm.crypto.AriaCrypto;
|
import nlib.cmm.crypto.AriaCrypto;
|
||||||
import nlib.cmm.crypto.NlibPasswordEncoder;
|
import nlib.cmm.crypto.NlibPasswordEncoder;
|
||||||
|
import nlib.cmm.service.CodeService;
|
||||||
import nlib.restful.service.DataApiReqVO;
|
import nlib.restful.service.DataApiReqVO;
|
||||||
import nlib.restful.service.DataApiResVO;
|
import nlib.restful.service.DataApiResVO;
|
||||||
import nlib.user.service.NlibLoginVO;
|
import nlib.user.service.NlibLoginVO;
|
||||||
@ -42,6 +43,9 @@ public class BoardController extends NlibCommonController
|
|||||||
@Resource(name = "ariaCrypto")
|
@Resource(name = "ariaCrypto")
|
||||||
private AriaCrypto ariaCrypto;
|
private AriaCrypto ariaCrypto;
|
||||||
|
|
||||||
|
@Resource(name = "codeService")
|
||||||
|
private CodeService codeService;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AuthenticationManager authenticationManager;
|
private AuthenticationManager authenticationManager;
|
||||||
@ -93,11 +97,20 @@ public class BoardController extends NlibCommonController
|
|||||||
String pageIndex = paramMap.get("pageIndex");
|
String pageIndex = paramMap.get("pageIndex");
|
||||||
String pageSize = paramMap.get("pageSize");
|
String pageSize = paramMap.get("pageSize");
|
||||||
|
|
||||||
// 반환 정보
|
// 페이징 사이즈 코드 목록 조회
|
||||||
|
DataApiReqVO reqVOforPageSize = new DataApiReqVO();
|
||||||
|
reqVOforPageSize.setAuthKey(createAuthKey(req, authentication));
|
||||||
|
reqVOforPageSize.setPageSize(0);
|
||||||
|
reqVOforPageSize.addInfoItem("codeUpperId", "PAGE_SIZE");
|
||||||
|
DataApiResVO resVOforPageSize = codeService.listCodes(reqVOforPageSize);
|
||||||
|
|
||||||
|
// 반환 정보
|
||||||
model.addAttribute("pageIndex" , pageIndex);
|
model.addAttribute("pageIndex" , pageIndex);
|
||||||
model.addAttribute("pageSize" , pageSize);
|
model.addAttribute("pageSize" , pageSize);
|
||||||
model.addAttribute("searchKeyword", searchKeyword);
|
model.addAttribute("searchKeyword", searchKeyword);
|
||||||
|
model.addAttribute("pageSizeCodes", resVOforPageSize.getList());
|
||||||
|
|
||||||
|
log.debug("listQnAs > pageSizeCodes : " + resVOforPageSize.getList());
|
||||||
return "nlib/board/listQnAs";
|
return "nlib/board/listQnAs";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,8 +148,21 @@ public class BoardController extends NlibCommonController
|
|||||||
// 요청
|
// 요청
|
||||||
DataApiResVO resVO = boardService.listQnAs(reqVO);
|
DataApiResVO resVO = boardService.listQnAs(reqVO);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------
|
||||||
// JSON변환 응답 처리
|
// JSON변환 응답 처리
|
||||||
return makeResponseEntityJson(resVO.getList());
|
//-------------------------------
|
||||||
|
// JS-GRID 페이징 처리를 포함한 응답값 처리
|
||||||
|
// {data: [{...}],
|
||||||
|
// itemsCount: 255
|
||||||
|
// }
|
||||||
|
|
||||||
|
HashMap<String, Object> retMap = new HashMap<String, Object>();
|
||||||
|
retMap.put("data", resVO.getList());
|
||||||
|
retMap.put("itemsCount", resVO.getRecordTotCount());
|
||||||
|
|
||||||
|
return makeResponseEntityJson(retMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -152,4 +152,27 @@ public class NlibCommonController {
|
|||||||
|
|
||||||
return ResponseEntity.ok().headers(headers).body(jsonStr);
|
return ResponseEntity.ok().headers(headers).body(jsonStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<String> makeResponseEntityJson(HashMap<String,Object> retMap) {
|
||||||
|
|
||||||
|
// Convert Json
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
String jsonStr = null;
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add(HttpHeaders.CONTENT_TYPE, "application/json; charset=UTF-8");
|
||||||
|
|
||||||
|
try {
|
||||||
|
jsonStr = mapper.writeValueAsString(retMap);
|
||||||
|
log.debug("RETURN DATA > json:" + jsonStr);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
ErrorMessage eMsg = new ErrorMessage("ERR_JSON_CONVERT", "응답객체를 JSON으로 변환 처리 중 오류가 발생하였습니다. : " + e.toString());
|
||||||
|
try { jsonStr = mapper.writeValueAsString(eMsg); } catch (JsonProcessingException ee) {}
|
||||||
|
e.printStackTrace();
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).headers(headers).body(jsonStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity.ok().headers(headers).body(jsonStr);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
13
src/main/java/nlib/cmm/service/CodeService.java
Normal file
13
src/main/java/nlib/cmm/service/CodeService.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
package nlib.cmm.service;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import nlib.restful.service.DataApiReqVO;
|
||||||
|
import nlib.restful.service.DataApiResVO;
|
||||||
|
|
||||||
|
public interface CodeService
|
||||||
|
{
|
||||||
|
public DataApiResVO listCodes(DataApiReqVO reqVO);
|
||||||
|
|
||||||
|
}
|
||||||
28
src/main/java/nlib/cmm/service/impl/CodeDAO.java
Normal file
28
src/main/java/nlib/cmm/service/impl/CodeDAO.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
package nlib.cmm.service.impl;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import nlib.cmm.web.MainController;
|
||||||
|
import nlib.restful.DataApi;
|
||||||
|
import nlib.restful.service.DataApiReqVO;
|
||||||
|
import nlib.restful.service.DataApiResVO;
|
||||||
|
|
||||||
|
@Repository("codeDAO")
|
||||||
|
public class CodeDAO extends DataApi
|
||||||
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(CodeDAO.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 주 자원의 URI
|
||||||
|
*/
|
||||||
|
public static final String RESOURCE_URI = "/uac/service/code/list";
|
||||||
|
|
||||||
|
public DataApiResVO listCodes(DataApiReqVO reqVO) {
|
||||||
|
reqVO.setReqUrl(RESOURCE_URI + "/" + reqVO.getInfoItem("codeUpperId"));
|
||||||
|
return get(reqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
25
src/main/java/nlib/cmm/service/impl/CodeServiceImpl.java
Normal file
25
src/main/java/nlib/cmm/service/impl/CodeServiceImpl.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
package nlib.cmm.service.impl;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import nlib.cmm.service.CodeService;
|
||||||
|
import nlib.restful.service.DataApiReqVO;
|
||||||
|
import nlib.restful.service.DataApiResVO;
|
||||||
|
|
||||||
|
@Service("codeService")
|
||||||
|
public class CodeServiceImpl implements CodeService
|
||||||
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(CodeServiceImpl.class);
|
||||||
|
|
||||||
|
@Resource(name="codeDAO")
|
||||||
|
private CodeDAO codeDAO;
|
||||||
|
|
||||||
|
public DataApiResVO listCodes(DataApiReqVO reqVO) {
|
||||||
|
return codeDAO.listCodes(reqVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
87
src/main/java/nlib/cmm/web/CodeController.java
Normal file
87
src/main/java/nlib/cmm/web/CodeController.java
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
package nlib.cmm.web;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import nlib.cmm.NlibCommonController;
|
||||||
|
import nlib.cmm.service.CodeService;
|
||||||
|
import nlib.restful.service.DataApiReqVO;
|
||||||
|
import nlib.restful.service.DataApiResVO;
|
||||||
|
import nlib.util.StringUtil;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class CodeController extends NlibCommonController {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(CodeController.class);
|
||||||
|
|
||||||
|
@Resource(name="codeService")
|
||||||
|
private CodeService codeService;
|
||||||
|
|
||||||
|
@RequestMapping(value="/code/listCodesAjax.do")
|
||||||
|
public ResponseEntity<String> listCodeAjax(HttpServletRequest req,
|
||||||
|
Authentication authentication, @RequestBody Map<String, String> paramMap) {
|
||||||
|
|
||||||
|
String codeSearchKeyword = paramMap.get("codeSearchKeyword");
|
||||||
|
String codePageIndex = paramMap.get("codePageIndex");
|
||||||
|
String codePageSize = paramMap.get("codePageSize");
|
||||||
|
String codeUpperId = paramMap.get("codeUpperId");
|
||||||
|
|
||||||
|
log.debug("listCodeAjax > codeSearchKeyword = " + codeSearchKeyword);
|
||||||
|
log.debug("listCodeAjax > codePageIndex = " + codePageIndex);
|
||||||
|
log.debug("listCodeAjax > codePageSize = " + codePageSize);
|
||||||
|
log.debug("listCodeAjax > codeUpperId = " + codeUpperId);
|
||||||
|
|
||||||
|
//-------------------------------
|
||||||
|
// REQ VO 구성
|
||||||
|
//-------------------------------
|
||||||
|
DataApiReqVO reqVO = new DataApiReqVO();
|
||||||
|
reqVO.setAuthKey(createAuthKey(req, authentication));
|
||||||
|
reqVO.setPageIndex(codePageIndex);
|
||||||
|
reqVO.setPageSize(codePageSize);
|
||||||
|
|
||||||
|
// 추가 정보 설정
|
||||||
|
reqVO.addInfoItem("searchKeyword", codeSearchKeyword);
|
||||||
|
reqVO.addInfoItem("codeUpperId", codeUpperId);
|
||||||
|
|
||||||
|
// 요청
|
||||||
|
DataApiResVO resVO = codeService.listCodes(reqVO);
|
||||||
|
|
||||||
|
//-------------------------------
|
||||||
|
// JSON변환 응답 처리
|
||||||
|
//-------------------------------
|
||||||
|
// JS-GRID 페이징 처리를 포함한 응답값 처리
|
||||||
|
// (1) 페이징을 서버단에서 처리하는 경우 (pagingloading = false)
|
||||||
|
// {data: [{...}],
|
||||||
|
// itemsCount: 255
|
||||||
|
// }
|
||||||
|
// (2) 페이징을 클라이언트에서 처리하는 경우 (pagingloading = true)
|
||||||
|
// {data: [{...}],
|
||||||
|
// itemsCount: 255
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 코드 페이징 사이즈값이 없거나 0인 경우, 서버에서 페이징 처리하지 않고 전체 데이터 전송
|
||||||
|
if(StringUtil.isEmpty(codePageSize) || Integer.parseInt(codePageSize) <= 0) {
|
||||||
|
return makeResponseEntityJson(resVO.getList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 코드 페이징 처리되는 경우
|
||||||
|
HashMap<String, Object> retMap = new HashMap<String, Object>();
|
||||||
|
retMap.put("data", resVO.getList());
|
||||||
|
retMap.put("itemsCount", resVO.getRecordTotCount());
|
||||||
|
|
||||||
|
return makeResponseEntityJson(retMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -55,12 +55,12 @@
|
|||||||
|
|
||||||
<!-- 검색조건 -->
|
<!-- 검색조건 -->
|
||||||
<select name="pageSize" id="pageSize" title="목록에 보여줄 글 개수">
|
<select name="pageSize" id="pageSize" title="목록에 보여줄 글 개수">
|
||||||
<option value="10">10개씩 보기</option>
|
<c:forEach var="pageSizeItem" items="${pageSizeCodes}" varStatus="status">
|
||||||
<option value="50">50개씩 보기</option>
|
<option value="<c:out value="${pageSizeItem.code }" />" <c:if test="${pageSizeItem.code == pageSize }">selected</c:if> ><c:out value="${pageSizeItem.name }" /></option>
|
||||||
<option value="100">100개씩 보기</option>
|
</c:forEach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<input type="text" name="pageIndex" id="pageIndex" title="페이지번호" value="1" size="5" maxlength="5" />
|
<input type="text" name="pageIndex" id="pageIndex" title="페이지번호" value="${pageIndex }" size="5" maxlength="5" />
|
||||||
<input type="text" name="searchKeyword" id="searchKeyword" title="검색어" value="${searchKeyword }" size="35" maxlength="50" />
|
<input type="text" name="searchKeyword" id="searchKeyword" title="검색어" value="${searchKeyword }" size="35" maxlength="50" />
|
||||||
<input type="button" name="btnSearch" id="btnSearch" value="검색" />
|
<input type="button" name="btnSearch" id="btnSearch" value="검색" />
|
||||||
|
|
||||||
@ -99,14 +99,12 @@ $("#jsGrid").jsGrid({
|
|||||||
|
|
||||||
controller: {
|
controller: {
|
||||||
loadData: function (filter) {
|
loadData: function (filter) {
|
||||||
|
|
||||||
var data = $.Deferred();
|
var data = $.Deferred();
|
||||||
|
|
||||||
//======================================
|
//======================================
|
||||||
// 요청 정보 구성 : 시작 (각 요청에 맞게 조정)
|
// 요청 정보 구성 : 시작 (각 요청에 맞게 조정)
|
||||||
//======================================
|
//======================================
|
||||||
var reqUrl = "${pageContext.request.contextPath}/board/listQnAsAjax.do";
|
var reqUrl = "${pageContext.request.contextPath}/board/listQnAsAjax.do";
|
||||||
|
|
||||||
var searchKeyword = document.articleForm.searchKeyword.value;
|
var searchKeyword = document.articleForm.searchKeyword.value;
|
||||||
//var pageIndex = document.articleForm.pageIndex.value;
|
//var pageIndex = document.articleForm.pageIndex.value;
|
||||||
var pageIndex = filter.pageIndex;
|
var pageIndex = filter.pageIndex;
|
||||||
@ -130,7 +128,11 @@ $("#jsGrid").jsGrid({
|
|||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: JSON.stringify(inputData),
|
data: JSON.stringify(inputData),
|
||||||
}).done(function(response){
|
}).done(function(response){
|
||||||
// 그리드 데이터 예시 : [{ "articleNo": 1, "articleType": "01" }, { "articleNo": 2, "articleType": "02" }]
|
<%
|
||||||
|
// 그리드 데이터 예시 :
|
||||||
|
// (1) 페이징 클라이언트에서 수행하는 경우(pageloading = false) : [{ "articleNo": 1, "articleType": "01" }, { "articleNo": 2, "articleType": "02" }]
|
||||||
|
// (2) 페이징 서버에서 수행하는 경우(pageloading = true) : {data: [{...}], itemsCount: 255}
|
||||||
|
%>
|
||||||
data.resolve(JSON.parse(response));
|
data.resolve(JSON.parse(response));
|
||||||
});
|
});
|
||||||
return data.promise();
|
return data.promise();
|
||||||
@ -162,6 +164,18 @@ $("#jsGrid").jsGrid({
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#pageSize").on("change", function(e) {
|
||||||
|
//alert(e.target.value);
|
||||||
|
//$("#jsGrid").jsGrid("option", "pageIndex", 1).("option", "pageSize", e.target.value);
|
||||||
|
//$("#jsGrid").jsGrid("loadData", {"pageIndex":2,"pageSize":50});
|
||||||
|
//fn_search_article();
|
||||||
|
//$("#jsGrid").controller.loadData({"pageIndex":2,"pageSize":50});
|
||||||
|
//$("#jsGrid").jsGrid("loadData()");
|
||||||
|
$("#jsGrid").jsGrid("search", {'pageIndex':'2','pageSize':e.target.value});
|
||||||
|
//$("#jsGrid").jsGrid("search", {'pageIndex':2,'pageSize':50});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#jsGrid").jsGrid("option", "pageIndex", $("#pageIndex").val(), "pageSize", $("#pageSize").val());
|
||||||
|
|
||||||
// 선택한 게시글 상세 보기로 이동
|
// 선택한 게시글 상세 보기로 이동
|
||||||
function fn_view_detail(articleNo) {
|
function fn_view_detail(articleNo) {
|
||||||
@ -170,8 +184,11 @@ function fn_view_detail(articleNo) {
|
|||||||
$("#articleForm").submit();
|
$("#articleForm").submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fn_search_article() {
|
||||||
|
$("#jsGrid").jsGrid("loadData");
|
||||||
|
}
|
||||||
|
|
||||||
function fn_search_article() {
|
function fn_search_article2() {
|
||||||
var searchKeyword = document.articleForm.searchKeyword.value;
|
var searchKeyword = document.articleForm.searchKeyword.value;
|
||||||
var pageIndex = document.articleForm.pageIndex.value;
|
var pageIndex = document.articleForm.pageIndex.value;
|
||||||
var pageSize = document.articleForm.pageSize.value;
|
var pageSize = document.articleForm.pageSize.value;
|
||||||
@ -183,7 +200,7 @@ function fn_view_detail(articleNo) {
|
|||||||
"pageSize" : pageSize
|
"pageSize" : pageSize
|
||||||
};
|
};
|
||||||
|
|
||||||
//lert(JSON.stringify(inputData));
|
//alert(JSON.stringify(inputData));
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : "${pageContext.request.contextPath}/board/listQnAsAjax.do",
|
url : "${pageContext.request.contextPath}/board/listQnAsAjax.do",
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user