Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] 메인 다가올 일정(1개) 조회 API - #58 #59

Merged
merged 7 commits into from
Jul 11, 2024
Merged

Conversation

sjk4618
Copy link
Member

@sjk4618 sjk4618 commented Jul 10, 2024

🔥Pull requests

⛳️ 작업한 브랜치

👷 작업한 내용

  • 메인 화면에서 보이는 가장 가까운 일정 가져오는 API 구현했습니다.
  • 현재시간으로부터 가장 가까운 날짜와 디데이, 그리고 month와 day로 나누어주었습니다.
    //가장 가까운 데이트 가져오기
    private Date findNearestDate(Long userId, LocalDate currentDate, LocalTime currentTime) {
        return dateRepository.findFirstByUserIdAndDateAfterOrDateAndStartAtAfterOrderByDateAscStartAtAsc(userId, currentDate, currentDate, currentTime)
                .orElseThrow(() -> new EntityNotFoundException(FailureCode.DATE_NOT_FOUND));
    }
    
public interface DateRepository extends JpaRepository<Date, Long> {
    Optional<Date> findFirstByUserIdAndDateAfterOrDateAndStartAtAfterOrderByDateAscStartAtAsc(
            Long userId, LocalDate currentDate, LocalDate sameDay, LocalTime currentTime);
}    

📟 관련 이슈

Copy link
Member

@rlarlgnszx rlarlgnszx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다!!1

@@ -10,7 +10,7 @@ public record DateCreateReq(
String title,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd", timezone = "Asia/Seoul")
LocalDate date,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "Asia/Seoul")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "hh:mm a", timezone = "Asia/Seoul")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

date에서 a값도 불필요하게 받아야 하는것 같습니다!
a를 빼주셔도 좋을 것 같아요!

String dateName,
int month,
int day,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "hh:mm a", timezone = "Asia/Seoul")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 a를 안받아주셔도 12:00 이렇게 매핑될 것 같습니다!

@@ -10,7 +10,7 @@ public record DateCreateReq(
String title,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd", timezone = "Asia/Seoul")
LocalDate date,
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "hh:mm a", timezone = "Asia/Seoul")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "Asia/Seoul")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

엇 빼셨군요? 순서대로 읽다보니 못봤습니다 ㅎㅅㅎ..!
굿! 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ㅋㅋㅋㅋㅋㅋㅋ굿!

Comment on lines 11 to 13
Optional<Date> findFirstByUserIdAndDateAfterOrDateAndStartAtAfterOrderByDateAscStartAtAsc(
Long userId, LocalDate currentDate, LocalDate sameDay, LocalTime currentTime);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JPA 응용 좋아요 ! 👍

Comment on lines 105 to 114
private int calculateDDay(LocalDate eventDate, LocalDate currentDate) {
if (eventDate.isEqual(currentDate)) {
return 0;
} else {
return (int) ChronoUnit.DAYS.between(currentDate, eventDate);
}
}

//가장 가까운 데이트 가져오기
private Date findNearestDate(final Long userId, final LocalDate now) {
return dateRepository.findTopByUserIdAndDateAfterOrderByDateAscStartAtAsc(userId, now)
.orElseThrow(() -> new EntityNotFoundException(FailureCode.NEAREST_DATE_NOT_FOUND));
private Date findNearestDate(Long userId, LocalDate currentDate, LocalTime currentTime) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 final 키워드 붙여주시면 감사하겠습니다!

Copy link
Contributor

@gardening-y gardening-y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다~!

sjk4618 added 2 commits July 12, 2024 04:44
# Conflicts:
#	dateroad-api/src/main/java/org/dateroad/date/api/DateController.java
#	dateroad-api/src/main/java/org/dateroad/date/service/DateRepository.java
#	dateroad-api/src/main/java/org/dateroad/date/service/DateService.java
#	dateroad-common/src/main/java/org/dateroad/code/FailureCode.java
@sjk4618 sjk4618 merged commit 7807f70 into develop Jul 11, 2024
1 check passed
@sjk4618 sjk4618 deleted the feature/#58 branch July 11, 2024 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] 메인 다가올 일정(1개) 조회 API
3 participants