Skip to content

Commit

Permalink
Merge pull request #190 from ITA-OneByte/dev
Browse files Browse the repository at this point in the history
[Release] 일정관리 프론트
  • Loading branch information
dpfls0922 authored Jan 14, 2025
2 parents 260cb2a + 7a3836a commit 24292f3
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import classfit.example.classfit.event.dto.request.EventModalRequest;
import classfit.example.classfit.common.ApiResponse;
import classfit.example.classfit.event.dto.request.EventCreateRequest;
import classfit.example.classfit.event.dto.response.EventModalResponse;
import classfit.example.classfit.event.dto.response.EventMontylyResponse;
import classfit.example.classfit.event.dto.response.EventResponse;
import classfit.example.classfit.event.service.EventService;
Expand Down Expand Up @@ -74,10 +75,10 @@ public ApiResponse<EventResponse> createModalEvent(

@GetMapping("/modal/{eventId}")
@Operation(summary = "모달 일정 상세 조회", description = "모달 일정을 상세조회하는 api 입니다.")
public ApiResponse<EventResponse> getEventDetails(
public ApiResponse<EventModalResponse> getEventDetails(
@PathVariable Long eventId
) {
EventResponse event = eventService.getEvent(eventId);
EventModalResponse event = eventService.getEvent(eventId);
return ApiResponse.success(event, 200, "SUCCESS");
}

Expand Down
17 changes: 17 additions & 0 deletions src/main/java/classfit/example/classfit/event/domain/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import classfit.example.classfit.calendarCategory.domain.CalendarCategory;
import classfit.example.classfit.common.domain.BaseEntity;
import classfit.example.classfit.event.dto.response.EventModalResponse;
import classfit.example.classfit.event.dto.response.EventResponse;
import classfit.example.classfit.eventMember.domain.EventMember;
import classfit.example.classfit.member.domain.Member;
Expand Down Expand Up @@ -140,4 +141,20 @@ public static EventResponse buildEventResponse(Event event) {
event.getEndDate()
);
}

public static EventModalResponse buildModalEventResponse(Event event) {
Long categoryId = (event.getCategory() != null) ? event.getCategory().getId() : null;

return EventModalResponse.of(
event.getId(),
event.getName(),
event.getEventType(),
event.getStartDate(),
event.getEndDate(),
categoryId,
event.getEventRepeatType(),
event.getRepeatEndDate(),
event.isAllDay()
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package classfit.example.classfit.event.dto.response;

import classfit.example.classfit.event.domain.EventRepeatType;
import classfit.example.classfit.event.domain.EventType;
import java.time.LocalDateTime;

public record EventModalResponse
(
Long id,
String name,
EventType eventType,
LocalDateTime startDate,
LocalDateTime endDate,
Long categoryId,
EventRepeatType eventRepeatType,
LocalDateTime repeatEndDate,
boolean isAllDay
) {
public static EventModalResponse of(final Long id, final String name, final EventType eventType, final LocalDateTime startDate, final LocalDateTime endDate, final Long categoryId, final EventRepeatType eventRepeatType, final LocalDateTime repeatEndDate, final boolean isAllDay) {
return new EventModalResponse(id, name, eventType, startDate, endDate, categoryId, eventRepeatType, repeatEndDate, isAllDay);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import classfit.example.classfit.common.exception.ClassfitException;
import classfit.example.classfit.event.domain.Event;
import classfit.example.classfit.event.dto.response.EventModalResponse;
import classfit.example.classfit.event.dto.response.EventMontylyResponse;
import classfit.example.classfit.event.dto.response.EventResponse;
import classfit.example.classfit.event.repository.EventRepository;
Expand All @@ -23,9 +24,9 @@ public class EventGetService {
private final EventRepository eventRepository;

@Transactional(readOnly = true)
public EventResponse getEvent(long eventId) {
public EventModalResponse getEvent(long eventId) {
Event event = getEventById(eventId);
return Event.buildEventResponse(event);
return Event.buildModalEventResponse(event);
}

private Event getEventById(long eventId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public void addRepeatedEvents(Member member, EventCreateRequest request) {
return;
}

LocalDateTime currentStartDate = request.startDate();
LocalDateTime currentEndDate = request.endDate();
LocalDateTime currentStartDate = getNextRepeatDate(request.startDate(), request.eventRepeatType());
LocalDateTime currentEndDate = getNextRepeatDate(request.endDate(), request.eventRepeatType());
LocalDateTime repeatEndDate = request.repeatEndDate().orElse(currentStartDate.plusMonths(6));

generateRepeatedEvents(member, request, currentStartDate, currentEndDate, repeatEndDate);
Expand Down Expand Up @@ -82,8 +82,8 @@ public void addRepeatedModalEvents(Member member, EventModalRequest request) {
return;
}

LocalDateTime currentStartDate = request.startDate();
LocalDateTime currentEndDate = request.endDate();
LocalDateTime currentStartDate = getNextRepeatDate(request.startDate(), request.eventRepeatType());
LocalDateTime currentEndDate = getNextRepeatDate(request.endDate(), request.eventRepeatType());
LocalDateTime repeatEndDate = request.repeatEndDate().orElse(currentStartDate.plusMonths(6));

generateRepeatedModalEvents(member, request, currentStartDate, currentEndDate, repeatEndDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import classfit.example.classfit.event.dto.request.EventCreateRequest;
import classfit.example.classfit.event.dto.request.EventDragUpdate;
import classfit.example.classfit.event.dto.request.EventModalRequest;
import classfit.example.classfit.event.dto.response.EventModalResponse;
import classfit.example.classfit.event.dto.response.EventMontylyResponse;
import classfit.example.classfit.event.dto.response.EventResponse;
import classfit.example.classfit.event.repository.EventRepository;
Expand Down Expand Up @@ -38,7 +39,7 @@ public EventResponse updateEvent(Member member, long eventId, EventModalRequest
return eventUpdateService.updateEvent(member, eventId, request);
}

public EventResponse getEvent(long eventId) {
public EventModalResponse getEvent(long eventId) {
return eventGetService.getEvent(eventId);
}

Expand Down

0 comments on commit 24292f3

Please sign in to comment.