-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 여러 팀플래이스 아이디의 기간 내 일정들 조회 기능 구현 * feat: 사용자가 속한 모든팀의 기간 내 일정 조회 서비스 구현 * refactor: 중복코드 메서드 분리 * feat: 회원의 전체 일정 조회 api구현 * refactor: Param annotation 제거 * refactor: 일정조회 테스트 클래스 명 수정 * refactor: 캘린더 기간을 나타내는 객체 분리 - CalendarPeriod 레코드 생성 - 기간계산 로직 분리 * test: 누락된 테스트 어노테이션 제거
- Loading branch information
Showing
12 changed files
with
263 additions
and
25 deletions.
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
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
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
31 changes: 31 additions & 0 deletions
31
...java/team/teamby/teambyteam/schedule/application/dto/ScheduleWithTeamPlaceIdResponse.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,31 @@ | ||
package team.teamby.teambyteam.schedule.application.dto; | ||
|
||
import team.teamby.teambyteam.schedule.domain.Schedule; | ||
import team.teamby.teambyteam.schedule.domain.Span; | ||
|
||
import java.time.format.DateTimeFormatter; | ||
|
||
public record ScheduleWithTeamPlaceIdResponse( | ||
Long id, | ||
Long teamPlaceId, | ||
String title, | ||
String startDateTime, | ||
String endDAteTime | ||
) { | ||
private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm"; | ||
|
||
public static ScheduleWithTeamPlaceIdResponse of(final Schedule schedule) { | ||
final Span span = schedule.getSpan(); | ||
final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DATE_TIME_FORMAT); | ||
final String startDateTime = span.getStartDateTime().format(dateTimeFormatter); | ||
final String endDateTime = span.getEndDateTime().format(dateTimeFormatter); | ||
|
||
return new ScheduleWithTeamPlaceIdResponse( | ||
schedule.getId(), | ||
schedule.getTeamPlaceId(), | ||
schedule.getTitle().getValue(), | ||
startDateTime, | ||
endDateTime | ||
); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ava/team/teamby/teambyteam/schedule/application/dto/SchedulesWithTeamPlaceIdResponse.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,16 @@ | ||
package team.teamby.teambyteam.schedule.application.dto; | ||
|
||
import team.teamby.teambyteam.schedule.domain.Schedule; | ||
|
||
import java.util.List; | ||
|
||
public record SchedulesWithTeamPlaceIdResponse( | ||
List<ScheduleWithTeamPlaceIdResponse> schedules | ||
) { | ||
public static SchedulesWithTeamPlaceIdResponse of(final List<Schedule> schedules) { | ||
return new SchedulesWithTeamPlaceIdResponse(schedules.stream() | ||
.map(ScheduleWithTeamPlaceIdResponse::of) | ||
.toList() | ||
); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
backend/src/main/java/team/teamby/teambyteam/schedule/domain/CalendarPeriod.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,22 @@ | ||
package team.teamby.teambyteam.schedule.domain; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.LocalTime; | ||
|
||
public record CalendarPeriod( | ||
LocalDateTime startDateTime, | ||
LocalDateTime endDatetime | ||
) { | ||
private static final int FIRST_DAY_OF_MONTH = 1; | ||
private static final LocalTime START_TIME_OF_DAY = LocalTime.of(0, 0, 0); | ||
public static final int NEXT_MONTH_OFFSET = 1; | ||
|
||
public static CalendarPeriod of(final int year, final int month) { | ||
final LocalDate startDate = LocalDate.of(year, month, FIRST_DAY_OF_MONTH); | ||
final LocalDate endDate = startDate.plusMonths(NEXT_MONTH_OFFSET).withDayOfMonth(FIRST_DAY_OF_MONTH); | ||
|
||
return new CalendarPeriod(LocalDateTime.of(startDate, START_TIME_OF_DAY), LocalDateTime.of(endDate, START_TIME_OF_DAY)); | ||
} | ||
|
||
} |
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
31 changes: 31 additions & 0 deletions
31
.../main/java/team/teamby/teambyteam/schedule/presentation/MyCalendarScheduleController.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,31 @@ | ||
package team.teamby.teambyteam.schedule.presentation; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import team.teamby.teambyteam.member.configuration.AuthPrincipal; | ||
import team.teamby.teambyteam.member.configuration.dto.MemberEmailDto; | ||
import team.teamby.teambyteam.schedule.application.ScheduleService; | ||
import team.teamby.teambyteam.schedule.application.dto.SchedulesWithTeamPlaceIdResponse; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/my-calendar") | ||
public class MyCalendarScheduleController { | ||
|
||
private final ScheduleService scheduleService; | ||
|
||
@GetMapping("/schedules") | ||
public ResponseEntity<SchedulesWithTeamPlaceIdResponse> findSchedulesInPeriod( | ||
@AuthPrincipal final MemberEmailDto memberEmailDto, | ||
@RequestParam final Integer year, | ||
@RequestParam final Integer month | ||
) { | ||
final SchedulesWithTeamPlaceIdResponse responseBody = scheduleService.findScheduleInPeriod(memberEmailDto, year, month); | ||
|
||
return ResponseEntity.ok(responseBody); | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -11,10 +11,8 @@ | |
import org.springframework.test.context.jdbc.Sql; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import team.teamby.teambyteam.fixtures.ScheduleFixtures; | ||
import team.teamby.teambyteam.schedule.application.dto.ScheduleRegisterRequest; | ||
import team.teamby.teambyteam.schedule.application.dto.ScheduleResponse; | ||
import team.teamby.teambyteam.schedule.application.dto.SchedulesResponse; | ||
import team.teamby.teambyteam.schedule.application.dto.ScheduleUpdateRequest; | ||
import team.teamby.teambyteam.member.configuration.dto.MemberEmailDto; | ||
import team.teamby.teambyteam.schedule.application.dto.*; | ||
import team.teamby.teambyteam.schedule.domain.Schedule; | ||
import team.teamby.teambyteam.schedule.domain.ScheduleRepository; | ||
import team.teamby.teambyteam.schedule.exception.ScheduleException; | ||
|
@@ -146,6 +144,36 @@ void firstAndLastDateScheduleFind() { | |
} | ||
} | ||
|
||
@Nested | ||
@DisplayName("통합 캘린더 정보 조회 시") | ||
class FindSchedulesByUser { | ||
|
||
@Test | ||
@DisplayName("통합 캘린더 정보조회를 성공한다.") | ||
void success() { | ||
// given | ||
// member who participate in team 2, 3 | ||
final MemberEmailDto memberEmailDto = new MemberEmailDto("[email protected]"); | ||
final int year = 2023; | ||
final int month = 6; | ||
|
||
// when | ||
final SchedulesWithTeamPlaceIdResponse scheduleInPeriod = scheduleService.findScheduleInPeriod(memberEmailDto, year, month); | ||
final List<ScheduleWithTeamPlaceIdResponse> scheduleResponses = scheduleInPeriod.schedules(); | ||
|
||
//then | ||
SoftAssertions.assertSoftly(softly -> { | ||
softly.assertThat(scheduleResponses).hasSize(5); | ||
softly.assertThat(scheduleResponses.get(0).title()).isEqualTo("3번 팀플 6월 첫날"); | ||
softly.assertThat(scheduleResponses.get(1).title()).isEqualTo("2번 팀플 6월 첫날"); | ||
softly.assertThat(scheduleResponses.get(2).title()).isEqualTo("3번 팀플 A"); | ||
softly.assertThat(scheduleResponses.get(3).title()).isEqualTo("2번 팀플 6월 어느날"); | ||
softly.assertThat(scheduleResponses.get(4).title()).isEqualTo("3번 팀플 B"); | ||
}); | ||
} | ||
|
||
} | ||
|
||
@Nested | ||
@DisplayName("일정 등록 시") | ||
class RegisterSchedule { | ||
|
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
Oops, something went wrong.