@@ -62,9 +62,6 @@ public Map<String, Object> readKorMeal() throws JsonProcessingException {
6262
6363 String nowMeal = mealService .getNowKorMeal ();
6464 Map <String , Object > responseBody = mealService .responseMeal (nowMeal );
65- // if need to stratify.
66- // ObjectMapper objectMapper = new ObjectMapper();
67- // String result = objectMapper.writeValueAsString(responseBody);
6865
6966 return responseBody ;
7067 }
@@ -77,104 +74,49 @@ public Map<String, Object> readEngMeal() throws JsonProcessingException {
7774 String nowMeal = mealService .getNowEngMeal ();
7875 Map <String , Object > responseBody = mealService .responseMeal (nowMeal );
7976
80- // if need to stratify.
81- // ObjectMapper objectMapper = new ObjectMapper();
82- // String result = objectMapper.writeValueAsString(responseBody);
83-
8477 return responseBody ;
8578 }
8679
87- @ PostMapping ("/spectest " )
88- public Map <String , Object > readSpecKortest (@ RequestBody Map <String , Object > requestBody ) throws JsonProcessingException {
89- // input : 날짜요일내일 + 아점저 + 1/2학
80+ @ PostMapping ("/speckor " )
81+ public Map <String , Object > readSpecKorMeal (@ RequestBody Map <String , Object > requestBody ) throws JsonProcessingException {
82+ // input : 날짜요일내일 + 아점저
9083 // output : 한국어 식단이 포함된 JSON (단, JSON은 카톡 서버가 받을 수 있는 형식이여야 함.)
9184
92- Map <String , Object > action = new HashMap <>();
93- action .put ("action" , requestBody .get ("action" ));
94-
95- Map <String , Object > params = new HashMap <>();
96- params .put ("params" , action .get ("action" ));
97-
98- Map <String , Object > paramssss = new HashMap <>();
99- paramssss .put ("params" , params .get ("params" ));
100-
101- String dateCustom = (String ) paramssss .get ("dateCustom" );
102- String bld = (String ) paramssss .get ("bld" );
103-
104- log .info ("req body : " + requestBody .toString ());
105- log .info ("action body : " + action .toString ());
106- log .info ("params body : " + params .toString ());
107- log .info ("paramssss body : " + paramssss .toString ());
108-
109- for (Entry <String , Object > entrySet : requestBody .entrySet ()) {
110- log .info (entrySet .getKey () + " : " + entrySet .getValue ());
111- }
112-
113- log .info ("###########RESULT############" );
114- log .info (dateCustom + " " + bld );
115- log .info (dateCustom + " " + bld );
85+ // how to print the request body
86+ //for (Entry<String, Object> entrySet : requestBody.entrySet()) {
87+ // log.info(entrySet.getKey() + " : " + entrySet.getValue());
88+ //}
11689
11790 ObjectMapper objectMapper = new ObjectMapper ();
118- Map <String , Object > action2 = objectMapper .convertValue (requestBody .get ("action" ), Map .class );
119- Map <String , Object > params2 = objectMapper .convertValue (action2 .get ("params" ), Map .class );
120- log .info (params2 .get ("dateCustom" ).toString () + " " + params2 .get ("bld" ).toString ());
121-
122- //Map<String, String> params2 = new HashMap<>();
123- //params2.put()
124- //log.info(params2.get("dateCustom") + " " + params2.get("bld"));
125-
126- String specMeal = mealService .getSpecKorMeal (dateCustom , bld );
127- Map <String , Object > responseBody = mealService .responseMeal (specMeal );
128-
129- // if need to stratify.
130- // ObjectMapper objectMapper = new ObjectMapper();
131- // String result = objectMapper.writeValueAsString(responseBody);
132-
133- return responseBody ;
134- }
135-
136- @ PostMapping ("/speckor" )
137- public Map <String , Object > readSpecKorMeal (@ RequestBody Map <String , Map <String , Map <String , Object >>> requestBody ) throws JsonProcessingException {
138- // input : 날짜요일내일 + 아점저 + 1/2학
139- // output : 한국어 식단이 포함된 JSON (단, JSON은 카톡 서버가 받을 수 있는 형식이여야 함.)
140-
141- Map <String , Map <String , Object >> action = requestBody .get ("action" );
142- Map <String , Object > params = action .get ("params" );
143- String dateCustom = (String ) params .get ("dateCustom" );
144- String bld = (String ) params .get ("bld" );
91+ Map <String , Object > action = objectMapper .convertValue (requestBody .get ("action" ), Map .class );
92+ Map <String , Object > params = objectMapper .convertValue (action .get ("params" ), Map .class );
14593
146- log .info (dateCustom + " " + bld );
147- log .info (dateCustom + " " + bld );
94+ //log.info(params2.get("dateCustom").toString() + " " + params2.get("bld").toString());
95+ String dateCustom = params .get ("dateCustom" ).toString ();
96+ String bld = params .get ("bld" ).toString ();
14897
14998 String specMeal = mealService .getSpecKorMeal (dateCustom , bld );
15099 Map <String , Object > responseBody = mealService .responseMeal (specMeal );
151100
152- // if need to stratify.
153- // ObjectMapper objectMapper = new ObjectMapper();
154- // String result = objectMapper.writeValueAsString(responseBody);
155-
156101 return responseBody ;
157102 }
158103
159104 @ PostMapping ("/speceng" )
160- public Map <String , Object > readSpecEngMeal (@ RequestBody Map <String , Map < String , Map < String , Object >> > requestBody ) throws JsonProcessingException {
161- // input : 날짜요일내일 + 아점저 + 1/2학
105+ public Map <String , Object > readSpecEngMeal (@ RequestBody Map <String , Object > requestBody ) throws JsonProcessingException {
106+ // input : 날짜요일내일 + 아점저
162107 // output : 영어 식단이 포함된 JSON (단, JSON은 카톡 서버가 받을 수 있는 형식이여야 함.)
163108
164- Map <String , Map <String , Object >> action = requestBody .get ("action" );
165- Map <String , Object > params = action .get ("params" );
166- String dateCustom = (String ) params .get ("dateCustom" );
167- String bld = (String ) params .get ("bld" );
109+ ObjectMapper objectMapper = new ObjectMapper ();
110+ Map <String , Object > action = objectMapper .convertValue (requestBody .get ("action" ), Map .class );
111+ Map <String , Object > params = objectMapper .convertValue (action .get ("params" ), Map .class );
168112
169- log .info (dateCustom + " " + bld );
113+ //log.info(params2.get("dateCustom").toString() + " " + params2.get("bld").toString());
114+ String dateCustom = params .get ("dateCustom" ).toString ();
115+ String bld = params .get ("bld" ).toString ();
170116
171117 String specMeal = mealService .getSpecEngMeal (dateCustom , bld );
172118 Map <String , Object > responseBody = mealService .responseMeal (specMeal );
173119
174- // if need to stratify.
175- // ObjectMapper objectMapper = new ObjectMapper();
176- // String result = objectMapper.writeValueAsString(responseBody);
177-
178120 return responseBody ;
179121 }
180122
0 commit comments