DataApi 공통모듈 수정/보완 및 API서버와의 테스트 수행
This commit is contained in:
parent
a6eeb6a1bd
commit
3358abbc5f
@ -28,61 +28,69 @@ import java.io.Serializable;
|
||||
public class RisVO implements Serializable {
|
||||
|
||||
/* 기존 지역 n 문화 사이트 RIS 항목 */
|
||||
private String TY; /* 참조유형 (ex: BOOK) */
|
||||
private String TI; /* 표제 (ex: 수원사랑 259호) */
|
||||
private String AB; /* 요약 */
|
||||
private String DA; /* 날짜 */
|
||||
private String PY; /* 발행 년도 (YYYY) */
|
||||
private String LA; /* 언어 (ex: Korean) */
|
||||
private String typeDivCd; /* 참조유형 TY */
|
||||
private String title; /* 제목 TI */
|
||||
private String subTitle; /* 부제목 T2 */
|
||||
private String creatYyyy; /* 생산일자 (YYYY) PY */
|
||||
private String keyword; /* 키워드 (ex: 수원사랑) KW */
|
||||
private String UR; /* URL */
|
||||
private String KW; /* 키워드 (ex: 수원사랑) */
|
||||
private String T2; /* 보조제목 (ex: 수원사랑 259호) */
|
||||
private String ER; /* 참조의 끝(비어있고 마지막 태그 여야 함) */
|
||||
|
||||
/*private String AB; 요약
|
||||
private String DA; 날짜
|
||||
private String LA; 언어 (ex: Korean) */
|
||||
|
||||
/* RIS 추가 항목 */
|
||||
private String ID; /* 자료번호 */
|
||||
private String T3; /* 자료제목 */
|
||||
private String masterId; /* 자료번호 ID */
|
||||
private String M3; /* 주제분야명 */
|
||||
private String L4; /* 썸네일이미지 URL */
|
||||
private String M1; /* 관리 번호 */
|
||||
private String PB; /* 저자명 */
|
||||
private String LB; /* 상표 */
|
||||
private String rprsThumbUrl; /* 썸네일이미지 URL L4 */
|
||||
private String stakrmMngNo; /* 관리번호 M1 */
|
||||
private String producer; /* 생산자(저자) A1 */
|
||||
private String orgNm; /* 생산기관명 PP */
|
||||
|
||||
public String getTY() {
|
||||
return TY;
|
||||
public String getTypeDivCd() {
|
||||
return typeDivCd;
|
||||
}
|
||||
public void setTY(String tY) {
|
||||
TY = tY;
|
||||
public String getTy() {
|
||||
return typeDivCd;
|
||||
}
|
||||
public String getTI() {
|
||||
return TI;
|
||||
public void setTypeDivCd(String typeDivCd) {
|
||||
this.typeDivCd = typeDivCd;
|
||||
}
|
||||
public void setTI(String tI) {
|
||||
TI = tI;
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public String getAB() {
|
||||
return AB;
|
||||
public String getTt() {
|
||||
return title;
|
||||
}
|
||||
public void setAB(String aB) {
|
||||
AB = aB;
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public String getDA() {
|
||||
return DA;
|
||||
public String getSubTitle() {
|
||||
return subTitle;
|
||||
}
|
||||
public void setDA(String dA) {
|
||||
DA = dA;
|
||||
public String getT2() {
|
||||
return subTitle;
|
||||
}
|
||||
public String getPY() {
|
||||
return PY;
|
||||
public void setSubTitle(String subTitle) {
|
||||
this.subTitle = subTitle;
|
||||
}
|
||||
public void setPY(String pY) {
|
||||
PY = pY;
|
||||
public String getCreatYyyy() {
|
||||
return creatYyyy;
|
||||
}
|
||||
public String getLA() {
|
||||
return LA;
|
||||
public String getPy() {
|
||||
return creatYyyy;
|
||||
}
|
||||
public void setLA(String lA) {
|
||||
LA = lA;
|
||||
public void setCreatYyyy(String creatYyyy) {
|
||||
this.creatYyyy = creatYyyy;
|
||||
}
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
public String getKw() {
|
||||
return keyword;
|
||||
}
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
public String getUR() {
|
||||
return UR;
|
||||
@ -90,35 +98,14 @@ public class RisVO implements Serializable {
|
||||
public void setUR(String uR) {
|
||||
UR = uR;
|
||||
}
|
||||
public String getKW() {
|
||||
return KW;
|
||||
public String getMasterId() {
|
||||
return masterId;
|
||||
}
|
||||
public void setKW(String kW) {
|
||||
KW = kW;
|
||||
public String getId() {
|
||||
return masterId;
|
||||
}
|
||||
public String getT2() {
|
||||
return T2;
|
||||
}
|
||||
public void setT2(String t2) {
|
||||
T2 = t2;
|
||||
}
|
||||
public String getER() {
|
||||
return ER;
|
||||
}
|
||||
public void setER(String eR) {
|
||||
ER = eR;
|
||||
}
|
||||
public String getID() {
|
||||
return ID;
|
||||
}
|
||||
public void setID(String iD) {
|
||||
ID = iD;
|
||||
}
|
||||
public String getT3() {
|
||||
return T3;
|
||||
}
|
||||
public void setT3(String t3) {
|
||||
T3 = t3;
|
||||
public void setMasterId(String masterId) {
|
||||
this.masterId = masterId;
|
||||
}
|
||||
public String getM3() {
|
||||
return M3;
|
||||
@ -126,30 +113,40 @@ public class RisVO implements Serializable {
|
||||
public void setM3(String m3) {
|
||||
M3 = m3;
|
||||
}
|
||||
public String getL4() {
|
||||
return L4;
|
||||
public String getRprsThumbUrl() {
|
||||
return rprsThumbUrl;
|
||||
}
|
||||
public void setL4(String l4) {
|
||||
L4 = l4;
|
||||
public String getL4() {
|
||||
return rprsThumbUrl;
|
||||
}
|
||||
public void setRprsThumbUrl(String rprsThumbUrl) {
|
||||
this.rprsThumbUrl = rprsThumbUrl;
|
||||
}
|
||||
public String getStakrmMngNo() {
|
||||
return stakrmMngNo;
|
||||
}
|
||||
public String getM1() {
|
||||
return M1;
|
||||
return stakrmMngNo;
|
||||
}
|
||||
public void setM1(String m1) {
|
||||
M1 = m1;
|
||||
public void setStakrmMngNo(String stakrmMngNo) {
|
||||
this.stakrmMngNo = stakrmMngNo;
|
||||
}
|
||||
public String getPB() {
|
||||
return PB;
|
||||
public String getProducer() {
|
||||
return producer;
|
||||
}
|
||||
public void setPB(String pB) {
|
||||
PB = pB;
|
||||
public String getA1() {
|
||||
return producer;
|
||||
}
|
||||
public String getLB() {
|
||||
return LB;
|
||||
public void setProducer(String producer) {
|
||||
this.producer = producer;
|
||||
}
|
||||
public void setLB(String lB) {
|
||||
LB = lB;
|
||||
public String getOrgNm() {
|
||||
return orgNm;
|
||||
}
|
||||
public String getPp() {
|
||||
return orgNm;
|
||||
}
|
||||
public void setOrgNm(String orgNm) {
|
||||
this.orgNm = orgNm;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -2,20 +2,12 @@ package nlib.restful;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import nlib.restful.service.DataApiReqVO;
|
||||
import nlib.restful.service.DataApiResVO;
|
||||
import nlib.restful.service.impl.DataApiTempXml;
|
||||
import nlib.util.StringUtil;
|
||||
import nlib.restful.service.impl.DataApiRESTful;
|
||||
|
||||
|
||||
/**
|
||||
@ -45,49 +37,14 @@ import nlib.util.StringUtil;
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
public class DataApi extends DataApiTempXml {
|
||||
@Repository("dataApi")
|
||||
public class DataApi extends DataApiRESTful { // RESTFul 서버에 접속하여 요청/응답처리를 수행하는 경우
|
||||
//public class DataApi extends DataApiTempXml { // 로컬파일에서 읽어와서 요청/응답처리를 수행하는 경우
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DataApi.class);
|
||||
|
||||
/**
|
||||
* 조회
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO get(DataApiReqVO reqVO) {
|
||||
|
||||
return super.get(reqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 등록
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO put(DataApiReqVO reqVO) {
|
||||
return super.put(reqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 수정
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO post(DataApiReqVO reqVO) {
|
||||
return super.post(reqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 삭제
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO delete (DataApiReqVO reqVO) {
|
||||
return super.delete(reqVO);
|
||||
public DataApiResVO request(DataApiReqVO reqVO) {
|
||||
return super.request(reqVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,13 +1,19 @@
|
||||
package nlib.restful.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import nlib.util.StringUtil;
|
||||
|
||||
@ -37,38 +43,6 @@ public interface DataApiInterface {
|
||||
|
||||
static final Logger log = LoggerFactory.getLogger(DataApiInterface.class);
|
||||
|
||||
/**
|
||||
* 조회
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO get(DataApiReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 등록
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO put(DataApiReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 수정
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO post(DataApiReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 삭제
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO delete (DataApiReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 실제 RESTful API 서버로 요청을 전송하고, 응답받은 자료를 응답VO에 담아서 리턴한다.
|
||||
*
|
||||
@ -76,40 +50,47 @@ public interface DataApiInterface {
|
||||
* @param method
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO send(DataApiReqVO reqVO, HttpMethod method);
|
||||
public DataApiResVO request(DataApiReqVO reqVO);
|
||||
|
||||
|
||||
/**
|
||||
* 요청 VO를 Map 형태로 변환한다.
|
||||
* [POST용] 요청 VO의 입력변수값을 API 요청을 위한 MultiValueMap 형태로 변환한다.
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public static MultiValueMap<String, String> makeParamMap(DataApiReqVO reqVO) {
|
||||
public static MultiValueMap<String, String> makeRequestParamMultiValueMap(DataApiReqVO reqVO) {
|
||||
|
||||
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
|
||||
|
||||
// 공통
|
||||
map.add("rows", "" + reqVO.getPageSize());
|
||||
map.add("page", "" + reqVO.getPageIndex());
|
||||
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
|
||||
|
||||
// 추가 정보
|
||||
if(reqVO.hasInfo()) {
|
||||
HashMap<String, Object> info = reqVO.getInfo();
|
||||
HashMap<String, String> info = reqVO.getInfo();
|
||||
for(String key : info.keySet()) {
|
||||
Object val = info.get(key);
|
||||
if(val instanceof HashMap) {
|
||||
HashMap<String, String> subInfo = (HashMap)val;
|
||||
for(String subKey : subInfo.keySet()) {
|
||||
String subVal = subInfo.get(subKey);
|
||||
map.add(subKey, subVal);
|
||||
}
|
||||
} else {
|
||||
map.add(key, (String)val);
|
||||
}
|
||||
String val = info.get(key);
|
||||
map.add(key, val);
|
||||
}
|
||||
}
|
||||
|
||||
if(reqVO.hasList()) {
|
||||
HashMap<String,List<HashMap<String,String>>> listMap = reqVO.getListMap();
|
||||
if(listMap != null) {
|
||||
for(String listName : listMap.keySet() ) {
|
||||
List<HashMap<String,String>> list = listMap.get(listName);
|
||||
|
||||
// 목록변수명은 있으나, 값이 없는 경우, 빈 배열 JSON값 설정
|
||||
if(list == null || list.size() < 1) {
|
||||
map.add(listName, "[]");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 목록변수명에 대한 목록 자료 존재하는 경우, JSON 생성 처리
|
||||
map.add(listName, makeJsonStrFromListMap(list));
|
||||
|
||||
} // for
|
||||
} // if(listMap != null)
|
||||
} // if(reqVO.hasList())
|
||||
|
||||
// 요청 파라메타 확인
|
||||
for(String key : map.keySet()) {
|
||||
log.debug("MultiValueMap > " + key + "=" + map.get(key));
|
||||
@ -118,13 +99,104 @@ public interface DataApiInterface {
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* [GET용] 요청 VO의 입력변수값을 API 요청을 위한 URL 쿼리 형태의 문자열로 리턴한다.
|
||||
*
|
||||
* @param url
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public static String makeRequestParamUrl(String url, DataApiReqVO reqVO) {
|
||||
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url);
|
||||
|
||||
// 추가 정보
|
||||
if(reqVO.hasInfo()) {
|
||||
HashMap<String, String> info = reqVO.getInfo();
|
||||
for(String key : info.keySet()) {
|
||||
Object val = info.get(key);
|
||||
builder.queryParam(key, (String)val);
|
||||
}
|
||||
}
|
||||
|
||||
if(reqVO.hasList()) {
|
||||
HashMap<String,List<HashMap<String,String>>> listMap = reqVO.getListMap();
|
||||
if(listMap != null) {
|
||||
for(String listName : listMap.keySet() ) {
|
||||
List<HashMap<String,String>> list = listMap.get(listName);
|
||||
|
||||
// 목록변수명은 있으나, 값이 없는 경우, 빈 배열 JSON값 설정
|
||||
if(list == null || list.size() < 1) {
|
||||
builder.queryParam(listName, "[]");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 목록변수명에 대한 목록 자료 존재하는 경우, JSON 생성 처리
|
||||
builder.queryParam(listName, makeJsonStrFromListMap(list));
|
||||
|
||||
} // for
|
||||
} // if(listMap != null)
|
||||
} // if(reqVO.hasList())
|
||||
|
||||
log.debug("makeRequestParamUrl > queryUrl = " + builder.toUriString());
|
||||
|
||||
return builder.toUriString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청전 공통 입력 파라메터를 확인한다.
|
||||
* HashMap를 목록의 요소로 하는 리스트를 받아서 해당 요소들의 배열을 가진 JSON 객체 문자열을 생성하여 리턴한다.
|
||||
* 예 : [{"name":"James", "city":"Miracle", ...}, ..., {"name":"James", "city":"Miracle", ...}]
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public static String makeJsonStrFromListMap(List<HashMap<String,String>> list) {
|
||||
|
||||
// 목록변수명은 있으나, 값이 없는 경우, 빈 배열 JSON값 설정
|
||||
if(list == null || list.size() < 1) {
|
||||
return "[]";
|
||||
}
|
||||
|
||||
// 목록변수명에 대한 목록 자료 존재하는 경우, JSON 생성 처리
|
||||
String jsonListStr = "";
|
||||
for(int i=0; i<list.size(); i++) {
|
||||
HashMap<String, String> record = list.get(i);
|
||||
|
||||
String jsonRecordStr = makeJsonStrFromMap(record);
|
||||
if(StringUtil.isEmpty(jsonRecordStr)) continue;
|
||||
|
||||
if(jsonListStr.length() > 0) jsonListStr += ",";
|
||||
jsonListStr += jsonRecordStr;
|
||||
}
|
||||
return "[" + jsonListStr + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* HashMap을 받아서 해당 요소들을 맴버변수로 하는 JSON객체 문자열을 생성하여 리턴한다.
|
||||
* 예 : {"name":"James", "city":"Miracle", ...}
|
||||
*
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
public static String makeJsonStrFromMap(HashMap<String,String> record) {
|
||||
if(record == null || record.size() < 1) return null;
|
||||
|
||||
String jsonRecordStr = "";
|
||||
for(String subKey : record.keySet()) {
|
||||
String subVal = record.get(subKey);
|
||||
if(jsonRecordStr.length() > 0) jsonRecordStr += ",";
|
||||
jsonRecordStr += "\"" + subKey + ":" + (subVal == null? "null" : "\"" + subVal + "\"");
|
||||
}
|
||||
|
||||
return "{" + jsonRecordStr + "}";
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청전 공통 필수 입력 매개변수를 체크하여 결과를 리턴한다.
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
* @throws Exception :
|
||||
*/
|
||||
public static DataApiResVO checkReqCommonParams(DataApiReqVO reqVO) throws Exception {
|
||||
|
||||
@ -136,6 +208,10 @@ public interface DataApiInterface {
|
||||
return new DataApiResVO("ERR_NO_RURL", "데이터 요청 업무ID에 대한 URL/RUI 정보가 존재하지 않습니다.");
|
||||
}
|
||||
|
||||
if(reqVO.getReqMethod() == null) {
|
||||
return new DataApiResVO("ERR_NO_METHOD", "데이터 요청 방식 정보가 존재하지 않습니다.");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -162,75 +238,37 @@ public interface DataApiInterface {
|
||||
Map<String, Object> map = null;
|
||||
|
||||
try {
|
||||
map = XmlConverter.convert(xmlStr);
|
||||
map = XmlConverter.convert(xmlStr, DataApiVO.XML_EL_NAME_ROOT_NAME);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
resVO.setResultCode("ERR_RES_XML_FORMAT");
|
||||
resVO.setResultMessage(String.format("올바르지 않은 XML 형식의 응답입니다. : [%s]", xmlStr));
|
||||
|
||||
log.error("convertXmlToResVO > " + resVO.getResultMessage());
|
||||
e.printStackTrace();
|
||||
return resVO;
|
||||
}
|
||||
|
||||
// 처리결과 확인
|
||||
String commonKeyList = "|resulttype|code|message|page|totpages|records|".toLowerCase();
|
||||
String lowerKey = null;
|
||||
List<HashMap<String, String>> recordList = null;
|
||||
for( String key : map.keySet()) {
|
||||
|
||||
lowerKey = key.toLowerCase();
|
||||
if(commonKeyList.contains("|" + lowerKey + "|")) {
|
||||
|
||||
if(lowerKey.equals("resulttype")) {
|
||||
String resultType = (String)map.get(key);
|
||||
if(!StringUtil.isEmpty(resultType) && resultType.toLowerCase().compareTo("success") == 0) {
|
||||
resVO.setResultCode("S0000");
|
||||
}
|
||||
}
|
||||
|
||||
if(lowerKey.equals("code")) {
|
||||
String code = (String)map.get(key);
|
||||
int codeInt = 0;
|
||||
try {
|
||||
codeInt = Integer.parseInt(code);
|
||||
|
||||
if(codeInt != 0) {
|
||||
resVO.setResultCode(String.format("ERR_BIZERR(%s)", code));
|
||||
} else {
|
||||
resVO.setResultCode("S0000");
|
||||
}
|
||||
} catch(Exception e) {
|
||||
if(StringUtil.isNotEmpty(code) && code.startsWith("S")) {
|
||||
codeInt = 0;
|
||||
resVO.setResultCode("S0000");
|
||||
} else {
|
||||
resVO.setResultCode(String.format("ERR_BIZERR(%s)", code));
|
||||
log.error("회신 code 정보를 정수로 변환처리 중 오류가 발생하였습니다." + e.toString());
|
||||
codeInt = -1;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(lowerKey.equals("message")) {
|
||||
resVO.setResultMessage((String)map.get(key));
|
||||
}
|
||||
|
||||
if(lowerKey.equals("page")) {
|
||||
resVO.setPageIndex(StringUtil.toNumber((String)map.get(key)));
|
||||
}
|
||||
|
||||
if(lowerKey.equals("totpages")) {
|
||||
resVO.setPageLastIndex(StringUtil.toNumber((String)map.get(key)));
|
||||
}
|
||||
|
||||
if(lowerKey.equals("records")) {
|
||||
resVO.setRecordTotCount(StringUtil.toNumber((String)map.get(key), 0));
|
||||
}
|
||||
} else {
|
||||
if(resVO.getInfo() == null) resVO.setInfo(new HashMap<String,Object>());
|
||||
HashMap<String,Object> info = resVO.getInfo();
|
||||
info.put(key, map.get(key));
|
||||
}
|
||||
if(key.equalsIgnoreCase(DataApiVO.XML_EL_NAME_RESULT_CODE)) resVO.setResultCode((String)map.get(key));
|
||||
else if(key.equalsIgnoreCase(DataApiVO.XML_EL_NAME_RESULT_MESSAGE)) resVO.setResultMessage((String)map.get(key));
|
||||
else if(key.equalsIgnoreCase(DataApiVO.XML_EL_NAME_RECORD)) {
|
||||
// 다건 목록 데이터인 경우
|
||||
Object obj = map.get(DataApiVO.XML_EL_NAME_RECORD);
|
||||
if(obj instanceof HashMap) {
|
||||
// 맵인 경우, 리스트형식으로 저장 처리
|
||||
List<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>();
|
||||
list.add((HashMap)obj);
|
||||
resVO.setList(DataApiVO.XML_EL_NAME_RECORD, list);
|
||||
} else if(obj instanceof List) {
|
||||
resVO.setList(DataApiVO.XML_EL_NAME_RECORD, (List)obj);
|
||||
} else {
|
||||
resVO.setResultCode("ERR_RES_XML_FORMAT_RECORD");
|
||||
resVO.setResultMessage(DataApiVO.XML_EL_NAME_RECORD + " 요소가 알수 없는 형식으로 객체화되었습니다. 확인바랍니다. : " + obj.toString());
|
||||
log.error("convertXmlToResVO > " + resVO.getResultMessage());
|
||||
return resVO;
|
||||
}
|
||||
} else resVO.putInfoItem(key, (String)map.get(key));
|
||||
}
|
||||
|
||||
return resVO;
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
package nlib.restful.service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import nlib.cmm.crypto.AriaCrypto;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
@ -26,104 +25,52 @@ import java.util.Map;
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
public class DataApiReqVO {
|
||||
public class DataApiReqVO extends DataApiVO {
|
||||
|
||||
public static final int DEFAULT_PAGE_SIZE = 10;
|
||||
public static final int DEFAULT_PAGE_INDEX = 1;
|
||||
|
||||
/* 페이징 정보 */
|
||||
private int pageIndex = 0; /* 요청 페이지 번호 */
|
||||
private int pageSize = 0; /* 페이지별 표출할 레코드 수 */
|
||||
|
||||
/* 기본정보 */
|
||||
private HashMap<String, Object> info = null;
|
||||
|
||||
public boolean hasInfo() {
|
||||
return (info != null && info.size() > 0);
|
||||
}
|
||||
|
||||
/* 요청업무ID 및 처리URI */
|
||||
int reqMethod; /* 요청메소드구분값 */
|
||||
String reqUrl; /* 요청업무ID에 대한 통합시스템의 응답 처리 프로그램 URI */
|
||||
|
||||
// GET/SET
|
||||
|
||||
public int getPageIndex() {
|
||||
return (pageIndex < 1 ? DEFAULT_PAGE_INDEX : pageIndex);
|
||||
}
|
||||
|
||||
public void setPageIndex(int pageIndex) {
|
||||
this.pageIndex = pageIndex;
|
||||
}
|
||||
|
||||
public void setPageIndex(String pageIndex) {
|
||||
try {
|
||||
this.pageIndex = Integer.parseInt(pageIndex);
|
||||
} catch(Exception e) {
|
||||
this.pageIndex = DEFAULT_PAGE_INDEX;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return (pageSize < 1 ? DEFAULT_PAGE_SIZE : pageSize);
|
||||
}
|
||||
|
||||
public void setPageSize(String pageSize) {
|
||||
try {
|
||||
this.pageSize = Integer.parseInt(pageSize);
|
||||
} catch(Exception e) {
|
||||
this.pageSize = DEFAULT_PAGE_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
public void setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(HashMap<String, Object> info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getReqUrl() {
|
||||
return reqUrl;
|
||||
}
|
||||
public void setReqUrl(String reqUrl) {
|
||||
this.reqUrl = reqUrl;
|
||||
/**
|
||||
* 메소드를 GET으로 기본설정하여 객체 생성하는 생성자
|
||||
*/
|
||||
public DataApiReqVO() {
|
||||
this(null, HttpMethod.GET);
|
||||
}
|
||||
|
||||
public int getReqMethod() {
|
||||
return reqMethod;
|
||||
/**
|
||||
* 요청 URL을 받아 객체 생성하는 생성자
|
||||
* 메소드는 GET으로 설정된다.
|
||||
*
|
||||
* @param reqUrl
|
||||
*/
|
||||
public DataApiReqVO(String reqUrl) {
|
||||
this(reqUrl, HttpMethod.GET);
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청 URL과 메소드를 받아 객체 생성하는 생성자
|
||||
*
|
||||
* @param reqUrl
|
||||
* @param reqMethod
|
||||
*/
|
||||
public DataApiReqVO(String reqUrl, HttpMethod reqMethod) {
|
||||
this.reqUrl = reqUrl;
|
||||
this.reqMethod = reqMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* 사용자ID 값을 디코딩하여 리턴한다.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getMbInfoIdWithDec() {
|
||||
return AriaCrypto.decode(getMbInfoId());
|
||||
}
|
||||
|
||||
public void setReqMethod(int reqMethod) {
|
||||
this.reqMethod = reqMethod;
|
||||
}
|
||||
|
||||
public void addInfoItem(String key, String value) {
|
||||
if(key == null) return;
|
||||
|
||||
if(info == null) info = new HashMap<String, Object>();
|
||||
|
||||
info.put(key, value);
|
||||
}
|
||||
|
||||
public String getInfoItem(String key) {
|
||||
if(key == null) return null;
|
||||
if(info == null) return null;
|
||||
|
||||
return (String)info.get(key);
|
||||
}
|
||||
|
||||
public void removeInfoItem(String key) {
|
||||
if(key == null) return;
|
||||
if(info == null) return;
|
||||
|
||||
info.remove(key);
|
||||
/**
|
||||
* 사용자ID를 인코딩하여 설정한다.
|
||||
*
|
||||
* @param mbInfoId
|
||||
*/
|
||||
public void setMbInfoIdWithEnc(String mbInfoId) {
|
||||
setMbInfoId(mbInfoId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
package nlib.restful.service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import nlib.util.StringUtil;
|
||||
|
||||
/**
|
||||
@ -28,17 +24,21 @@ import nlib.util.StringUtil;
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
public class DataApiResVO {
|
||||
public class DataApiResVO extends DataApiVO {
|
||||
|
||||
/**
|
||||
* 생성자
|
||||
*
|
||||
* @param resultCode
|
||||
* @param resultMessage
|
||||
*/
|
||||
public DataApiResVO() {
|
||||
super();
|
||||
this.resultCode = null;
|
||||
this.resultMessage = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 생성자
|
||||
* 처리결과 코드와 메시지를 입력받아 객체를 생성하는 생성자
|
||||
*
|
||||
* @param resultCode
|
||||
* @param resultMessage
|
||||
@ -48,24 +48,9 @@ public class DataApiResVO {
|
||||
this.resultMessage = resultMessage;
|
||||
}
|
||||
|
||||
|
||||
/* 처리결과 */
|
||||
String resultCode; /* 결과코드 */
|
||||
String resultMessage; /* 결과내용(오류내용) */
|
||||
|
||||
/* 페이징 정보 */
|
||||
int pageIndex = 0; /* 요청 페이지 번호 (page) */
|
||||
int pageLastIndex = 0; /* 마지막페이지번호 (totPages) */
|
||||
|
||||
/* 기본/추가 정보 */
|
||||
HashMap<String, Object> info = null;
|
||||
|
||||
/* 목록정보 */
|
||||
int recordTotCount = 0; /* 총 레코드수 (records) */
|
||||
|
||||
/**
|
||||
* 응답 처리결과가 성공인지의 여부를 리턴한다.
|
||||
* 결과코드(resultCode)의 값이 "S"로 시작하는 경우 true 리턴한다.
|
||||
* 결과코드(resultCode)의 값이 "S"로 시작하는 경우 true 리턴한다. 이외 false 리턴한다.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ -74,61 +59,4 @@ public class DataApiResVO {
|
||||
return (resultCode.trim().charAt(0) == 'S');
|
||||
}
|
||||
|
||||
// GET/SET
|
||||
|
||||
public String getResultCode() {
|
||||
return resultCode;
|
||||
}
|
||||
public void setResultCode(String resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
public String getResultMessage() {
|
||||
return resultMessage;
|
||||
}
|
||||
public void setResultMessage(String resultMessage) {
|
||||
this.resultMessage = resultMessage;
|
||||
}
|
||||
public int getPageIndex() {
|
||||
return pageIndex;
|
||||
}
|
||||
public void setPageIndex(int pageIndex) {
|
||||
this.pageIndex = pageIndex;
|
||||
}
|
||||
public int getPageLastIndex() {
|
||||
return pageLastIndex;
|
||||
}
|
||||
public void setPageLastIndex(int pageLastIndex) {
|
||||
this.pageLastIndex = pageLastIndex;
|
||||
}
|
||||
public HashMap<String, Object> getInfo() {
|
||||
return info;
|
||||
}
|
||||
public void setInfo(HashMap<String, Object> info) {
|
||||
this.info = info;
|
||||
}
|
||||
public int getRecordTotCount() {
|
||||
return recordTotCount;
|
||||
}
|
||||
public void setRecordTotCount(int recordTotCount) {
|
||||
this.recordTotCount = recordTotCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 반복되는 목록용 리스트 정보를 가져온다.
|
||||
* - RESTful API : "<results>"요소로 반복되는 요소를 반환한다.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<HashMap<String, String>> getList() {
|
||||
if(info == null) return null;
|
||||
return (List<HashMap<String, String>>)info.get("results");
|
||||
}
|
||||
|
||||
|
||||
public String getInfoItem(String key) {
|
||||
if(key == null) return null;
|
||||
if(info == null) return null;
|
||||
|
||||
return (String)info.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
288
src/main/java/nlib/restful/service/DataApiVO.java
Normal file
288
src/main/java/nlib/restful/service/DataApiVO.java
Normal file
@ -0,0 +1,288 @@
|
||||
package nlib.restful.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
import nlib.cmm.crypto.AriaCrypto;
|
||||
import nlib.cmm.service.NlibProperty;
|
||||
import nlib.util.StringUtil;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* @Class Name : DataApiReqVO.java
|
||||
*
|
||||
* @Description : RESTful API 요청 VO
|
||||
*
|
||||
*
|
||||
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @ ------------ -------- ---------------------------
|
||||
* @ 수정일 수정자 수정내용
|
||||
* @ ------------ -------- ---------------------------
|
||||
* @ 2021. 6. 22. KNKIM 최초 생성
|
||||
*
|
||||
*
|
||||
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
||||
* @since 2021. 6. 22.
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
public class DataApiVO {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DataApiVO.class);
|
||||
|
||||
/* 입출력 정보 중 공통 및 특정 항목들에 대한 처리를 위한 API 요소명 */
|
||||
public static final String XML_EL_NAME_ROOT_NAME = "results"; // 결과값 최상위 요소명
|
||||
public static final String XML_EL_NAME_PAGE_SIZE = "rows"; // 페이지크기 : 한페이지에 보여줄 레코드수
|
||||
public static final String XML_EL_NAME_PAGE_INDEX = "page"; // 페이지번호
|
||||
public static final String XML_EL_NAME_PAGE_LAST_INDEX = "totPages"; // 총페이지수
|
||||
public static final String XML_EL_NAME_RECORD_TOT_COUNT = "records"; // 총레코드수
|
||||
public static final String XML_EL_NAME_MB_INFO_ID = "mbInfoId"; // 시스템 내부 사용자ID
|
||||
public static final String XML_EL_NAME_RECORD = "record"; // 다건 목록 자료인 레코드 요소명
|
||||
public static final String XML_EL_NAME_RESULT_CODE = "resultCode"; // 처리결과 코드
|
||||
public static final String XML_EL_NAME_RESULT_MESSAGE = "resultMessage"; // 처리결과 메시지
|
||||
|
||||
/* 페이지 처리 기본값 */
|
||||
public static final int DEFAULT_PAGE_SIZE = NlibProperty.getInt("list.paging.page.size", 10);
|
||||
public static final int DEFAULT_PAGE_INDEX = 1;
|
||||
|
||||
String reqUrl = null; /* 요청업무ID에 대한 통합시스템의 응답 처리 프로그램 URI */
|
||||
HttpMethod reqMethod = HttpMethod.GET; /* 요청메소드구분값 */
|
||||
|
||||
String resultCode; /* 결과코드 */
|
||||
String resultMessage; /* 결과내용(오류내용) */
|
||||
|
||||
HashMap<String, String> info = null; /* 입출력 정보 맵 */
|
||||
HashMap<String, List<HashMap<String, String>>> listMap = null; /* 다건 레코드 리스트를 관리하는 맵 */
|
||||
|
||||
public DataApiVO() {
|
||||
super();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// 정보 항목 관련 IN/OUT 함수
|
||||
//--------------------------------------------------------------
|
||||
public void putInfoItem(String key, String value) {
|
||||
if(StringUtil.isEmpty(key)) return;
|
||||
if(info == null) info = new HashMap<String, String>();
|
||||
|
||||
info.put(key, value);
|
||||
}
|
||||
public String getInfoItem(String key) {
|
||||
return getInfoItem(key, null);
|
||||
}
|
||||
public String getInfoItem(String key, String defValue) {
|
||||
if(StringUtil.isEmpty(key)) return defValue;
|
||||
if(info == null) return defValue;
|
||||
|
||||
String value = info.get(key);
|
||||
|
||||
return StringUtil.isEmpty(value) ? defValue : value;
|
||||
}
|
||||
public void removeInfoItem(String key) {
|
||||
if(StringUtil.isEmpty(key)) return;
|
||||
if(info == null) return;
|
||||
info.remove(key);
|
||||
}
|
||||
public boolean hasInfo() {
|
||||
return (info != null && info.size() > 0);
|
||||
}
|
||||
|
||||
public boolean hasList() {
|
||||
return (listMap != null && listMap.size() > 0);
|
||||
}
|
||||
|
||||
public boolean hasList(String listName) {
|
||||
List list = getList(listName);
|
||||
return (list != null && list.size() > 0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// 다건 레코드관련 함수
|
||||
//--------------------------------------------------------------
|
||||
public void addListItem(String listName, HashMap<String, String> map) {
|
||||
if(StringUtil.isEmpty(listName)) return;
|
||||
List<HashMap<String, String>> list = getList(listName);
|
||||
|
||||
if(list == null) list = new ArrayList<HashMap<String, String>>();
|
||||
list.add(map);
|
||||
setList(listName, list);
|
||||
return;
|
||||
}
|
||||
|
||||
public void removeListItem(String listName, int idx) {
|
||||
if(StringUtil.isEmpty(listName)) return;
|
||||
if(idx < 0) return;
|
||||
|
||||
List<HashMap<String, String>> list = getList(listName);
|
||||
if(list != null && list.size() > idx) list.remove(idx);
|
||||
return;
|
||||
}
|
||||
|
||||
public void clearList(String listName) {
|
||||
if(StringUtil.isEmpty(listName)) return;
|
||||
|
||||
List<HashMap<String, String>> list = getList(listName);
|
||||
if(list != null) list.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
public List<HashMap<String, String>> getList(String listName) {
|
||||
if(StringUtil.isEmpty(listName)) return null;
|
||||
if(listMap == null && listMap.size() < 1) return null;
|
||||
|
||||
return listMap.get(listName);
|
||||
}
|
||||
|
||||
public void setList(String listName, List<HashMap<String, String>> list) {
|
||||
if(StringUtil.isEmpty(listName)) return;
|
||||
if(listMap == null) initList();
|
||||
|
||||
List<HashMap<String, String>> listOld = getList(listName);
|
||||
if(listOld != null) listOld.clear();
|
||||
|
||||
listMap.put(listName, list);
|
||||
return;
|
||||
}
|
||||
|
||||
private void initList() {
|
||||
if(listMap == null) listMap = new HashMap<String, List<HashMap<String, String>>>();
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// 페이징 처리 관련
|
||||
//--------------------------------------------------------------
|
||||
public int getPageIndex() {
|
||||
int pageIndex = 0;
|
||||
try {
|
||||
pageIndex = Integer.parseInt(getInfoItem(XML_EL_NAME_PAGE_INDEX, "0"));
|
||||
} catch(Exception e) {
|
||||
log.error("getPageIndex > " + e.toString());
|
||||
return 0;
|
||||
}
|
||||
return pageIndex;
|
||||
}
|
||||
public void setPageIndex(int pageIndex) {
|
||||
setPageIndex("" + pageIndex);
|
||||
}
|
||||
public void setPageIndex(String pageIndex) {
|
||||
putInfoItem("XML_EL_NAME_PAGE_INDEX", pageIndex);
|
||||
}
|
||||
public int getPageLastIndex() {
|
||||
int pageLastIndex = 0;
|
||||
try {
|
||||
pageLastIndex = Integer.parseInt(getInfoItem(XML_EL_NAME_PAGE_LAST_INDEX, "0"));
|
||||
} catch(Exception e) {
|
||||
log.error("getPageLastIndex > " + e.toString());
|
||||
return 0;
|
||||
}
|
||||
return pageLastIndex;
|
||||
}
|
||||
public void setPageLastIndex(int pageLastIndex) {
|
||||
setPageLastIndex("" + pageLastIndex);
|
||||
}
|
||||
public void setPageLastIndex(String pageLastIndex) {
|
||||
putInfoItem("XML_EL_NAME_PAGE_LAST_INDEX", pageLastIndex);
|
||||
}
|
||||
public int getPageSize() {
|
||||
int pageSize = 0;
|
||||
try {
|
||||
pageSize = Integer.parseInt(getInfoItem(XML_EL_NAME_PAGE_SIZE, "0"));
|
||||
} catch(Exception e) {
|
||||
log.error("getPageSize > " + e.toString());
|
||||
return 0;
|
||||
}
|
||||
return pageSize;
|
||||
}
|
||||
public void setPageSize(int pageSize) {
|
||||
setPageSize("" + pageSize);
|
||||
}
|
||||
public void setPageSize(String pageSize) {
|
||||
putInfoItem("XML_EL_NAME_PAGE_SIZE", pageSize);
|
||||
}
|
||||
public int getRecordTotCount() {
|
||||
int recordTotCount = 0;
|
||||
try {
|
||||
recordTotCount = Integer.parseInt(getInfoItem(XML_EL_NAME_RECORD_TOT_COUNT, "0"));
|
||||
} catch(Exception e) {
|
||||
log.error("getRecordTotCount > " + e.toString());
|
||||
return 0;
|
||||
}
|
||||
return recordTotCount;
|
||||
}
|
||||
public void setRecordTotCount(int recordTotCount) {
|
||||
setRecordTotCount("" + recordTotCount);
|
||||
}
|
||||
public void setRecordTotCount(String recordTotCount) {
|
||||
putInfoItem(XML_EL_NAME_RECORD_TOT_COUNT, recordTotCount);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// 사용자ID 처리 관련
|
||||
//--------------------------------------------------------------
|
||||
public String getMbInfoId() {
|
||||
return getInfoItem("XML_EL_NAME_MB_INFO_ID");
|
||||
}
|
||||
public String getEncMbInfoId() {
|
||||
return AriaCrypto.encode(getInfoItem("XML_EL_NAME_MB_INFO_ID"));
|
||||
}
|
||||
public void setMbInfoId(String mbInfoId) {
|
||||
putInfoItem("XML_EL_NAME_MB_INFO_ID", mbInfoId);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// GET & SET
|
||||
//--------------------------------------------------------------
|
||||
public String getReqUrl() {
|
||||
return reqUrl;
|
||||
}
|
||||
|
||||
public void setReqUrl(String reqUrl) {
|
||||
this.reqUrl = reqUrl;
|
||||
}
|
||||
|
||||
public HttpMethod getReqMethod() {
|
||||
return reqMethod;
|
||||
}
|
||||
|
||||
public void setReqMethod(HttpMethod reqMethod) {
|
||||
this.reqMethod = reqMethod;
|
||||
}
|
||||
|
||||
public String getResultCode() {
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
public void setResultCode(String resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
|
||||
public String getResultMessage() {
|
||||
return resultMessage;
|
||||
}
|
||||
|
||||
public void setResultMessage(String resultMessage) {
|
||||
this.resultMessage = resultMessage;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(HashMap<String, String> info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public HashMap<String, List<HashMap<String, String>>> getListMap() {
|
||||
return listMap;
|
||||
}
|
||||
|
||||
}
|
||||
@ -24,7 +24,7 @@ public class XmlConverter {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(XmlConverter.class);
|
||||
|
||||
public static HashMap<String, Object> convert(String xmlStr) throws Exception {
|
||||
public static HashMap<String, Object> convert(String xmlStr, String rootEleName) throws Exception {
|
||||
|
||||
if(xmlStr == null) return null;
|
||||
|
||||
@ -35,7 +35,7 @@ public class XmlConverter {
|
||||
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
|
||||
XMLEventReader eventReader = inputFactory.createXMLEventReader(bIn);
|
||||
|
||||
resMap = getElementValue("result", eventReader, null);
|
||||
resMap = getElementValue(rootEleName, eventReader, null);
|
||||
//log.debug("Converting XML to HashMap : Done >> " + resMap);
|
||||
} catch (XMLStreamException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package nlib.restful.service.impl;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -9,12 +11,13 @@ import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import nlib.restful.service.DataApiInterface;
|
||||
import nlib.restful.service.DataApiReqVO;
|
||||
import nlib.restful.service.DataApiResVO;
|
||||
import nlib.restful.service.DataApiInterface;
|
||||
import nlib.util.StringUtil;
|
||||
|
||||
/**
|
||||
@ -53,48 +56,6 @@ public class DataApiRESTful implements DataApiInterface {
|
||||
@Value("#{properties['dataapi.server.protocol']}")
|
||||
private String DAPI_SERVER_PROTOCOL;
|
||||
|
||||
|
||||
/**
|
||||
* 조회
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO get(DataApiReqVO reqVO) {
|
||||
|
||||
return send(reqVO, HttpMethod.GET);
|
||||
}
|
||||
|
||||
/**
|
||||
* 등록
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO put(DataApiReqVO reqVO) {
|
||||
return send(reqVO, HttpMethod.PUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 수정
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO post(DataApiReqVO reqVO) {
|
||||
return send(reqVO, HttpMethod.POST);
|
||||
}
|
||||
|
||||
/**
|
||||
* 삭제
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO delete (DataApiReqVO reqVO) {
|
||||
return send(reqVO, HttpMethod.DELETE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 실제 RESTful API 서버로 요청을 전송하고, 응답받은 자료를 응답VO에 담아서 리턴한다.
|
||||
*
|
||||
@ -102,42 +63,79 @@ public class DataApiRESTful implements DataApiInterface {
|
||||
* @param method
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO send(DataApiReqVO reqVO, HttpMethod method) {
|
||||
public DataApiResVO request(DataApiReqVO reqVO) {
|
||||
|
||||
log.debug("request > " + reqVO.getReqMethod());
|
||||
|
||||
DataApiResVO resVO = null;
|
||||
|
||||
try {
|
||||
|
||||
//-----------------------------------
|
||||
// 입력값 검증작업
|
||||
//-----------------------------------
|
||||
resVO = DataApiInterface.checkReqCommonParams(reqVO);
|
||||
if(resVO != null) return resVO;
|
||||
if(method == null) return new DataApiResVO("ERR_NO_METHOD", "HTTP 요청 Method가 유효하지 않습니다.");
|
||||
HttpMethod method = reqVO.getReqMethod();
|
||||
|
||||
//-----------------------------------
|
||||
// 폼 파라메터 생성 작업
|
||||
// 폼 파라메터 생성 작업 및 요청 처리
|
||||
//-----------------------------------
|
||||
String url = DAPI_SERVER_PROTOCOL + "://" + DAPI_SERVER_IP + ("80".equals(DAPI_SERVER_PORT) ? "" : ":" + DAPI_SERVER_PORT) + reqVO.getReqUrl();
|
||||
log.debug("REQ URL : " + url);
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||
MultiValueMap<String, String> parameters = DataApiInterface.makeParamMap(reqVO);
|
||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity(parameters, headers);
|
||||
|
||||
ResponseEntity<String> responseEntity = null;
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.getMessageConverters()
|
||||
.add(0, new StringHttpMessageConverter(StandardCharsets.UTF_8));
|
||||
|
||||
if(method == HttpMethod.GET) {
|
||||
HttpEntity requestEntity = new HttpEntity(headers);
|
||||
responseEntity = restTemplate.exchange (DataApiInterface.makeRequestParamUrl(url, reqVO), method, requestEntity, String.class);
|
||||
} else if(method == HttpMethod.POST) {
|
||||
MultiValueMap<String, String> parameters = DataApiInterface.makeRequestParamMultiValueMap(reqVO);
|
||||
parameters.forEach((k, v) -> log.debug("params > " + k + " : " + v));
|
||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity(parameters, headers);
|
||||
responseEntity = restTemplate.postForEntity(url, requestEntity , String.class);
|
||||
} else {
|
||||
String message = "RESTFul API Http Method 설정 오류입니다. : POST, GET 방식만 허용됩니다.";
|
||||
log.error("request > " + message);
|
||||
return DataApiInterface.makeErrorRes("E_ERR_METHOD", message);
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
// 요청 처리
|
||||
//-----------------------------------
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
String url = DAPI_SERVER_PROTOCOL + "://" + DAPI_SERVER_IP + ("80".equals(DAPI_SERVER_PORT) ? "" : ":" + DAPI_SERVER_PORT) + reqVO.getReqUrl();
|
||||
log.debug("REQ URL : " + reqVO.getReqUrl());
|
||||
// RestTemplate restTemplate = new RestTemplate();
|
||||
//restTemplate.setMessageConverters(msgConverters);
|
||||
|
||||
//ResponseEntity<String> responseEntity = restTemplate.exchange(url, method, requestEntity, String.class);
|
||||
// ResponseEntity<String> responseEntity = restTemplate.exchange (url, method, requestEntity, String.class);
|
||||
//ResponseEntity<String> responseEntity = restTemplate.exchange (url, HttpMethod.GET, requestEntity, String.class, parameters);
|
||||
//ResponseEntity<String> responseEntity = restTemplate.postForEntity( url, requestEntity , String.class ); // working well
|
||||
//ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class, parameters); // not working
|
||||
|
||||
/*
|
||||
// GET // OK
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url)
|
||||
.queryParam("mngOrgCd", "SU01")
|
||||
.queryParam("masterId", "UR-408A9832D25C42289D9B1FC81FDA8360")
|
||||
.queryParam("typeDivCd", "IT_MUSE");
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange (builder.toUriString(), method, entity, String.class);
|
||||
*/
|
||||
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange(url, method, requestEntity, String.class);
|
||||
|
||||
//-----------------------------------
|
||||
// 응답 처리
|
||||
//-----------------------------------
|
||||
HttpStatus statusCode = responseEntity.getStatusCode();
|
||||
log.debug("RES StatusCode : " + statusCode);
|
||||
String resultXML = "";
|
||||
resultXML = responseEntity.getBody();
|
||||
String resultXML = responseEntity.getBody();
|
||||
log.debug("RES resultXML : " + resultXML);
|
||||
|
||||
// 응답 자료 객체화
|
||||
@ -145,19 +143,22 @@ public class DataApiRESTful implements DataApiInterface {
|
||||
|
||||
// 처리결과 코드 확인
|
||||
if(StringUtil.isEmpty(resVO.getResultCode())) {
|
||||
String resultMessage = resVO.getResultMessage();
|
||||
if (statusCode == HttpStatus.OK) {
|
||||
resVO.setResultCode("S_HTTP_STATUS_OK");
|
||||
resVO.setResultMessage("정상처리되었습니다.");
|
||||
resVO.setResultMessage(StringUtil.isEmpty(resultMessage) ? "정상처리되었습니다." : resultMessage);
|
||||
} else {
|
||||
resVO.setResultCode("E_STATUS_CODE_FAIL");
|
||||
resVO.setResultMessage(String.format("처리에 실패하였습니다. (HTTP상태코드 : %s)", statusCode.toString()));
|
||||
resVO.setResultMessage(StringUtil.isEmpty(resultMessage) ? String.format("처리에 실패하였습니다. (HTTP상태코드 : %s)", statusCode.toString()) : resultMessage);
|
||||
}
|
||||
}
|
||||
|
||||
//log.debug("RES resVO : " + resVO);
|
||||
log.debug("RES resVO : resultCode = " + resVO.getResultCode());
|
||||
log.debug("RES resVO : resultMessage = " + resVO.getResultMessage());
|
||||
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("request > Exception 발생 : " + e.toString());
|
||||
return DataApiInterface.makeErrorRes("E_REQ_EXCEPTION", e.toString());
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@ import java.nio.charset.StandardCharsets;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@ -19,10 +18,11 @@ import org.springframework.util.MultiValueMap;
|
||||
|
||||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||
|
||||
import nlib.restful.service.DataApiInterface;
|
||||
import nlib.restful.service.DataApiReqVO;
|
||||
import nlib.restful.service.DataApiResVO;
|
||||
import nlib.restful.service.DataApiServerResponseVO;
|
||||
import nlib.restful.service.DataApiInterface;
|
||||
import nlib.restful.service.DataApiVO;
|
||||
import nlib.util.StringUtil;
|
||||
|
||||
/**
|
||||
@ -56,47 +56,6 @@ public class DataApiTempXml implements DataApiInterface {
|
||||
private String DAPI_TEMP_XML_PATH;
|
||||
|
||||
|
||||
/**
|
||||
* 조회
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO get(DataApiReqVO reqVO) {
|
||||
|
||||
return send(reqVO, HttpMethod.GET);
|
||||
}
|
||||
|
||||
/**
|
||||
* 등록
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO put(DataApiReqVO reqVO) {
|
||||
return send(reqVO, HttpMethod.PUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 수정
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO post(DataApiReqVO reqVO) {
|
||||
return send(reqVO, HttpMethod.POST);
|
||||
}
|
||||
|
||||
/**
|
||||
* 삭제
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO delete (DataApiReqVO reqVO) {
|
||||
return send(reqVO, HttpMethod.DELETE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 실제 RESTful API 서버로 요청을 전송하고, 응답받은 자료를 응답VO에 담아서 리턴한다.
|
||||
*
|
||||
@ -104,7 +63,9 @@ public class DataApiTempXml implements DataApiInterface {
|
||||
* @param method
|
||||
* @return
|
||||
*/
|
||||
public DataApiResVO send(DataApiReqVO reqVO, HttpMethod method) {
|
||||
public DataApiResVO request(DataApiReqVO reqVO) {
|
||||
|
||||
log.debug("request > " + reqVO.getReqMethod());
|
||||
|
||||
DataApiResVO resVO = null;
|
||||
|
||||
@ -114,21 +75,20 @@ public class DataApiTempXml implements DataApiInterface {
|
||||
//-----------------------------------
|
||||
resVO = DataApiInterface.checkReqCommonParams(reqVO);
|
||||
if(resVO != null) return resVO;
|
||||
if(method == null) return new DataApiResVO("ERR_NO_METHOD", "HTTP 요청 Method가 유효하지 않습니다.");
|
||||
HttpMethod method = reqVO.getReqMethod();
|
||||
|
||||
//-----------------------------------
|
||||
// 폼 파라메터 생성 작업
|
||||
// 폼 파라메터 생성 작업 (요청데이터 확인용)
|
||||
//-----------------------------------
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
||||
MultiValueMap<String, String> parameters = DataApiInterface.makeParamMap(reqVO);
|
||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity(parameters, headers);
|
||||
MultiValueMap<String, String> parameters = DataApiInterface.makeRequestParamMultiValueMap(reqVO);
|
||||
|
||||
//-----------------------------------
|
||||
// 응답 처리
|
||||
//-----------------------------------
|
||||
HttpStatus statusCode = HttpStatus.OK;
|
||||
String resultXML = getTempDataFromXmlFile(reqVO, method);
|
||||
String resultXML = getTempDataFromXmlFile(reqVO);
|
||||
//log.debug("RES resultXML : " + resultXML);
|
||||
|
||||
// 응답 자료 객체화
|
||||
@ -136,16 +96,18 @@ public class DataApiTempXml implements DataApiInterface {
|
||||
|
||||
// 처리결과 코드 확인
|
||||
if(StringUtil.isEmpty(resVO.getResultCode())) {
|
||||
String resultMessage = resVO.getResultMessage();
|
||||
if (statusCode == HttpStatus.OK) {
|
||||
resVO.setResultCode("S_HTTP_STATUS_OK");
|
||||
resVO.setResultMessage("정상처리되었습니다.");
|
||||
resVO.setResultMessage(StringUtil.isEmpty(resultMessage) ? "정상처리되었습니다." : resultMessage);
|
||||
} else {
|
||||
resVO.setResultCode("E_STATUS_CODE_FAIL");
|
||||
resVO.setResultMessage(String.format("처리에 실패하였습니다. (HTTP상태코드 : %s)", statusCode.toString()));
|
||||
resVO.setResultMessage(StringUtil.isEmpty(resultMessage) ? String.format("처리에 실패하였습니다. (HTTP상태코드 : %s)", statusCode.toString()) : resultMessage);
|
||||
}
|
||||
}
|
||||
|
||||
//log.debug("RES resVO : " + resVO);
|
||||
log.debug("RES resVO : resultCode = " + resVO.getResultCode());
|
||||
log.debug("RES resVO : resultMessage = " + resVO.getResultMessage());
|
||||
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -163,54 +125,55 @@ public class DataApiTempXml implements DataApiInterface {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private String getTempDataFromXmlFile(DataApiReqVO reqVO, HttpMethod method) throws Exception {
|
||||
private String getTempDataFromXmlFile(DataApiReqVO reqVO) throws Exception {
|
||||
|
||||
String fileName = reqVO.getReqUrl().substring(1).replaceAll("/", ".");
|
||||
String xmlPath = DAPI_TEMP_XML_PATH + "/" + fileName + "_" + method.toString().toUpperCase() + ".xml";
|
||||
String returnXmlStr = null;
|
||||
HttpMethod method = reqVO.getReqMethod();
|
||||
String fileName = reqVO.getReqUrl().substring(1).replaceAll("/", ".");
|
||||
String xmlPath = DAPI_TEMP_XML_PATH + "/" + fileName + "_" + method.toString().toUpperCase() + ".xml";
|
||||
String returnXmlStr = null;
|
||||
|
||||
log.info("XML FILE PATH : " + xmlPath);
|
||||
log.info("XML FILE PATH : " + xmlPath);
|
||||
|
||||
|
||||
DataApiServerResponseVO resVO = null;
|
||||
DataApiServerResponseVO resVO = null;
|
||||
|
||||
File xmlFile = new File(xmlPath);
|
||||
if(!xmlFile.exists()) {
|
||||
resVO = new DataApiServerResponseVO("-20", String.format("%s 파일을 찾을 수 없습니다.",xmlPath));
|
||||
File xmlFile = new File(xmlPath);
|
||||
if(!xmlFile.exists()) {
|
||||
resVO = new DataApiServerResponseVO("-20", String.format("%s 파일을 찾을 수 없습니다.",xmlPath));
|
||||
XmlMapper mapper = new XmlMapper();
|
||||
returnXmlStr = mapper.writer().withRootName("result").writeValueAsString(resVO);
|
||||
}
|
||||
|
||||
if(resVO == null && !xmlFile.isFile()) {
|
||||
resVO = new DataApiServerResponseVO("-21", String.format("%s는 파일이어야 합니다.",xmlPath));
|
||||
XmlMapper mapper = new XmlMapper();
|
||||
returnXmlStr = mapper.writer().withRootName(DataApiVO.XML_EL_NAME_ROOT_NAME).writeValueAsString(resVO);
|
||||
}
|
||||
|
||||
if(resVO == null) {
|
||||
StringBuilder strBd = new StringBuilder();
|
||||
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(xmlPath),StandardCharsets.UTF_8))) {
|
||||
|
||||
String line;
|
||||
int i = 0;
|
||||
while ((line = br.readLine()) != null) {
|
||||
strBd.append(line + "\n");
|
||||
}
|
||||
returnXmlStr = strBd.toString();
|
||||
} catch (IOException e) {
|
||||
log.error("XML 파일 읽는 중 오류 발생 : " + e.toString());
|
||||
e.printStackTrace();
|
||||
|
||||
resVO = new DataApiServerResponseVO("-22", String.format("%s 파일을 읽는 중 오류가 발생하였습니다(%s). ",xmlPath, e.toString()));
|
||||
XmlMapper mapper = new XmlMapper();
|
||||
returnXmlStr = mapper.writer().withRootName("result").writeValueAsString(resVO);
|
||||
returnXmlStr = mapper.writer().withRootName(DataApiVO.XML_EL_NAME_ROOT_NAME).writeValueAsString(resVO);
|
||||
}
|
||||
|
||||
if(resVO == null && !xmlFile.isFile()) {
|
||||
resVO = new DataApiServerResponseVO("-21", String.format("%s는 파일이어야 합니다.",xmlPath));
|
||||
XmlMapper mapper = new XmlMapper();
|
||||
returnXmlStr = mapper.writer().withRootName("result").writeValueAsString(resVO);
|
||||
}
|
||||
}
|
||||
|
||||
if(resVO == null) {
|
||||
StringBuilder strBd = new StringBuilder();
|
||||
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(xmlPath),StandardCharsets.UTF_8))) {
|
||||
|
||||
String line;
|
||||
int i = 0;
|
||||
while ((line = br.readLine()) != null) {
|
||||
strBd.append(line + "\n");
|
||||
}
|
||||
returnXmlStr = strBd.toString();
|
||||
} catch (IOException e) {
|
||||
log.error("XML 파일 읽는 중 오류 발생 : " + e.toString());
|
||||
e.printStackTrace();
|
||||
|
||||
resVO = new DataApiServerResponseVO("-22", String.format("%s 파일을 읽는 중 오류가 발생하였습니다(%s). ",xmlPath, e.toString()));
|
||||
XmlMapper mapper = new XmlMapper();
|
||||
returnXmlStr = mapper.writer().withRootName("result").writeValueAsString(resVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//log.info("RESUTN XML STR : " + returnXmlStr);
|
||||
return returnXmlStr;
|
||||
//log.info("RESUTN XML STR : " + returnXmlStr);
|
||||
return returnXmlStr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,4 +29,5 @@ public interface SampleDataApiService {
|
||||
|
||||
public DataApiResVO getSampleInfo(DataApiReqVO reqVO) throws Exception;
|
||||
|
||||
public DataApiResVO getItemInfo(DataApiReqVO reqVO) throws Exception;
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import nlib.restful.DataApi;
|
||||
import nlib.restful.service.DataApiReqVO;
|
||||
import nlib.restful.service.DataApiResVO;
|
||||
import nlib.sample.service.SampleDataApiService;
|
||||
@ -33,12 +34,15 @@ import nlib.sample.service.SampleDataApiService;
|
||||
@Service("sampleDataApiService")
|
||||
public class SampleDataApiServiceImpl implements SampleDataApiService {
|
||||
|
||||
/** SampleDataApiDAO */
|
||||
@Resource(name = "sampleDataApiDAO")
|
||||
private SampleDataApiDAO sampleDataApiDAO;
|
||||
/** RESTFul API 송수신 모듈 */
|
||||
@Resource(name = "dataApi")
|
||||
private DataApi dataApi;
|
||||
|
||||
public DataApiResVO getSampleInfo(DataApiReqVO reqVO) throws Exception {
|
||||
return sampleDataApiDAO.getSampleInfo(reqVO);
|
||||
return dataApi.request(reqVO);
|
||||
}
|
||||
|
||||
public DataApiResVO getItemInfo(DataApiReqVO reqVO) throws Exception {
|
||||
return dataApi.request(reqVO);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,16 +3,22 @@ package nlib.sample.web;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import nlib.cmm.NlibCommonController;
|
||||
import nlib.restful.service.DataApiReqVO;
|
||||
import nlib.restful.service.DataApiResVO;
|
||||
import nlib.restful.service.DataApiVO;
|
||||
import nlib.sample.service.SampleDataApiService;
|
||||
import nlib.user.service.NlibLoginVO;
|
||||
import nlib.util.StringUtil;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
@ -37,7 +43,7 @@ import nlib.sample.service.SampleDataApiService;
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
public class SampleDataApiController {
|
||||
public class SampleDataApiController extends NlibCommonController {
|
||||
|
||||
/** SampleDataApiService */
|
||||
@Resource(name = "sampleDataApiService")
|
||||
@ -80,4 +86,91 @@ public class SampleDataApiController {
|
||||
return "nlib/sample/getSampleInfo";
|
||||
}
|
||||
|
||||
@RequestMapping("/sample/getItemInfo.do")
|
||||
public String getItemInfo(HttpServletRequest request, @RequestParam Map<String, String> commandMap, ModelMap model) throws Exception {
|
||||
|
||||
String message = null;
|
||||
|
||||
DataApiReqVO reqVO = new DataApiReqVO("/uac/service/nlib/col/getItemInfo", HttpMethod.GET);
|
||||
|
||||
String mngOrgCd = commandMap.get("mngOrgCd");
|
||||
String masterId = commandMap.get("masterId");
|
||||
String typeDivCd = commandMap.get("typeDivCd");
|
||||
|
||||
if(StringUtil.isEmpty(mngOrgCd) || StringUtil.isEmpty(masterId) || StringUtil.isEmpty(typeDivCd)) {
|
||||
message = "필수정보값이 입력되지 않았습니다.";
|
||||
model.addAttribute("message", message);
|
||||
return "nlib/sample/getItemInfo";
|
||||
}
|
||||
|
||||
// 변수 설정
|
||||
reqVO.putInfoItem("mngOrgCd", mngOrgCd);
|
||||
reqVO.putInfoItem("masterId", masterId);
|
||||
reqVO.putInfoItem("typeDivCd", typeDivCd);
|
||||
|
||||
// 사용자ID 설정
|
||||
NlibLoginVO nlibLoginVO = getNlibLoginVO(request);
|
||||
if(nlibLoginVO != null && !StringUtil.isEmpty(nlibLoginVO.getMbInfoId())) {
|
||||
reqVO.setMbInfoId(nlibLoginVO.getMbInfoId());
|
||||
}
|
||||
|
||||
// API 호출
|
||||
DataApiResVO resVO = sampleDataApiService.getItemInfo(reqVO);
|
||||
|
||||
// 결과값 전달
|
||||
model.addAttribute("resultCode", resVO.getResultCode());
|
||||
model.addAttribute("resultMessage", resVO.getResultMessage());
|
||||
model.addAttribute("info", resVO.getInfo());
|
||||
|
||||
// 참고 정보 : API 접속 서버 정보
|
||||
model.addAttribute("serverProtocol", dataapiServerIp);
|
||||
model.addAttribute("serverIp", dataapiServerPort);
|
||||
model.addAttribute("serverPort", dataapiServerProtocol);
|
||||
|
||||
return "nlib/sample/getItemInfo";
|
||||
}
|
||||
|
||||
@RequestMapping("/sample/listRentItem.do")
|
||||
public String listRentItem(HttpServletRequest request, @RequestParam Map<String, String> commandMap, ModelMap model) throws Exception {
|
||||
|
||||
String message = null;
|
||||
|
||||
DataApiReqVO reqVO = new DataApiReqVO("/uac/service/nlib/rent/listRentItem", HttpMethod.GET);
|
||||
|
||||
// 변수 설정
|
||||
reqVO.putInfoItem("rows", getParamStr(commandMap, "rows", "10"));
|
||||
reqVO.putInfoItem("page", getParamStr(commandMap, "rows", "1"));
|
||||
reqVO.putInfoItem("mngOrgCd", getParamStr(commandMap, "mngOrgCd", "KCCF"));
|
||||
reqVO.putInfoItem("mbInfoId", getParamStr(commandMap, "mbInfoId", "BDCCAF34CF8AA365C660ADB121CE6741"));
|
||||
|
||||
// 사용자ID 설정
|
||||
// NlibLoginVO nlibLoginVO = getNlibLoginVO(request);
|
||||
// if(nlibLoginVO != null && !StringUtil.isEmpty(nlibLoginVO.getMbInfoId())) {
|
||||
// reqVO.setMbInfoId(nlibLoginVO.getMbInfoId());
|
||||
// }
|
||||
|
||||
// API 호출
|
||||
DataApiResVO resVO = sampleDataApiService.getItemInfo(reqVO);
|
||||
|
||||
// 입력 매개변수 전달
|
||||
model.addAttribute("rows", resVO.getRecordTotCount());
|
||||
model.addAttribute("page", resVO.getPageIndex());
|
||||
model.addAttribute("mngOrgCd", resVO.getInfoItem("mngOrgCd"));
|
||||
model.addAttribute("mbInfoId", resVO.getInfoItem("mbInfoId"));
|
||||
|
||||
// 결과값 전달
|
||||
model.addAttribute("resultCode", resVO.getResultCode());
|
||||
model.addAttribute("resultMessage", resVO.getResultMessage());
|
||||
model.addAttribute("info", resVO.getInfo());
|
||||
model.addAttribute("list", resVO.getList(DataApiVO.XML_EL_NAME_RECORD));
|
||||
|
||||
// 참고 정보 : API 접속 서버 정보
|
||||
model.addAttribute("serverProtocol", dataapiServerIp);
|
||||
model.addAttribute("serverIp", dataapiServerPort);
|
||||
model.addAttribute("serverPort", dataapiServerProtocol);
|
||||
|
||||
return "nlib/sample/listRentItem";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -77,10 +77,12 @@ public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers("/rent/*.do").permitAll()
|
||||
.antMatchers("/collection/*.do").permitAll()
|
||||
.antMatchers("/sample/password/getSampleEncoder.do").permitAll()
|
||||
.antMatchers("/sample/*.do").permitAll()
|
||||
.antMatchers("/*/*Ajax.do").permitAll()
|
||||
.antMatchers("/fileupload/**").permitAll()
|
||||
.antMatchers("/board/**").permitAll()
|
||||
.antMatchers("/inform/**").permitAll()
|
||||
.antMatchers("/test/**").permitAll()
|
||||
.antMatchers("/alert/**").permitAll()
|
||||
.antMatchers("/code/**").permitAll()
|
||||
.antMatchers("/homes/**").permitAll()
|
||||
|
||||
@ -54,11 +54,16 @@ nlib.council.dns.host = nlib
|
||||
#dataapi.server.port = 80
|
||||
#dataapi.server.protocol = http
|
||||
|
||||
# \ub85c\uceec \uc11c\ubc84
|
||||
dataapi.server.ip = localhost
|
||||
dataapi.server.port = 8088
|
||||
# \uc784\uc2dc PC \uac1c\ubc1c \uc11c\ubc84
|
||||
dataapi.server.ip = 192.168.25.87
|
||||
dataapi.server.port = 8080
|
||||
dataapi.server.protocol = http
|
||||
|
||||
# \ub85c\uceec \uc11c\ubc84
|
||||
#dataapi.server.ip = localhost
|
||||
#dataapi.server.port = 8088
|
||||
#dataapi.server.protocol = http
|
||||
|
||||
# \ub85c\uceec \uac1c\ubc1c\uc6a9 XML \ud30c\uc77c \uc704\uce58
|
||||
dataapi.temp.xml.path = C:/iams/workspace/nlib/data/dataxml
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<li><a href="#" onclick="javascript:location.href='${pageContext.request.contextPath}/rent/listRentItems.do';">대출</a></li>
|
||||
<li><a href="#" onclick="javascript:location.href='${pageContext.request.contextPath}/rent/listReservations.do';">예약</a></li>
|
||||
<li><a href="#" onclick="javascript:location.href='${pageContext.request.contextPath}/rent/listRequestsForViewingItem.do';">열람요청</a></li>
|
||||
<li><a href="#" onclick="javascript:location.href='${pageContext.request.contextPath}/collection/listInterests.do';">관심자료</a></li>
|
||||
<li><a href="#" onclick="javascript:location.href='${pageContext.request.contextPath}/interest/listInterests.do';">관심자료</a></li>
|
||||
<li><a href="#" onclick="javascript:location.href='${pageContext.request.contextPath}/cmm/listNotifications.do';">알림</a></li>
|
||||
|
||||
<!-- 개발자용 메뉴 -->
|
||||
@ -31,6 +31,8 @@
|
||||
<li><a href="#" style="color:#FF5;" onclick="javascript:location.href='${pageContext.request.contextPath}/sample/password/getSampleEncoder.do';">암호화</a></li>
|
||||
<li><a href="#" style="color:#FF5;" onclick="javascript:location.href='${pageContext.request.contextPath}/system/reloadProperties.do';">프로퍼티갱신</a></li>
|
||||
<li><a href="#" style="color:#FF5;" onclick="javascript:location.href='${pageContext.request.contextPath}/code/listCodes.do';">코드조회</a></li>
|
||||
<li><a href="#" style="color:#FF5;" onclick="javascript:location.href='${pageContext.request.contextPath}/sample/getItemInfo.do';">자료상세조회:API샘플</a></li>
|
||||
<li><a href="#" style="color:#FF5;" onclick="javascript:location.href='${pageContext.request.contextPath}/sample/listRentItem.do';">목록조회:API샘플</a></li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user