diff --git a/pom.xml b/pom.xml index b15437dc..33ed0de5 100644 --- a/pom.xml +++ b/pom.xml @@ -72,6 +72,13 @@ + + + + io.swagger + swagger-annotations + 1.5.22 + diff --git a/src/main/java/geoinfo/api/geoinfo/GeoinfoApiV1Controller.java b/src/main/java/geoinfo/api/geoinfo/GeoinfoApiV1Controller.java new file mode 100644 index 00000000..58bb5282 --- /dev/null +++ b/src/main/java/geoinfo/api/geoinfo/GeoinfoApiV1Controller.java @@ -0,0 +1,118 @@ +package geoinfo.api.geoinfo; + +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.RequiredArgsConstructor; + +import java.util.Date; +import java.util.HashMap; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import geoinfo.api.geoinfo.service.GeoinfoApiV1Service; +import geoinfo.util.MyUtil; + +@Controller +@RequiredArgsConstructor +@RequestMapping("/api/geoinfo/v1") +public class GeoinfoApiV1Controller { + + private final Logger logger = LoggerFactory.getLogger(GeoinfoApiV1Controller.class); + + @Autowired + GeoinfoApiV1Service geoinfoApiV1Service; + + /** + * GeoInfo API 서비스의 동적 처리를 위한 통합 메서드입니다. + * URL 경로의 서비스명을 기반으로 분기하여 해당 비즈니스 로직을 호출합니다. + * @param serviceName URL 경로에서 추출된 서비스명 (예: abc, def) + * @param request HttpServletRequest 객체 + * @param strJSON 클라이언트로부터 받은 JSON 형식의 요청 본문 + * @param response HttpServletResponse 객체 + * @return 처리 결과를 담은 JSONObject + */ + @ApiOperation(value = "GeoInfo API 서비스 통합 엔드포인트", notes = "URL 경로에 지정된 서비스명에 따라 적절한 비즈니스 로직을 동적으로 처리합니다.
" + + "- 요청 본문(body)에 JSON 형식의 파라미터를 전달해야 합니다.
" + + "- 예시 URL: /api/geoinfo/v1/getProjectInfo.do, /api/geoinfo/v1/getBoreholeInfo.do
" + + "- 변경자명 : 김종훈
" + + "- 변경일자 : 2025.08.14") + @RequestMapping(value = "/{spName}.do", method = RequestMethod.GET) + @ResponseBody + public JSONObject handleApiService( + @ApiParam(value = "URL 경로에 포함된 서비스 이름", required = true, example = "getProjectInfo") @PathVariable("spName") String spName, + HttpServletRequest request, + @RequestParam HashMap params, + HttpServletResponse response) { + + + + JSONObject jsonResponse = new JSONObject(); + + + // 2. HashMap을 사용하여 JSONObject 생성 + JSONObject jsonObject = new JSONObject(); + for (HashMap.Entry entry : params.entrySet()) { + if ("".equals(entry.getValue())) { + entry.setValue(null); + jsonObject.put(entry.getKey(), entry.getValue()); + } + } + + + // 3. toJSONString() 메서드로 JSON 문자열 출력 + String jsonString = jsonObject.toJSONString(); + + logger.info("\n--------------------------------------------------------------\n" + + request.getRequestURI() + " IN:" + + "\n--------------------------------------------------------------\n" + + "procedure Name: " + spName + "\n" + + "Request params: \n" + jsonString + "\n" + + "\n--------------------------------------------------------------\n" + ); + + JSONParser jsonParser = new JSONParser(); + JSONArray jsonArr = null; + + + try { + geoinfoApiV1Service.handleApiService(request, params, spName, jsonResponse); + } catch (Exception e) { + // TODO Auto-generated catch block + String strTxt = + "---------- BUG REPORTING START ----------" + "\n" + + "에러 문구:[" + request.getRequestURI() + " " + "]" + "\n" + + "jsonString:[\n" + jsonString + "\n]\n" + + "e.getMessage():[\n" + e.getMessage() + "\n]\n" + "\n" + + "new Date().toString():[" + new Date().toString() + "]\n" + "\n" + + "---------- BUG REPORTING END ----------" + "\n" + + ""; + System.out.println(strTxt); + jsonResponse.put("resultCode", -1); + jsonResponse.put("result", "false"); + jsonResponse.put("message", e.getMessage()); + } + + logger.info("\n--------------------------------------------------------------\n" + + request.getRequestURI() + " OUT:" + + "\n--------------------------------------------------------------\n" + + "Response JSON: [" + jsonResponse.toJSONString() + "]\n" + + "\n--------------------------------------------------------------\n"); + + return jsonResponse; + } +} diff --git a/src/main/java/geoinfo/api/geoinfo/service/GeoinfoApiV1Mapper.java b/src/main/java/geoinfo/api/geoinfo/service/GeoinfoApiV1Mapper.java new file mode 100644 index 00000000..144f57f9 --- /dev/null +++ b/src/main/java/geoinfo/api/geoinfo/service/GeoinfoApiV1Mapper.java @@ -0,0 +1,16 @@ +package geoinfo.api.geoinfo.service; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; + +import egovframework.rte.psl.dataaccess.mapper.Mapper; +import egovframework.rte.psl.dataaccess.util.EgovMap; + +@Mapper("geoinfoApiV1Mapper") +public interface GeoinfoApiV1Mapper { + public ArrayList spGetTblProjectInfo(HashMap params) throws SQLException; +} + + + diff --git a/src/main/java/geoinfo/api/geoinfo/service/GeoinfoApiV1Service.java b/src/main/java/geoinfo/api/geoinfo/service/GeoinfoApiV1Service.java new file mode 100644 index 00000000..bccecfa2 --- /dev/null +++ b/src/main/java/geoinfo/api/geoinfo/service/GeoinfoApiV1Service.java @@ -0,0 +1,12 @@ +package geoinfo.api.geoinfo.service; + +import java.util.HashMap; + +import javax.servlet.http.HttpServletRequest; + +import org.json.simple.JSONObject; + + +public interface GeoinfoApiV1Service { + int handleApiService(HttpServletRequest request, HashMap params, String spName, JSONObject jsonResponse) throws Exception; +} diff --git a/src/main/java/geoinfo/api/geoinfo/service/impl/GeoinfoApiV1ServiceImpl.java b/src/main/java/geoinfo/api/geoinfo/service/impl/GeoinfoApiV1ServiceImpl.java new file mode 100644 index 00000000..fd179316 --- /dev/null +++ b/src/main/java/geoinfo/api/geoinfo/service/impl/GeoinfoApiV1ServiceImpl.java @@ -0,0 +1,74 @@ +package geoinfo.api.geoinfo.service.impl; + +import geoinfo.api.geoinfo.service.GeoinfoApiV1Mapper; +import geoinfo.api.geoinfo.service.GeoinfoApiV1Service; +import geoinfo.drilling.input.service.DrillingInputMapper; +import geoinfo.drilling.input.service.DrillingInputService; +import geoinfo.drilling.inquiry.service.DrillingInquiryService; +import geoinfo.main.login.service.LoginMapper; +import geoinfo.util.MyUtil; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import egovframework.rte.psl.dataaccess.util.EgovMap; + +@Service("geoinfoApiV1Service") +public class GeoinfoApiV1ServiceImpl implements GeoinfoApiV1Service { + + @Resource(name="geoinfoApiV1Mapper") + private GeoinfoApiV1Mapper geoinfoApiV1Mapper; + + + public int handleApiService(HttpServletRequest request, HashMap params, String spName, JSONObject jsonResponse) throws Exception { + + //호출 프로시저 유효성 체크 + spName = spName.trim(); + + + // 서비스 이름에 따라 분기 처리 + HashMap resultMap = null; + int nRetCode = -1; + String lpszRetMsg = null; + if ("sp-get-tbl-project-info".equalsIgnoreCase(spName)) { + ArrayList hashMapList = geoinfoApiV1Mapper.spGetTblProjectInfo(params); + jsonResponse.put("data", hashMapList); + + //nRetCode = MyUtil.getIntegerFromObject(hashMap.get("v_RetCode")); + //lpszRetMsg = MyUtil.getStringFromObject(hashMap.get("v_RetMsg")); + + } else if ("def".equalsIgnoreCase(spName)) { + } else { + // 지원하지 않는 서비스명인 경우 오류 처리 + throw new Exception("Unsupported service name: " + spName); + } + + if( false ) { + if( nRetCode == 100 ) { + jsonResponse.put("resultCode", nRetCode); + jsonResponse.put("result", "true"); + jsonResponse.put("message", "SUCCESS"); + } else { + jsonResponse.put("resultCode", nRetCode); + jsonResponse.put("result", "false"); + jsonResponse.put("message", lpszRetMsg); + } + + } + + return nRetCode; + } + + +} diff --git a/src/main/java/geoinfo/drilling/input/service/impl/DrillingInputServiceImpl.java b/src/main/java/geoinfo/drilling/input/service/impl/DrillingInputServiceImpl.java index 00d42ced..0fda949b 100644 --- a/src/main/java/geoinfo/drilling/input/service/impl/DrillingInputServiceImpl.java +++ b/src/main/java/geoinfo/drilling/input/service/impl/DrillingInputServiceImpl.java @@ -106,6 +106,7 @@ public class DrillingInputServiceImpl implements DrillingInputService { //String[] words = projectMasterCompanyName.split(" "); //String lastWord = words[words.length - 1]; //spGetMasterCompanyDistrictParams.put("projectMasterCompanyName", lastWord); + projectMasterCompanyName = projectMasterCompanyName.trim(); spGetMasterCompanyDistrictParams.put("projectMasterCompanyName", projectMasterCompanyName); drillingInputMapper.spGetMasterCompanyDistrict(spGetMasterCompanyDistrictParams); diff --git a/src/main/resources/egovframework/sqlmap/mapper/api/geoinfo/GeoinfoApiV1Mapper.xml b/src/main/resources/egovframework/sqlmap/mapper/api/geoinfo/GeoinfoApiV1Mapper.xml new file mode 100644 index 00000000..7373e7ca --- /dev/null +++ b/src/main/resources/egovframework/sqlmap/mapper/api/geoinfo/GeoinfoApiV1Mapper.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/egovframework/sqlmap/mapper/main/Login_SQL.xml b/src/main/resources/egovframework/sqlmap/mapper/main/Login_SQL.xml index 173bad68..5ead924e 100644 --- a/src/main/resources/egovframework/sqlmap/mapper/main/Login_SQL.xml +++ b/src/main/resources/egovframework/sqlmap/mapper/main/Login_SQL.xml @@ -152,17 +152,17 @@ ]]> - + - AND EXISTS (SELECT 1 FROM TBL_FIELD_PERMEABILITY C WHERE B.HOLE_CODE = C.HOLE_CODE ) + AND EXISTS (SELECT 1 FROM TBL_FIELD_WATERPRESSURE C WHERE B.HOLE_CODE = C.HOLE_CODE ) - AND EXISTS (SELECT 1 FROM TBL_FIELD_WATERPRESSURE C WHERE B.HOLE_CODE = C.HOLE_CODE ) + AND EXISTS (SELECT 1 FROM TBL_FIELD_PERMEABILITY C WHERE B.HOLE_CODE = C.HOLE_CODE ) @@ -276,13 +276,13 @@ UNION ALL - SELECT DISTINCT HOLE_CODE FROM TBL_FIELD_PERMEABILITY + SELECT DISTINCT HOLE_CODE FROM TBL_FIELD_WATERPRESSURE UNION ALL - SELECT DISTINCT HOLE_CODE FROM TBL_FIELD_WATERPRESSURE + SELECT DISTINCT HOLE_CODE FROM TBL_FIELD_PERMEABILITY @@ -496,12 +496,12 @@ - AND EXISTS (SELECT 1 FROM TBL_FIELD_PERMEABILITY C WHERE B.HOLE_CODE = C.HOLE_CODE ) + AND EXISTS (SELECT 1 FROM TBL_FIELD_WATERPRESSURE C WHERE B.HOLE_CODE = C.HOLE_CODE ) - AND EXISTS (SELECT 1 FROM TBL_FIELD_WATERPRESSURE C WHERE B.HOLE_CODE = C.HOLE_CODE ) + AND EXISTS (SELECT 1 FROM TBL_FIELD_PERMEABILITY C WHERE B.HOLE_CODE = C.HOLE_CODE ) @@ -685,13 +685,13 @@ UNION ALL - SELECT DISTINCT HOLE_CODE FROM TBL_FIELD_PERMEABILITY + SELECT DISTINCT HOLE_CODE FROM TBL_FIELD_WATERPRESSURE UNION ALL - SELECT DISTINCT HOLE_CODE FROM TBL_FIELD_WATERPRESSURE + SELECT DISTINCT HOLE_CODE FROM TBL_FIELD_PERMEABILITY