[ fix ] : #427 블로그의 게시글 리스트 최신순, 추천순에 첨부이미지 썸네일로 연결되게 백엔드 수정#428
[ fix ] : #427 블로그의 게시글 리스트 최신순, 추천순에 첨부이미지 썸네일로 연결되게 백엔드 수정#428
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
|
||
| // Redis 의존성 | ||
| implementation ("org.springframework.boot:spring-boot-starter-data-redis") | ||
| // implementation ("org.springframework.boot:spring-boot-starter-data-redis") |
There was a problem hiding this comment.
Redis 의존성을 주석 처리했습니다. Redis를 사용하지 않는다면 문제없지만, 추후 Redis를 사용할 계획이 있다면 주석을 해제해야 합니다. 사용 여부를 명확히 결정하고 주석을 남겨주세요. 사용하지 않는다면, 왜 사용하지 않는지에 대한 이유를 추가로 코멘트로 남겨주는 것이 좋습니다.
| private String imageUrl; | ||
| private double score; | ||
|
|
||
| private String content; // 추가 |
There was a problem hiding this comment.
PostResponseDto에 content, username, categoryId, category 필드를 추가했습니다. username과 category는 user.getNickname() 또는 user.getName(), category.getName()과 같이 적절한 getter 메소드를 사용하여 값을 설정해야 합니다. null값 처리에 대한 고려가 필요하며, 필드에 대한 자세한 설명(Javadoc)을 추가하는 것이 좋습니다.
| .viewCount(post.getView()) | ||
| .createdAt(post.getCreatedAt()) | ||
| .modifiedAt(post.getModifiedAt()) | ||
| .imageUrl(post.getImageList().isEmpty() ? null : post.getImageList().get(0).getImageUrl()) // 추가! |
There was a problem hiding this comment.
imageUrl 설정 부분에 post.getImageList().isEmpty() ? null : post.getImageList().get(0).getImageUrl() 를 추가했습니다. 이미지 목록이 비어있는 경우 null을 반환하는 것은 좋은 방법입니다. 하지만, getImageList().get(0) 부분은 isEmpty() 체크를 이미 했으므로 IndexOutOfBoundsException 발생 가능성은 낮지만, 더 안전하게 post.getImageList().stream().findFirst().map(image -> image.getImageUrl()).orElse(null) 과 같이 Optional을 활용하는 것이 좋습니다. 코드 가독성을 높이는 방향으로 개선하는 것을 추천합니다.
| .viewCount(post.getView()) | ||
| .createdAt(post.getCreatedAt()) | ||
| .modifiedAt(post.getModifiedAt()) | ||
| .imageUrl(post.getImageList().isEmpty() ? null : post.getImageList().get(0).getImageUrl()) // 추가 |
There was a problem hiding this comment.
504번 라인과 동일한 문제입니다. Optional을 활용하여 IndexOutOfBoundsException 예외 발생 가능성을 제거하고 코드 가독성을 높이는 것이 좋습니다. post.getImageList().stream().findFirst().map(image -> image.getImageUrl()).orElse(null) 와 같이 변경하는 것을 권장합니다.
블로그 리스트에 첨부이미지 썸네일로 연결되게 백엔드 수정