feat: event lead rows carry attendance and source, with an attended filter

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-01 21:31:03 +08:00
1 parent cba2929a00
commit 3af5cccd59
16 files changed
+160 -55

No files matched your search

@@ -22,5 +22,7 @@ public record EventLeadDetail(
String notes,
LocalDateTime capturedAt,
List<Long> interestIds,
Long companyId
Long companyId,
LocalDateTime attendedAt,
String source
) {}
@@ -1,5 +1,5 @@
package com.solvway.services.counter.dto;
/** One event's leads, filtered; null or blank filters are ignored. page is 0-based. companyId null means all companies. */
/** One event's leads, filtered; null or blank filters are ignored; attended true or false keeps only attended or not attended. page is 0-based. companyId null means all companies. */
public record EventLeadSearchRequest(Long companyId, long eventUuid, Long salespersonUserId, String temperature,
String status, Long interestId, String leadType, int page, int size) {}
String status, Long interestId, String leadType, Boolean attended, int page, int size) {}
@@ -29,6 +29,8 @@ public interface EventLeadRepository extends JpaRepository<EventLead, Long> {
+ " AND (:temperature IS NULL OR e.temperature = :temperature)"
+ " AND (:status IS NULL OR e.status = :status)"
+ " AND (:leadType IS NULL OR e.leadType = :leadType)"
+ " AND (:attended IS NULL OR (:attended = true AND e.attendedAt IS NOT NULL)"
+ " OR (:attended = false AND e.attendedAt IS NULL))"
+ " AND (:interestId IS NULL OR EXISTS (SELECT 1 FROM EventLeadInterest i"
+ " WHERE i.id.eventLeadId = e.id AND i.id.interestId = :interestId))";
@@ -38,7 +40,7 @@ public interface EventLeadRepository extends JpaRepository<EventLead, Long> {
Page<Object[]> search(@Param("companyId") Long companyId, @Param("eventUuid") long eventUuid,
@Param("salespersonUserId") Long salespersonUserId, @Param("temperature") String temperature,
@Param("status") String status, @Param("interestId") Long interestId,
@Param("leadType") String leadType, Pageable pageable);
@Param("leadType") String leadType, @Param("attended") Boolean attended, Pageable pageable);
long countByEventUuidAndAttendedAtIsNotNull(long eventUuid);
@@ -163,7 +163,7 @@ public class EventLeadService {
Pageable pageable = PageRequest.of(Math.max(req.page(), 0), Math.min(Math.max(req.size(), 1), MAX_PAGE_SIZE),
Sort.by(Sort.Order.desc("capturedAt"), Sort.Order.desc("id")));
Page<Object[]> rows = eventLeadRepository.search(req.companyId(), req.eventUuid(), req.salespersonUserId(),
blankToNull(req.temperature()), blankToNull(req.status()), req.interestId(), blankToNull(req.leadType()), pageable);
blankToNull(req.temperature()), blankToNull(req.status()), req.interestId(), blankToNull(req.leadType()), req.attended(), pageable);
if (rows.isEmpty()) return rows.map(r -> null);
Map<Long, List<Long>> interests = eventLeadInterestRepository
.findByIdEventLeadIdIn(rows.map(r -> ((EventLead) r[0]).getId()).getContent()).stream()
@@ -235,7 +235,8 @@ public class EventLeadService {
private static EventLeadDetail detail(EventLead e, Lead l, List<Long> interestIds) {
return new EventLeadDetail(e.getUuid(), e.getEventUuid(), l.getUuid(), l.getName(), l.getMobileE164(),
l.getEmailNormalised(), l.getCompanyName(), l.getJobTitle(), e.getLeadType(), e.getSalespersonUserId(),
e.getTemperature(), e.getStatus(), e.getNextFollowUpDate(), e.getNotes(), e.getCapturedAt(), interestIds, e.getCompanyId());
e.getTemperature(), e.getStatus(), e.getNextFollowUpDate(), e.getNotes(), e.getCapturedAt(), interestIds, e.getCompanyId(),
e.getAttendedAt(), e.getSource());
}
private static void fillBlank(String current, String offered, Consumer<String> setter) {