Skip to content

Commit

Permalink
refactor: edit get calendar response
Browse files Browse the repository at this point in the history
  • Loading branch information
Chan531 committed Dec 4, 2024
1 parent 61fef6a commit 24851bd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.soptie.server.api.controller;

import java.security.Principal;
import java.time.LocalDate;
import java.util.Map;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -11,7 +13,7 @@

import com.soptie.server.api.controller.docs.CalendarApiDocs;
import com.soptie.server.api.controller.dto.response.SuccessResponse;
import com.soptie.server.api.controller.dto.response.calendar.GetCalendarResponse;
import com.soptie.server.api.controller.dto.response.calendar.DateHistoryResponse;
import com.soptie.server.api.controller.generic.SuccessMessage;
import com.soptie.server.domain.calendar.CalendarService;

Expand All @@ -27,7 +29,7 @@ public class CalendarApi implements CalendarApiDocs {

@ResponseStatus(HttpStatus.OK)
@GetMapping
public SuccessResponse<GetCalendarResponse> getCalendar(
public SuccessResponse<Map<LocalDate, DateHistoryResponse>> getCalendar(
final Principal principal,
@RequestParam final int year,
@RequestParam final int month
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.soptie.server.api.controller.docs;

import java.security.Principal;
import java.time.LocalDate;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestParam;

import com.soptie.server.api.controller.dto.response.ErrorResponse;
import com.soptie.server.api.controller.dto.response.SuccessResponse;
import com.soptie.server.api.controller.dto.response.calendar.GetCalendarResponse;
import com.soptie.server.api.controller.dto.response.calendar.DateHistoryResponse;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand All @@ -33,7 +35,7 @@ public interface CalendarApiDocs {
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
SuccessResponse<GetCalendarResponse> getCalendar(
SuccessResponse<Map<LocalDate, DateHistoryResponse>> getCalendar(
@Parameter(hidden = true) Principal principal,
@Parameter(
name = "year",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.springframework.transaction.annotation.Transactional;

import com.soptie.server.api.controller.dto.response.calendar.DateHistoryResponse;
import com.soptie.server.api.controller.dto.response.calendar.GetCalendarResponse;
import com.soptie.server.domain.membermission.MissionHistory;
import com.soptie.server.domain.memberroutine.RoutineHistory;
import com.soptie.server.domain.memo.Memo;
Expand Down Expand Up @@ -47,7 +46,7 @@ public class CalendarService {
private final MissionAdapter missionAdapter;
private final ChallengeAdapter challengeAdapter;

public GetCalendarResponse getCalendar(final long memberId, final int year, final int month) {
public Map<LocalDate, DateHistoryResponse> getCalendar(final long memberId, final int year, final int month) {
memberAdapter.findById(memberId);
val startDateTime = LocalDateTime.of(year, month, 1, 0, 0);
val endDateTime = startDateTime.plusMonths(1).withDayOfMonth(1).minusSeconds(1);
Expand Down Expand Up @@ -99,14 +98,13 @@ private Map<LocalDate, List<MissionHistory>> getMissions(
));
}

private GetCalendarResponse getHistories(
private Map<LocalDate, DateHistoryResponse> getHistories(
final Map<LocalDate, Memo> memos,
final Map<LocalDate, List<RoutineHistory>> routines,
final Map<LocalDate, List<MissionHistory>> missions
) {
val dates = getDates(memos, routines, missions);
val dateAndHistories = getDateAndHistories(dates, memos, routines, missions);
return GetCalendarResponse.of(dateAndHistories);
return getDateAndHistories(dates, memos, routines, missions);
}

private Set<LocalDate> getDates(
Expand Down

0 comments on commit 24851bd

Please sign in to comment.