Skip to content

[BE-201] 레코드 쓴 날짜 반환#158

Merged
kdomo merged 7 commits intodevelopfrom
feature/BE-201
Feb 14, 2023
Merged

[BE-201] 레코드 쓴 날짜 반환#158
kdomo merged 7 commits intodevelopfrom
feature/BE-201

Conversation

@kdomo
Copy link
Copy Markdown
Member

@kdomo kdomo commented Feb 10, 2023

관련 이슈 번호

설명

달력 버튼을 클릭 했을 때 로그인 된 사용자의 레코드 쓴 날짜를 반환해주는 API 입니다.
입력받은 년도와 월의 1일 부터 ~ 입력받은 년도와 월의 마지막일까지 between으로 처리하였습니다

변경사항

질문사항

@kdomo kdomo added ✨ Feature 기능 개발 ✅ Test 테스트 labels Feb 10, 2023
@kdomo kdomo self-assigned this Feb 10, 2023
Comment on lines +418 to +424
TreeSet<Integer> writtenRecordDays = new TreeSet<>();
writtenRecordDays.addAll(
recordRepository.findAllByWriterAndCreatedAtBetween(member, start, end)
.stream().map(
record -> record.getCreatedAt().getDayOfMonth()
).collect(Collectors.toSet())
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
TreeSet<Integer> writtenRecordDays = new TreeSet<>();
writtenRecordDays.addAll(
recordRepository.findAllByWriterAndCreatedAtBetween(member, start, end)
.stream().map(
record -> record.getCreatedAt().getDayOfMonth()
).collect(Collectors.toSet())
);
TreeSet<Integer> writtenRecordDays = recordRepository.findAllByWriterAndCreatedAtBetween(member, start, end)
.stream()
.map(record -> record.getCreatedAt().getDayOfMonth())
.collect(Collectors.toCollection(TreeSet::new));

요렇게 줄일 수 있을 거 같네용

Comment on lines +409 to +416
LocalDate standardDate = LocalDate.of(
writtenRecordDayRequestDto.getYearMonth().getYear(),
writtenRecordDayRequestDto.getYearMonth().getMonth(),
1
);

LocalDateTime start = getStartOfDay(standardDate.withDayOfMonth(1));
LocalDateTime end = getEndOfDay(standardDate.withDayOfMonth(standardDate.lengthOfMonth()));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

이 부분을 DateTimeUtil에 메소드를 정의해서 빼는 방법으로 가면 좋을거 같네요

- WrittenRecordDayRequestDto.java 파일 필드 값 YearMonth에서 LocalDateTime으로 통일 하였습니다
- RecordController.java 파일 getWrittenRecordDays 메서드 반환 값 Set<Integer>에서 WrittenRecordDayResponseDto로 변경하였습니다
LocalDateTime 필드에 `@DateTimeFormat(pattern = "yyyy-MM")`을 활용하여 yyyy-MM 형식으로 받아보려고 하였으나
IllegalArgumentException 발생하여 YearMonth로 다시 변경하였습니다.

ErrorMessage: Failed to convert value of type 'java.lang.String' to required type 'java.time.LocalDateTime'
@kdomo kdomo merged commit 8f62026 into develop Feb 14, 2023
@kdomo kdomo deleted the feature/BE-201 branch February 14, 2023 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 기능 개발 ✅ Test 테스트

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants