
--- pom.xml
+++ pom.xml
... | ... | @@ -112,6 +112,13 @@ |
112 | 112 |
<version>2.13.3</version> |
113 | 113 |
</dependency> |
114 | 114 |
|
115 |
+ <!--기본 org.json --> |
|
116 |
+ <dependency> |
|
117 |
+ <groupId>org.json</groupId> |
|
118 |
+ <artifactId>json</artifactId> |
|
119 |
+ <version>20180813</version> |
|
120 |
+ </dependency> |
|
121 |
+ |
|
115 | 122 |
<!-- 시스템 입출력(파일 포함) --> |
116 | 123 |
<dependency> |
117 | 124 |
<groupId>commons-io</groupId> |
--- server/main/java/kr/co/takensoft/crosswalk/test/dao/TestDAO.java
+++ server/main/java/kr/co/takensoft/crosswalk/test/dao/TestDAO.java
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 |
import kr.co.takensoft.crosswalk.test.vo.Test; |
5 | 5 |
import org.apache.ibatis.annotations.Mapper; |
6 | 6 |
|
7 |
+import java.util.HashMap; |
|
7 | 8 |
import java.util.List; |
8 | 9 |
|
9 | 10 |
/** |
... | ... | @@ -23,4 +24,12 @@ |
23 | 24 |
* @since 2022.09.01 |
24 | 25 |
*/ |
25 | 26 |
public List<Test> testDataSelectList (Test test) throws Exception; |
27 |
+ |
|
28 |
+ /** |
|
29 |
+ * 데이터 조회 테스트 |
|
30 |
+ * |
|
31 |
+ * @author 최정우 |
|
32 |
+ * @since 2022.09.01 |
|
33 |
+ */ |
|
34 |
+ public String getDongGeoJson (HashMap<String, Object> data) throws Exception; |
|
26 | 35 |
} |
--- server/main/java/kr/co/takensoft/crosswalk/test/service/TestService.java
+++ server/main/java/kr/co/takensoft/crosswalk/test/service/TestService.java
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 |
|
3 | 3 |
import kr.co.takensoft.crosswalk.test.vo.Test; |
4 | 4 |
|
5 |
+import java.util.HashMap; |
|
5 | 6 |
import java.util.List; |
6 | 7 |
|
7 | 8 |
|
... | ... | @@ -16,4 +17,12 @@ |
16 | 17 |
*/ |
17 | 18 |
public List<Test> testDataSelectList (Test test) throws Exception; |
18 | 19 |
|
20 |
+ /** |
|
21 |
+ * 데이터 조회 테스트 |
|
22 |
+ * |
|
23 |
+ * @author 최정우 |
|
24 |
+ * @since 2022.09.01 |
|
25 |
+ */ |
|
26 |
+ public String getDongGeoJson (HashMap<String, Object> data) throws Exception; |
|
27 |
+ |
|
19 | 28 |
} |
--- server/main/java/kr/co/takensoft/crosswalk/test/service/impl/TestServiceImpl.java
+++ server/main/java/kr/co/takensoft/crosswalk/test/service/impl/TestServiceImpl.java
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 |
import org.springframework.beans.factory.annotation.Autowired; |
7 | 7 |
import org.springframework.stereotype.Service; |
8 | 8 |
|
9 |
+import java.util.HashMap; |
|
9 | 10 |
import java.util.List; |
10 | 11 |
|
11 | 12 |
/** |
... | ... | @@ -30,4 +31,9 @@ |
30 | 31 |
public List<Test> testDataSelectList(Test test) throws Exception { |
31 | 32 |
return testDao.testDataSelectList(test); |
32 | 33 |
} |
34 |
+ |
|
35 |
+ @Override |
|
36 |
+ public String getDongGeoJson(HashMap<String, Object> data) throws Exception { |
|
37 |
+ return testDao.getDongGeoJson(data); |
|
38 |
+ } |
|
33 | 39 |
} |
--- server/main/java/kr/co/takensoft/crosswalk/test/web/TestConroller.java
+++ server/main/java/kr/co/takensoft/crosswalk/test/web/TestConroller.java
... | ... | @@ -3,6 +3,7 @@ |
3 | 3 |
import com.fasterxml.jackson.databind.ObjectMapper; |
4 | 4 |
import kr.co.takensoft.crosswalk.test.service.TestService; |
5 | 5 |
import kr.co.takensoft.crosswalk.test.vo.Test; |
6 |
+import org.json.JSONObject; |
|
6 | 7 |
import org.springframework.beans.factory.annotation.Autowired; |
7 | 8 |
import org.springframework.stereotype.Controller; |
8 | 9 |
import org.springframework.web.bind.annotation.RequestBody; |
... | ... | @@ -107,4 +108,56 @@ |
107 | 108 |
mav.addObject("result", param); |
108 | 109 |
return mav; |
109 | 110 |
} |
111 |
+ |
|
112 |
+ @RequestMapping(value = "/testDongGeoJson.json", method = RequestMethod.POST) |
|
113 |
+ public ModelAndView testDongGeoJson () throws Exception { |
|
114 |
+ |
|
115 |
+ String freeBus = "{\n" + |
|
116 |
+ " \"type\": \"FeatureCollection\",\n" + |
|
117 |
+ " \"features\": [\n" + |
|
118 |
+ " {\n" + |
|
119 |
+ " \"type\": \"Feature\",\n" + |
|
120 |
+ " \"properties\": {\n" + |
|
121 |
+ " \"popupContent\": \"18th & California Light Rail Stop\",\n" + |
|
122 |
+ " \"data\" : 123\n" + |
|
123 |
+ " },\n" + |
|
124 |
+ " \"geometry\": {\n" + |
|
125 |
+ " \"type\": \"Point\",\n" + |
|
126 |
+ " \"coordinates\": [126.9757184, 37.564388] \n" + |
|
127 |
+ " }\n" + |
|
128 |
+ " },{\n" + |
|
129 |
+ " \"type\": \"Feature\",\n" + |
|
130 |
+ " \"properties\": {\n" + |
|
131 |
+ " \"popupContent\": \"20th & Welton Light Rail Stop\",\n" + |
|
132 |
+ " \"data\" : 456\n" + |
|
133 |
+ " },\n" + |
|
134 |
+ " \"geometry\": {\n" + |
|
135 |
+ " \"type\": \"Point\",\n" + |
|
136 |
+ " \"coordinates\": [124.9748523, 37.5796212]\n" + |
|
137 |
+ " }\n" + |
|
138 |
+ " }\n" + |
|
139 |
+ " ]\n" + |
|
140 |
+ "}"; |
|
141 |
+ |
|
142 |
+ JSONObject jsonObject = new JSONObject(freeBus); |
|
143 |
+ System.out.println(jsonObject.toString()); |
|
144 |
+ ModelAndView mav = new ModelAndView("jsonView"); |
|
145 |
+ mav.addObject("result", jsonObject.toString()); |
|
146 |
+ |
|
147 |
+ return mav; |
|
148 |
+ } |
|
149 |
+ |
|
150 |
+ @RequestMapping(value = "/testDongGeoJson2.json", method = RequestMethod.POST) |
|
151 |
+ public ModelAndView testDongGeoJson2 () throws Exception { |
|
152 |
+ |
|
153 |
+ HashMap<String, Object> aa = new HashMap<String, Object>(); |
|
154 |
+ aa.put("code", "2711"); |
|
155 |
+ |
|
156 |
+ String data = testService.getDongGeoJson(aa); |
|
157 |
+ // JSONObject jsonObject = new JSONObject(data); |
|
158 |
+ System.out.print(data); |
|
159 |
+ ModelAndView mav = new ModelAndView("jsonView"); |
|
160 |
+ mav.addObject("result",data); |
|
161 |
+ return mav; |
|
162 |
+ } |
|
110 | 163 |
} |
--- server/main/java/spring/config/DataSourceContextConfig.java
+++ server/main/java/spring/config/DataSourceContextConfig.java
... | ... | @@ -35,7 +35,7 @@ |
35 | 35 |
/*hikariConfig.setDriverClassName("org.postgresql.Driver"); |
36 | 36 |
hikariConfig.setJdbcUrl("jdbc:postgresql://165.229.169.113:5432/mold_management_system?currentSchema=mold_management_system_v1_7");*/ |
37 | 37 |
hikariConfig.setDriverClassName("net.sf.log4jdbc.sql.jdbcapi.DriverSpy"); |
38 |
- hikariConfig.setJdbcUrl("jdbc:log4jdbc:postgresql://210.180.118.83:5432/crosswalk?currentSchema=crosswalk"); |
|
38 |
+ hikariConfig.setJdbcUrl("jdbc:log4jdbc:postgresql://210.180.118.83:5432/crosswalk?currentSchema=crosswalk_v0_1"); |
|
39 | 39 |
hikariConfig.setUsername("takensoft"); |
40 | 40 |
hikariConfig.setPassword("ts44301236!@"); |
41 | 41 |
return hikariConfig; |
--- server/main/resources/mybatis/main/test-SQL.xml
+++ server/main/resources/mybatis/main/test-SQL.xml
... | ... | @@ -28,4 +28,21 @@ |
28 | 28 |
FROM public.user_info; |
29 | 29 |
</select> |
30 | 30 |
|
31 |
+ |
|
32 |
+ <select id="getDongGeoJson" parameterType="HashMap" resultType="string"> |
|
33 |
+ SELECT jsonb_build_object( |
|
34 |
+ 'type', 'FeatureCollection', |
|
35 |
+ 'features', jsonb_agg(features.feature) |
|
36 |
+ ) |
|
37 |
+ FROM ( |
|
38 |
+ SELECT jsonb_build_object( |
|
39 |
+ 'type', 'Feature', |
|
40 |
+ 'id', dong_cd , |
|
41 |
+ 'name', dong_kor_nm, |
|
42 |
+ 'geometry', ST_AsGeoJSON(geom)::jsonb, |
|
43 |
+ 'properties', to_jsonb(inputs) - 'gid' - 'geom' |
|
44 |
+ ) AS feature |
|
45 |
+ FROM (SELECT * FROM dong_new where dong_cd like CONCAT('27','%')) inputs) features; |
|
46 |
+ </select> |
|
47 |
+ |
|
31 | 48 |
</mapper>(파일 끝에 줄바꿈 문자 없음) |
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?