Skip to content

Commit

Permalink
Fix: 크롤링 URL 중복 검증 요청 시, URL 값으로만 검증되도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
yxhwxn committed Aug 10, 2024
1 parent 5c74f6f commit 6a3a04f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class CrawlApi {
"Response<br>" +
"- 요청된 URL과 중복된 댓글 수집 이력이 있을 경우 '검증 및 확인되었습니다.' 출력<br>" +
"- 요청된 URL과 중복된 댓글 수집 이력이 없을 경우 '수집 이력이 없습니다.' 출력")
public ResponseEntity<ApiResponse<String>> checkExistingComments(@RequestParam String url, @RequestParam Long eventId, @CurrentAccount Account account) {
String message = crawlService.checkExistingComments(url, eventId, account.userId());
public ResponseEntity<ApiResponse<String>> checkExistingComments(@RequestParam String url, @CurrentAccount Account account) {
String message = crawlService.checkExistingComments(url, account.userId());
if (message != null) {
return ResponseEntity.ok(ApiResponse.of(ResponseCode.SUCCESS, message));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,11 @@ public class CrawlService {
private final EventRepository eventRepository;
private final MemberRepository memberRepository;

public String checkExistingComments(String url, Long eventId, String userId) {
public String checkExistingComments(String url, String userId) {
Member member = memberRepository.findByUserIdAndStatusNot(userId, UserStatus.DELETED)
.orElseThrow(() -> new IllegalArgumentException("Member not found"));

Event event = eventRepository.findByIdAndMemberId(eventId, member.getId())
.orElseThrow(() -> new IllegalArgumentException("Event not found"));

List<Comment> existingComments = commentRepository.findByUrlAndEventId(url, eventId);
List<Comment> existingComments = commentRepository.findByUrl(url);
if (!existingComments.isEmpty()) {
LocalDateTime firstCommentDate = existingComments.get(0).getCreatedAt();
return "동일한 URL의 댓글을 " + firstCommentDate.toLocalDate() + " 일자에 수집한 이력이 있습니다.";
Expand Down

0 comments on commit 6a3a04f

Please sign in to comment.