Skip to content

Commit

Permalink
fix: attendance 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
SHEOMM committed Mar 7, 2024
1 parent b3edf95 commit 72878f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ public interface AttendeeRepository extends JpaRepository<Attendee, Long> {
@Query(value = "SELECT * FROM attendee WHERE attendee.course_id = :courseId And attendee.id NOT IN (SELECT att.attendee_id FROM attendance as att WHERE att.session_id = :sessionId)", nativeQuery = true)
public List<Attendee> findAbsenteeBySessionIdWhenNoRegister(@Param("courseId") Long courseId, @Param("sessionId") Long sessionId);

@Query(value = "SELECT atda.id as attandenceId, atdee.name as AttendeeName, atda.is_attended as AttendanceStatus, atda.created_at as AttendanceTime \n"
@Query(value = "SELECT atda.id as AttendanceId, atdee.name as AttendeeName, atda.is_attended as AttendanceStatus, atda.created_at as AttendanceTime \n"
+ "FROM attendee as atdee \n"
+ "INNER JOIN attendance as atda ON atdee.id = atda.attendee_id \n"
+ "WHERE atda.session_id = :sessionId", nativeQuery = true)
public List<SessionAttendeeInfo> findSessionAttendees(@Param("sessionId") Long sessionId);


@Query(value = "SELECT atda.id as attandenceId, atdee.name as AttendeeName, atda.is_attended as AttendanceStatus, atda.created_at as AttendanceTime \n"
@Query(value = "SELECT atda.id as AttendanceId, atdee.name as AttendeeName, atda.is_attended as AttendanceStatus, atda.created_at as AttendanceTime \n"
+ "FROM attendee as atdee \n"
+ "INNER JOIN attendance as atda ON atdee.id = atda.attendee_id \n"
+ "WHERE atda.session_id = :sessionId \n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import java.util.Collections;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@RequiredArgsConstructor
@Slf4j
public class AttendeeServiceImpl implements AttendeeService{

private final AttendeeRepository attendeeRepository;
Expand Down Expand Up @@ -53,10 +55,11 @@ public void deleteAttendees(List<Long> deleteAttendees){
@Transactional(readOnly = true)
public List<SessionAttendees> getSessionAttendeesIfExistsOrEmpty(Long sessionId){
List<SessionAttendeeInfo> sessionAttendees = attendeeRepository.findSessionAttendees(sessionId);
log.info(sessionAttendees.get(0).getAttendanceId().toString());
return sessionAttendees == null || sessionAttendees.isEmpty() ?
Collections.emptyList()
: sessionAttendees.stream().map(sessionAttendee -> SessionAttendees.builder()
.id(sessionAttendee.getAttendanceId())
.attendanceId(sessionAttendee.getAttendanceId())
.attendeeName(sessionAttendee.getAttendeeName())
.attendanceStatus(sessionAttendee.getAttendanceStatus())
.attendanceTime(sessionAttendee.getAttendanceTime())
Expand All @@ -69,7 +72,7 @@ public List<SessionAttendees> getSessionAbsenteesIfExistsOrEmpty(Long sessionId)
return sessionAttendees == null || sessionAttendees.isEmpty() ?
Collections.emptyList()
: sessionAttendees.stream().map(sessionAttendee -> SessionAttendees.builder()
.id(sessionAttendee.getAttendanceId())
.attendanceId(sessionAttendee.getAttendanceId())
.attendeeName(sessionAttendee.getAttendeeName())
.attendanceStatus(sessionAttendee.getAttendanceStatus())
.attendanceTime(sessionAttendee.getAttendanceTime())
Expand Down

0 comments on commit 72878f5

Please sign in to comment.