Skip to content
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 @@ -26,11 +26,12 @@ public interface AttendanceRecordRepository extends JpaRepository<AttendanceReco
/* 배치 업서트(ON CONFLICT) — meeting_id 기준 */
@Modifying
@Query(value = """
INSERT INTO public.attendance_records (meeting_id, user_id, present, updated_at)
SELECT :meetingId, u, :present, NOW()
FROM unnest(:userIds) AS u
ON CONFLICT (meeting_id, user_id)
DO UPDATE SET present = EXCLUDED.present, updated_at = NOW()
INSERT INTO public.attendance_records (meeting_id, user_id, present, updated_at)
SELECT :meetingId, uid, :present, NOW()
FROM unnest(CAST(:userIds AS bigint[])) AS uid
ON CONFLICT (meeting_id, user_id)
DO UPDATE SET present = EXCLUDED.present, updated_at = NOW()
""", nativeQuery = true)
int upsertBatchByMeetingId(@Param("meetingId") Long meetingId, @Param("userIds") List<Long> userIds, @Param("present") boolean present);
int upsertBatchByMeetingId(@Param("meetingId") Long meetingId, @Param("userIds") Long[] userIds, // 👈 배열
@Param("present") boolean present);
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ public long setAttendance(String date, List<Long> userIds, boolean present) {

LocalDate d = LocalDate.parse(date);
Long meetingId = ensureMeetingAndGetId(d);
int affected = attendanceRecordRepository.upsertBatchByMeetingId(meetingId, userIds, present);

Long[] arr = userIds.toArray(Long[]::new); // ✅ List -> Array
int affected = attendanceRecordRepository
.upsertBatchByMeetingId(meetingId, arr, present);
return Math.max(affected, 0);
}

Expand Down
Loading