
--- build.gradle
+++ build.gradle
... | ... | @@ -55,6 +55,10 @@ |
55 | 55 |
// Log4j2 스타터 |
56 | 56 |
implementation 'org.springframework.boot:spring-boot-starter-log4j2' |
57 | 57 |
// https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310 |
58 |
+ // Jackson 라이브러리 추가 |
|
59 |
+ implementation 'com.fasterxml.jackson.core:jackson-databind' |
|
60 |
+ implementation 'com.fasterxml.jackson.core:jackson-annotations' |
|
61 |
+ implementation 'com.fasterxml.jackson.core:jackson-core' |
|
58 | 62 |
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310' |
59 | 63 |
|
60 | 64 |
// 웹 푸시 라이브러리 |
--- src/main/java/com/takensoft/taken_bi_manager/openAPI/service/impl/OpenApiServiceImpl.java
+++ src/main/java/com/takensoft/taken_bi_manager/openAPI/service/impl/OpenApiServiceImpl.java
... | ... | @@ -175,17 +175,17 @@ |
175 | 175 |
|
176 | 176 |
// param으로 Query 조건문 만들기 |
177 | 177 |
param.remove("serviceKey"); |
178 |
- if (param.get("currentPage") != null && CommonUtil.parseInt(param.get("currentPage")) > 0) { |
|
178 |
+ if (param.get("pageNo") != null && CommonUtil.parseInt(param.get("pageNo")) > 0) { |
|
179 | 179 |
// OFFSET 계산 |
180 |
- int currentPage = CommonUtil.parseInt(param.get("currentPage")); |
|
181 |
- int perPage = CommonUtil.parseInt(param.get("perPage") != null ? param.get("perPage") : 30); // 기본값 30 |
|
180 |
+ int currentPage = CommonUtil.parseInt(param.get("pageNo")); |
|
181 |
+ int perPage = CommonUtil.parseInt(param.get("numOfRows") != null ? param.get("numOfRows") : 30); // 기본값 30 |
|
182 | 182 |
int offset = (currentPage - 1) * perPage; |
183 | 183 |
dataTable.setOffset(offset); // OFFSET 설정 |
184 |
- param.remove("currentPage"); |
|
184 |
+ param.remove("pageNo"); |
|
185 | 185 |
} |
186 |
- if (param.get("perPage") != null && CommonUtil.parseInt(param.get("perPage")) > 0) { |
|
187 |
- dataTable.setPerPage(CommonUtil.parseInt(param.get("perPage"))); |
|
188 |
- param.remove("perPage"); |
|
186 |
+ if (param.get("numOfRows") != null && CommonUtil.parseInt(param.get("numOfRows")) > 0) { |
|
187 |
+ dataTable.setPerPage(CommonUtil.parseInt(param.get("numOfRows"))); |
|
188 |
+ param.remove("numOfRows"); |
|
189 | 189 |
} |
190 | 190 |
String query = buildQueryCondition(param , dataTable.getColumnDatas()); |
191 | 191 |
System.out.println("조건문 쿼리문 " + query); |
--- src/main/java/com/takensoft/taken_bi_manager/openAPI/web/OpenApiController.java
+++ src/main/java/com/takensoft/taken_bi_manager/openAPI/web/OpenApiController.java
... | ... | @@ -1,12 +1,15 @@ |
1 | 1 |
package com.takensoft.taken_bi_manager.openAPI.web; |
2 | 2 |
|
3 | 3 |
import com.fasterxml.jackson.databind.ObjectMapper; |
4 |
+import com.takensoft.taken_bi_manager.common.connection.db.util.DBConnectionUtil; |
|
4 | 5 |
import com.takensoft.taken_bi_manager.common.connection.db.vo.ConnectionDB; |
5 | 6 |
import com.takensoft.taken_bi_manager.common.util.CommonUtil; |
6 | 7 |
import com.takensoft.taken_bi_manager.common.util.StringUtil; |
7 | 8 |
import com.takensoft.taken_bi_manager.common.vo.CheckMessage; |
8 | 9 |
import com.takensoft.taken_bi_manager.common.vo.CustomeResultMap; |
9 | 10 |
import com.takensoft.taken_bi_manager.common.vo.SearchVO; |
11 |
+import com.takensoft.taken_bi_manager.controller.data.DataController; |
|
12 |
+import com.takensoft.taken_bi_manager.data.dao.DataDAO; |
|
10 | 13 |
import com.takensoft.taken_bi_manager.data.dao.DatasetDAO; |
11 | 14 |
import com.takensoft.taken_bi_manager.data.service.DatasetService; |
12 | 15 |
import com.takensoft.taken_bi_manager.data.vo.ColumnData; |
... | ... | @@ -21,6 +24,8 @@ |
21 | 24 |
import jakarta.servlet.http.HttpSession; |
22 | 25 |
import kr.co.smartguru.apim.gateway.util.APIMGatewayUtil; |
23 | 26 |
import org.springframework.beans.factory.annotation.Autowired; |
27 |
+import org.springframework.http.HttpStatus; |
|
28 |
+import org.springframework.http.ResponseEntity; |
|
24 | 29 |
import org.springframework.web.bind.annotation.*; |
25 | 30 |
import org.springframework.web.servlet.ModelAndView; |
26 | 31 |
import org.w3c.dom.Document; |
... | ... | @@ -45,6 +50,9 @@ |
45 | 50 |
|
46 | 51 |
@Autowired |
47 | 52 |
private DatasetDAO datasetDAO; |
53 |
+ |
|
54 |
+ @Autowired |
|
55 |
+ private DataDAO dataDAO; |
|
48 | 56 |
|
49 | 57 |
private static HashMap<String, HashMap<String, String>> apiCodeMap; |
50 | 58 |
|
... | ... | @@ -160,25 +168,71 @@ |
160 | 168 |
* |
161 | 169 |
* 배포 url json 정보 확인 |
162 | 170 |
*/ |
163 |
- @GetMapping("/openapi/{datasetPostId}/{datasetId}/{exportId}/getData") |
|
164 |
- public CustomeResultMap getData (@PathVariable String datasetPostId, @PathVariable String datasetId, @PathVariable String exportId, @RequestParam HashMap<String, Object> param) throws Exception { |
|
165 |
- CustomeResultMap result = new CustomeResultMap(); |
|
171 |
+ @RequestMapping("/openapi/{datasetPostId}/{datasetId}/{exportId}/getData") |
|
172 |
+ public ResponseEntity getData (@PathVariable String datasetPostId, @PathVariable String datasetId, @PathVariable String exportId, @RequestParam HashMap<String, Object> param) throws Exception { |
|
173 |
+ |
|
174 |
+ ModelAndView mav = new ModelAndView("jsonView"); |
|
175 |
+ //최종 객체 |
|
176 |
+ Map<String, Object> result = new HashMap<>(1); |
|
177 |
+ //최종 하위 객체 |
|
178 |
+ Map<String, Object> response = new HashMap<>(2); |
|
179 |
+ |
|
180 |
+ String resultCode = "00"; |
|
181 |
+ String resultMsg = apiCodeMap.get(resultCode).get("errorEng"); |
|
182 |
+ |
|
183 |
+ Map<String, Object> header = new HashMap<>(); |
|
184 |
+ Map<String, Object> body = new HashMap<>(); |
|
185 |
+ |
|
166 | 186 |
System.out.println("params입니다 "+ param); |
167 | 187 |
if(param.get("serviceKey").toString() == null) { |
168 |
- result.getCheckMessage().setMessage("서비스 키가 필요합니다."); |
|
188 |
+ mav.addObject("message", "서비스 키가 필요합니다."); |
|
169 | 189 |
}else{ |
170 | 190 |
int serviceKeyCkeck = openApiService.openApiKeyCheck(param.get("serviceKey").toString()); |
171 | 191 |
if( serviceKeyCkeck >0){ |
172 |
- // body에 rowData를 담는다 |
|
173 |
- List<LinkedHashMap<String, Object>> rowData = openApiService.openApiGetINRowDataAll(datasetPostId , param); |
|
192 |
+ try{ |
|
193 |
+ Dataset dataset = datasetDAO.selectDatasetByPostId(datasetPostId); |
|
194 |
+ ConnectionDB connectionDB = dataDAO.selectDbConnectionOne(dataset.getDbConectId()); |
|
195 |
+ DataTable dataTable = new DataTable(dataset); |
|
196 |
+ DBConnectionUtil dbUtil = new DBConnectionUtil(); |
|
197 |
+ connectionDB.decodingData(); |
|
198 |
+ dbUtil.getRowDataTotalRows(connectionDB,dataTable); |
|
199 |
+ body.put("totalCount", dbUtil.getRowDataTotalRows(connectionDB,dataTable)); |
|
200 |
+ body.put("pageNo", param.get("pageNo")); |
|
201 |
+ body.put("numOfRows", param.get("numOfRows")); |
|
174 | 202 |
|
175 |
- result.getResultData().put("body", rowData); |
|
203 |
+ // body에 rowData를 담는다 |
|
204 |
+ List<LinkedHashMap<String, Object>> rowData = openApiService.openApiGetINRowDataAll(datasetPostId , param); |
|
205 |
+ Map<String, List<LinkedHashMap<String, Object>>> items = new HashMap<>(0); |
|
206 |
+ items.put("item", rowData); |
|
207 |
+ body.put("items", items); |
|
208 |
+ |
|
209 |
+ response.put("body", body); |
|
210 |
+ } catch (Exception e) { |
|
211 |
+ e.printStackTrace(); |
|
212 |
+ |
|
213 |
+ // 어플리케이션 에러 |
|
214 |
+ resultCode = "2"; |
|
215 |
+ resultMsg = apiCodeMap.get(resultCode).get("errorEng"); |
|
216 |
+ } finally { |
|
217 |
+ /* header에 '결과 코드' 담기 */ |
|
218 |
+ header.put("resultCode", resultCode); |
|
219 |
+ header.put("resultMsg", resultMsg); |
|
220 |
+ |
|
221 |
+ /** header 데이터 담기 **/ |
|
222 |
+ //mav.addObject("header", header); |
|
223 |
+ response.put("header", header); |
|
224 |
+ |
|
225 |
+ |
|
226 |
+ /** 최종 API 데이터 담기 **/ |
|
227 |
+ result.put("response", response); |
|
228 |
+ mav.addObject("result", result); |
|
229 |
+ } |
|
176 | 230 |
} else { |
177 |
- result.getCheckMessage().setMessage("서비스 키가 유효하지 않습니다."); |
|
231 |
+ mav.addObject("message", "서비스 키가 유효하지 않습니다."); |
|
178 | 232 |
} |
179 | 233 |
} |
180 | 234 |
|
181 |
- return result; |
|
235 |
+ return ResponseEntity.ok(result); |
|
182 | 236 |
} |
183 | 237 |
/** |
184 | 238 |
* @author 하관우 |
--- src/main/resources/spring/mapper/sql/mariadb-SQL.xml
+++ src/main/resources/spring/mapper/sql/mariadb-SQL.xml
... | ... | @@ -496,7 +496,7 @@ |
496 | 496 |
WHERE 1 |
497 | 497 |
${query} |
498 | 498 |
</if> |
499 |
- <if test="perPage != null and perPage > 10"> |
|
499 |
+ <if test="offset != null and offset > 0"> |
|
500 | 500 |
LIMIT #{perPage} OFFSET #{offset} |
501 | 501 |
</if> |
502 | 502 |
</select> |
--- src/main/resources/spring/mapper/sql/mysql-SQL.xml
+++ src/main/resources/spring/mapper/sql/mysql-SQL.xml
... | ... | @@ -495,7 +495,7 @@ |
495 | 495 |
WHERE 1 |
496 | 496 |
${query} |
497 | 497 |
</if> |
498 |
- <if test="perPage != null and perPage > 10"> |
|
498 |
+ <if test="offset != null and offset > 0"> |
|
499 | 499 |
LIMIT #{perPage} OFFSET #{offset} |
500 | 500 |
</if> |
501 | 501 |
</select> |
--- src/main/resources/spring/mapper/sql/postgre-SQL.xml
+++ src/main/resources/spring/mapper/sql/postgre-SQL.xml
... | ... | @@ -589,7 +589,7 @@ |
589 | 589 |
<!-- AND --> |
590 | 590 |
${query} |
591 | 591 |
</if> |
592 |
- <if test="perPage != null and perPage > 10"> |
|
592 |
+ <if test="offset != null and offset > 0"> |
|
593 | 593 |
LIMIT #{perPage} OFFSET #{offset} |
594 | 594 |
</if> |
595 | 595 |
</select> |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?