Skip to content

Commit f2fb389

Browse files
김산김산
authored andcommitted
[#7] Feat: create target date api for FE
1 parent c8a1cfb commit f2fb389

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

src/main/java/com/example/helper/controller/MealController.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import java.util.Map;
1616

1717

18-
@RestController
18+
@RestController // @Controller + @ResponseBody. return이 view가 아닌, http body에 직접 쓰여짐.
1919
@RequestMapping(path = "/meals", produces = "application/json;charset=UTF-8")
2020
@Slf4j
2121
public class MealController {
@@ -29,11 +29,12 @@ public String hello() {
2929
}
3030

3131
@PostMapping("/test")
32-
public @ResponseBody void test(String testStr) {
32+
public void test(String testStr) {
3333
log.info(testStr);
3434
}
35+
3536
@PostMapping("/create")
36-
public @ResponseBody String createMeal(@RequestBody Mealdto mealDto) {
37+
public String createMeal(@RequestBody Mealdto mealDto) {
3738
// input : 식단 json
3839
// output : None
3940

@@ -48,7 +49,7 @@ public String hello() {
4849
}
4950

5051
@PostMapping("/kor")
51-
public @ResponseBody String readKorMeal() throws JsonProcessingException {
52+
public String readKorMeal() throws JsonProcessingException {
5253
// input : None (먼저 서버에서 현재 시간 측정)
5354
// output : 한국어 식단이 포함된 JSON (단, JSON은 카톡 서버가 받을 수 있는 형식이여야 함.)
5455

@@ -70,7 +71,7 @@ public String hello() {
7071
// }
7172
// };
7273

73-
Map<String, Object> simpleText = new HashMap<>();
74+
Map<String, Object> simpleText = new HashMap<>();
7475
simpleText.put("text", nowMeal);
7576

7677
Map<String, Object> simpleTextWrapper = new HashMap<>();
@@ -93,7 +94,7 @@ public String hello() {
9394
}
9495

9596
@PostMapping("/eng")
96-
public @ResponseBody String readEngMeal() throws JsonProcessingException {
97+
public String readEngMeal() throws JsonProcessingException {
9798
// input : None (먼저 서버에서 현재 시간 측정)
9899
// output : 영어 식단이 포함된 JSON (단, JSON은 카톡 서버가 받을 수 있는 형식이여야 함.)
99100

@@ -115,7 +116,7 @@ public String hello() {
115116
// }
116117
// };
117118

118-
Map<String, Object> simpleText = new HashMap<>();
119+
Map<String, Object> simpleText = new HashMap<>();
119120
simpleText.put("text", nowMeal);
120121

121122
Map<String, Object> simpleTextWrapper = new HashMap<>();
@@ -138,7 +139,7 @@ public String hello() {
138139
}
139140

140141
@PostMapping("/speckor")
141-
public @ResponseBody String readSpecKorMeal() throws JsonProcessingException {
142+
public String readSpecKorMeal() throws JsonProcessingException {
142143
// input : 날짜요일내일 + 아점저 + 1/2학
143144
// output : 한국어 식단이 포함된 JSON (단, JSON은 카톡 서버가 받을 수 있는 형식이여야 함.)
144145

@@ -160,7 +161,7 @@ public String hello() {
160161
// }
161162
// };
162163

163-
Map<String, Object> simpleText = new HashMap<>();
164+
Map<String, Object> simpleText = new HashMap<>();
164165
simpleText.put("text", specMeal);
165166

166167
Map<String, Object> simpleTextWrapper = new HashMap<>();
@@ -183,7 +184,7 @@ public String hello() {
183184
}
184185

185186
@PostMapping("/speceng")
186-
public @ResponseBody String readSpecEngMeal() throws JsonProcessingException {
187+
public String readSpecEngMeal() throws JsonProcessingException {
187188
// input : 날짜요일내일 + 아점저 + 1/2학
188189
// output : 영어 식단이 포함된 JSON (단, JSON은 카톡 서버가 받을 수 있는 형식이여야 함.)
189190

@@ -205,7 +206,7 @@ public String hello() {
205206
// }
206207
// };
207208

208-
Map<String, Object> simpleText = new HashMap<>();
209+
Map<String, Object> simpleText = new HashMap<>();
209210
simpleText.put("text", specMeal);
210211

211212
Map<String, Object> simpleTextWrapper = new HashMap<>();
@@ -226,4 +227,12 @@ public String hello() {
226227

227228
return result;
228229
}
230+
231+
@GetMapping("/date")
232+
public List<DateMealDto> DateMealRead(DateReqDto dateReqDto) {
233+
234+
List<DateMealDto> dateMealDtoList = mealService.getDateMeal(dateReqDto);
235+
236+
return dateMealDtoList;
237+
}
229238
}

src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/helper_db
33
spring.datasource.username=helper
44
spring.datasource.password=12345678
55
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
6-
spring.jpa.hibernate.ddl-auto=create
6+
spring.jpa.hibernate.ddl-auto=validate
77

88
spring.jpa.show-sql=true
99
spring.jpa.properties.hibernate.format_sql=true

0 commit comments

Comments
 (0)