주상도PDF를 다운로드 하는 API 개발

main
유지인 2025-12-09 09:21:45 +09:00
parent ac1aea006a
commit 1a3f94524c
5 changed files with 54 additions and 1 deletions

View File

@ -51,7 +51,8 @@ public class GeoinfoApiV1Controller {
"- 예시 URL: /api/geoinfo/v1/getProjectInfo.do, /api/geoinfo/v1/getBoreholeInfo.do<br />" +
"- 변경자명 : 김종훈<br />" +
"- 변경일자 : 2025.08.14")
@RequestMapping(value = "/{spName}.do", method = RequestMethod.GET)
// @RequestMapping(value = "/{spName}.do", method = RequestMethod.GET)
@RequestMapping(value = "/{spName:^(?!borehole-log$).+}.do", method = RequestMethod.GET)
@ResponseBody
public JSONObject handleApiService(
@ApiParam(value = "URL 경로에 포함된 서비스 이름", required = true, example = "getProjectInfo") @PathVariable("spName") String spName,
@ -115,4 +116,41 @@ public class GeoinfoApiV1Controller {
return jsonResponse;
}
@RequestMapping(value = "/borehole-log.do", method = RequestMethod.GET)
public void getBoreholeLogPdf(
@RequestParam String holeCode,
@RequestParam HashMap<String, Object> params,
HttpServletResponse response) throws Exception {
int validApiKey = 0;
validApiKey = geoinfoApiV1Service.isValidWebApiKey(params);
if (validApiKey != 1) {
JSONObject jsonResponse = new JSONObject();
if (validApiKey == -1) {
jsonResponse.put("resultCode", -1);
jsonResponse.put("result", "false");
jsonResponse.put("message", "미승인 API키 입니다.");
} else if (validApiKey == -2) {
jsonResponse.put("resultCode", -2);
jsonResponse.put("result", "false");
jsonResponse.put("message", "기간이 만료된 API키 입니다.");
} else { // validApiKey == 0
jsonResponse.put("resultCode", 0);
jsonResponse.put("result", "false");
jsonResponse.put("message", "등록되지 않은 API키 입니다.");
}
// JSON 반환 설정
response.setContentType("application/json; charset=UTF-8");
response.getWriter().write(jsonResponse.toJSONString());
return;
}
// 3. API Key 정상일 경우 PDF URL로 리디렉션 실행
String redirectUrl = "/ClipReport4/export/exportForPDF_Jusangdo.jsp?data=" + holeCode;
response.sendRedirect(redirectUrl);
}
}

View File

@ -134,4 +134,7 @@ public interface GeoinfoApiV1Mapper {
public int spCntTblRockReptTriU(HashMap<String, Object> params) throws SQLException;
public ArrayList<EgovMap> spGetTblRockReptTri(HashMap<String, Object> params) throws SQLException;
public int spCntTblRockReptTri(HashMap<String, Object> params) throws SQLException;
// API Key 검증
public int spIsValidWebApiKeyId(HashMap<String, Object> params) throws SQLException;
}

View File

@ -9,4 +9,5 @@ import org.json.simple.JSONObject;
public interface GeoinfoApiV1Service {
int handleApiService(HttpServletRequest request, HashMap<String, Object> params, String spName, JSONObject jsonResponse) throws Exception;
int isValidWebApiKey(HashMap<String, Object> params) throws Exception;
}

View File

@ -232,4 +232,9 @@ public class GeoinfoApiV1ServiceImpl implements GeoinfoApiV1Service {
// 성공 코드 반환
return 0;
}
@Override
public int isValidWebApiKey(HashMap<String, Object> params) throws Exception {
return geoinfoApiV1Mapper.spIsValidWebApiKeyId(params);
}
}

View File

@ -750,4 +750,10 @@
) FROM DUAL
</select>
<select id="spIsValidWebApiKeyId" parameterType="map" resultType="int">
<!-- 0:키없음, 1:정상, -1:미승인, -2:기간만료 -->
SELECT SP_IS_VALID_WEB_API_KEY_ID(
#{apiKey, jdbcType=VARCHAR}
) FROM DUAL
</select>
</mapper>