Skip to content

Commit

Permalink
feat: attendee 생성 시 동명이인 처리 api 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
SHEOMM committed Mar 26, 2024
1 parent 7e846a4 commit 57470f6
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import com.waruru.areyouhere.attendee.dto.ClassAttendeesDto;
import com.waruru.areyouhere.attendee.dto.DeleteAttendeesDto;
import com.waruru.areyouhere.attendee.dto.DuplicateCheckAttendeesDto;
import com.waruru.areyouhere.attendee.dto.NewAttendeesDto;
import com.waruru.areyouhere.attendee.service.AttendeeService;
import com.waruru.areyouhere.attendee.service.dto.ClassAttendees;
import com.waruru.areyouhere.attendee.service.dto.DuplicateAttendees;
import com.waruru.areyouhere.common.annotation.LoginRequired;
import java.util.List;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -52,4 +54,11 @@ public ResponseEntity<HttpStatus> delete(@RequestBody DeleteAttendeesDto deleteA
attendeeService.deleteAttendees(deleteAttendeesDto.getAttendeeIds());
return ResponseEntity.ok().build();
}

@LoginRequired
@PostMapping("/duplicate")
public ResponseEntity<DuplicateAttendees> checkDuplicate(@RequestBody DuplicateCheckAttendeesDto duplicateCheckAttendeesDto){
return ResponseEntity.ok(attendeeService.getDuplicateAttendees(duplicateCheckAttendeesDto.getCourseId(), duplicateCheckAttendeesDto.getNewAttendees()));
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.waruru.areyouhere.attendee.dto;

import java.util.List;
import lombok.Getter;


@Getter
public class DuplicateCheckAttendeesDto {
private Long courseId;
private List<String> newAttendees;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.waruru.areyouhere.attendee.dto.AttendeeData;
import com.waruru.areyouhere.attendee.service.dto.ClassAttendees;
import com.waruru.areyouhere.attendee.service.dto.DuplicateAttendees;
import com.waruru.areyouhere.attendee.service.dto.SessionAttendees;
import java.util.List;

Expand All @@ -18,4 +19,6 @@ public interface AttendeeService {
public void deleteAttendees(List<Long> deleteAttendees);

public int getAttendeeByCourseId(Long courseId);

public DuplicateAttendees getDuplicateAttendees(Long courseId, List<String> newAttendees);
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void createAttendees(Long courseId, List<AttendeeData> newAttendees){
attendeeBatchRepository.insertAttendeesBatch(attendees);
}

@Override
public DuplicateAttendees getDuplicateAttendees(Long courseId, List<String> newAttendees){
Set<String> uniqueAttendees = new HashSet<>();
DuplicateAttendees duplicateAttendees = new DuplicateAttendees(new LinkedList<>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
@Service
@RequiredArgsConstructor
@Transactional
@Slf4j
public class CourseServiceImpl implements CourseService {
private final CourseRepository courseRepository;
private final ManagerRepository managerRepository;
Expand Down Expand Up @@ -128,6 +129,7 @@ public Course getCourse(Long courseId) {

private boolean isAttendeesUnique(List<String> attendees) {
Set<String> uniqueAttendees = Set.copyOf(attendees);
log.debug("Attendees: {}", uniqueAttendees);
return uniqueAttendees.size() == attendees.size();
}

Expand Down

0 comments on commit 57470f6

Please sign in to comment.