diff --git a/src/main/java/com/sillim/recordit/calendar/dto/response/CalendarResponse.java b/src/main/java/com/sillim/recordit/calendar/dto/response/CalendarResponse.java index f8e1bae4..b077d3a2 100644 --- a/src/main/java/com/sillim/recordit/calendar/dto/response/CalendarResponse.java +++ b/src/main/java/com/sillim/recordit/calendar/dto/response/CalendarResponse.java @@ -2,9 +2,13 @@ import com.sillim.recordit.calendar.domain.Calendar; -public record CalendarResponse(Long id, String title, String colorHex) { +public record CalendarResponse(Long id, String title, String colorHex, Long categoryId) { public static CalendarResponse from(Calendar calendar) { - return new CalendarResponse(calendar.getId(), calendar.getTitle(), calendar.getColorHex()); + return new CalendarResponse( + calendar.getId(), + calendar.getTitle(), + calendar.getColorHex(), + calendar.getCategory().getId()); } } diff --git a/src/main/java/com/sillim/recordit/goal/dto/response/MonthlyGoalListResponse.java b/src/main/java/com/sillim/recordit/goal/dto/response/MonthlyGoalListResponse.java index 3f998063..22e63bd3 100644 --- a/src/main/java/com/sillim/recordit/goal/dto/response/MonthlyGoalListResponse.java +++ b/src/main/java/com/sillim/recordit/goal/dto/response/MonthlyGoalListResponse.java @@ -2,22 +2,14 @@ import com.sillim.recordit.goal.domain.MonthlyGoal; -public record MonthlyGoalListResponse( - Long id, - String title, - Long categoryId, - String colorHex, - Boolean achieved, - Long calendarId) { +public record MonthlyGoalListResponse(Long id, String title, String colorHex, Boolean achieved) { public static MonthlyGoalListResponse from(final MonthlyGoal monthlyGoal) { return new MonthlyGoalListResponse( monthlyGoal.getId(), monthlyGoal.getTitle(), - monthlyGoal.getCategory().getId(), monthlyGoal.getColorHex(), - monthlyGoal.isAchieved(), - monthlyGoal.getCalendar().getId()); + monthlyGoal.isAchieved()); } } diff --git a/src/main/java/com/sillim/recordit/goal/dto/response/WeeklyGoalDetailsResponse.java b/src/main/java/com/sillim/recordit/goal/dto/response/WeeklyGoalDetailsResponse.java index 5ae77afc..7df9ffd6 100644 --- a/src/main/java/com/sillim/recordit/goal/dto/response/WeeklyGoalDetailsResponse.java +++ b/src/main/java/com/sillim/recordit/goal/dto/response/WeeklyGoalDetailsResponse.java @@ -27,6 +27,7 @@ public static WeeklyGoalDetailsResponse from(final WeeklyGoal weeklyGoal) { .week(weeklyGoal.getWeek()) .startDate(weeklyGoal.getStartDate()) .endDate(weeklyGoal.getEndDate()) + .calendarId(weeklyGoal.getCalendar().getId()) .categoryId(weeklyGoal.getCategory().getId()) .colorHex(weeklyGoal.getColorHex()) .build(); @@ -38,6 +39,7 @@ public static WeeklyGoalDetailsResponse from(final WeeklyGoal weeklyGoal) { .week(weeklyGoal.getWeek()) .startDate(weeklyGoal.getStartDate()) .endDate(weeklyGoal.getEndDate()) + .calendarId(weeklyGoal.getCalendar().getId()) .categoryId(weeklyGoal.getCategory().getId()) .colorHex(weeklyGoal.getColorHex()) .relatedMonthlyGoal( diff --git a/src/main/java/com/sillim/recordit/goal/dto/response/WeeklyGoalResponse.java b/src/main/java/com/sillim/recordit/goal/dto/response/WeeklyGoalResponse.java index 0a53892e..a66b2915 100644 --- a/src/main/java/com/sillim/recordit/goal/dto/response/WeeklyGoalResponse.java +++ b/src/main/java/com/sillim/recordit/goal/dto/response/WeeklyGoalResponse.java @@ -7,10 +7,9 @@ public record WeeklyGoalResponse( Long id, String title, - Long categoryId, + Integer week, String colorHex, Boolean achieved, - Long calendarId, RelatedMonthlyGoalResponse relatedMonthlyGoal) { public static WeeklyGoalResponse from(final WeeklyGoal weeklyGoal) { @@ -19,19 +18,17 @@ public static WeeklyGoalResponse from(final WeeklyGoal weeklyGoal) { return WeeklyGoalResponse.builder() .id(weeklyGoal.getId()) .title(weeklyGoal.getTitle()) - .categoryId(weeklyGoal.getCategory().getId()) + .week(weeklyGoal.getWeek()) .colorHex(weeklyGoal.getColorHex()) .achieved(weeklyGoal.isAchieved()) - .calendarId(weeklyGoal.getCalendar().getId()) .build(); } return WeeklyGoalResponse.builder() .id(weeklyGoal.getId()) .title(weeklyGoal.getTitle()) - .categoryId(weeklyGoal.getCategory().getId()) + .week(weeklyGoal.getWeek()) .colorHex(weeklyGoal.getColorHex()) .achieved(weeklyGoal.isAchieved()) - .calendarId(weeklyGoal.getCalendar().getId()) .relatedMonthlyGoal( RelatedMonthlyGoalResponse.from(weeklyGoal.getRelatedMonthlyGoal().get())) .build(); diff --git a/src/main/java/com/sillim/recordit/goal/repository/CustomWeeklyGoalRepository.java b/src/main/java/com/sillim/recordit/goal/repository/CustomWeeklyGoalRepository.java index 1e2ed5b4..1e522aa0 100644 --- a/src/main/java/com/sillim/recordit/goal/repository/CustomWeeklyGoalRepository.java +++ b/src/main/java/com/sillim/recordit/goal/repository/CustomWeeklyGoalRepository.java @@ -10,6 +10,7 @@ public interface CustomWeeklyGoalRepository { List findWeeklyGoalInMonth(Integer year, Integer month, Long calendarId); - @Query("select wg from WeeklyGoal wg left join fetch wg.calendar where wg.id = :id") + @Query( + "select wg from WeeklyGoal wg left join fetch wg.calendar left join fetch wg.category left join fetch wg.relatedMonthlyGoal where wg.id = :id") Optional findWeeklyGoalById(@Param("id") Long id); }