-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from UMC-CommonPlant/feat/#74_Calendar
[Feat] Calendar: 월별 조회
- Loading branch information
Showing
11 changed files
with
602 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/main/java/com/umc/commonplant/domain/calendar/controller/CalendarController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.umc.commonplant.domain.calendar.controller; | ||
|
||
import com.umc.commonplant.domain.Jwt.JwtService; | ||
import com.umc.commonplant.domain.calendar.dto.CalendarDto; | ||
import com.umc.commonplant.domain.calendar.service.CalendarService; | ||
import com.umc.commonplant.domain.memo.dto.MemoDto; | ||
import com.umc.commonplant.domain.place.dto.PlaceDto; | ||
import com.umc.commonplant.domain.plant.dto.PlantDto; | ||
import com.umc.commonplant.domain.user.entity.User; | ||
import com.umc.commonplant.domain.user.service.UserService; | ||
import com.umc.commonplant.global.dto.JsonResponse; | ||
import io.swagger.v3.core.util.Json; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@Slf4j | ||
@RequestMapping("/calendar") | ||
@RequiredArgsConstructor | ||
@RestController | ||
public class CalendarController { | ||
|
||
private final CalendarService calendarService; | ||
private final JwtService jwtService; | ||
private final UserService userService; | ||
|
||
@GetMapping | ||
public ResponseEntity<JsonResponse> getCalendarByDate(@RequestParam("year") String year, | ||
@RequestParam("month") String month, | ||
@RequestParam("day") String day) { | ||
|
||
return ResponseEntity.ok(new JsonResponse(true, 200, "getCalendarByDate", null)); | ||
} | ||
|
||
@GetMapping("/monthly") | ||
public ResponseEntity<JsonResponse> getCalendarByMonth(@RequestParam("year") String year, | ||
@RequestParam("month") String month) { | ||
String uuid = jwtService.resolveToken(); | ||
User user = userService.getUser(uuid); | ||
|
||
CalendarDto.getMyCalendarRes monthlyCalendar = calendarService.getMyCalendar(user, year, month); | ||
|
||
return ResponseEntity.ok(new JsonResponse(true, 200, "getCalendarByMonth", monthlyCalendar)); | ||
} | ||
|
||
@GetMapping("/place") | ||
public ResponseEntity<JsonResponse> getCalendarByPlace() { | ||
String uuid = jwtService.resolveToken(); | ||
User user = userService.getUser(uuid); | ||
|
||
List<CalendarDto.getMyCalendarPlaceListRes> placeList = calendarService.getPlaceNameListByUser(user); | ||
|
||
return ResponseEntity.ok(new JsonResponse(true, 200, "getPlaceList", placeList)); | ||
} | ||
|
||
@GetMapping("/place/plant") | ||
public ResponseEntity<JsonResponse> getCalendarByPlaceAndPlant(@RequestParam("code") String code) { | ||
String uuid = jwtService.resolveToken(); | ||
User user = userService.getUser(uuid); | ||
|
||
List<CalendarDto.getMyCalendarPlantListRes> plantList = calendarService.getPlantListByPlace(user, code); | ||
|
||
return ResponseEntity.ok(new JsonResponse(true, 200, "getPlantList", plantList)); | ||
} | ||
|
||
@GetMapping("/place/plant/memo") | ||
public ResponseEntity<JsonResponse> getCalendarByPlaceAndPlantAndMemo(@RequestParam("code") String code, | ||
@RequestParam("plant") Long plantIdx) { | ||
String uuid = jwtService.resolveToken(); | ||
User user = userService.getUser(uuid); | ||
|
||
List<CalendarDto.getMyCalendarMemoRes> memoList = calendarService.getAllMemoByPlant(plantIdx); | ||
|
||
return ResponseEntity.ok(new JsonResponse(true, 200, "getMemoList", memoList)); | ||
} | ||
|
||
} |
107 changes: 107 additions & 0 deletions
107
src/main/java/com/umc/commonplant/domain/calendar/dto/CalendarDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package com.umc.commonplant.domain.calendar.dto; | ||
|
||
import com.umc.commonplant.domain.plant.entity.Plant; | ||
import lombok.*; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
public class CalendarDto { | ||
|
||
/** | ||
* 최종 My Calendar Response | ||
*/ | ||
@NoArgsConstructor | ||
@Getter | ||
public static class getMyCalendarRes{ | ||
private String year; | ||
private String month; | ||
|
||
private List<getMyCalendarEventRes> dateList; | ||
|
||
@Builder | ||
public getMyCalendarRes(String year, String month, List<getMyCalendarEventRes> dateList) { | ||
this.year = year; | ||
this.month = month; | ||
this.dateList = dateList; | ||
} | ||
} | ||
|
||
/** | ||
* 날짜 별로 불러오는 My Calendar 정보 | ||
*/ | ||
@NoArgsConstructor | ||
@Getter | ||
public static class getMyCalendarEventRes { | ||
private int parsedDate; | ||
// @JsonFormat(pattern = "yyyy.MM.dd") | ||
// private LocalDateTime date; | ||
|
||
private boolean nextWatered; | ||
private boolean prevWatered; | ||
private boolean joinPlant; | ||
private boolean writeMemo; | ||
|
||
@Builder | ||
public getMyCalendarEventRes(int parsedDate, boolean nextWatered, boolean prevWatered, | ||
boolean joinPlant, boolean writeMemo) { | ||
this.parsedDate = parsedDate; | ||
this.nextWatered = nextWatered; | ||
this.prevWatered = prevWatered; | ||
this.joinPlant = joinPlant; | ||
this.writeMemo = writeMemo; | ||
} | ||
} | ||
|
||
/** | ||
* My Calendar에 보여줄 Place 리스트 | ||
*/ | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
public static class getMyCalendarPlaceListRes{ | ||
private String name; | ||
} | ||
|
||
/** | ||
* My Calendar에 보여줄 Plant 리스트 | ||
*/ | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
public static class getMyCalendarPlantListRes{ | ||
private String plantName; | ||
private String nickname; | ||
private String imgUrl; | ||
|
||
@Builder | ||
public getMyCalendarPlantListRes(Plant plant){ | ||
this.plantName = plant.getPlantName(); | ||
this.nickname = plant.getNickname(); | ||
this.imgUrl = plant.getImgUrl(); | ||
} | ||
} | ||
|
||
/** | ||
* My Calendar에 보여줄 Memo 리스트 | ||
*/ | ||
@NoArgsConstructor | ||
@Getter | ||
public static class getMyCalendarMemoRes { | ||
private Long memo_idx; | ||
private String content; | ||
private String imgUrl; | ||
private String writer; | ||
private LocalDateTime created_at; | ||
|
||
@Builder | ||
public getMyCalendarMemoRes(Long memo_idx, String content, String imgUrl, String writer, LocalDateTime created_at) { | ||
this.memo_idx = memo_idx; | ||
this.content = content; | ||
this.imgUrl = imgUrl; | ||
this.writer = writer; | ||
this.created_at = created_at; | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.