Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public interface CustomWeeklyGoalRepository {

List<WeeklyGoal> 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<WeeklyGoal> findWeeklyGoalById(@Param("id") Long id);
}
Loading