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

Fix: 크롤링 URL 중복 검증 요청 시, URL 값으로만 검증되도록 수정 #32

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading