feat: company-scoped events, leads, event leads and exports

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-11-30 20:30:46 +08:00
1 parent de2ae63cea
commit ec504fd529
31 files changed
+1096 -190

No files matched your search

@@ -0,0 +1,33 @@
package com.solvway.services.counter.service;
import com.solvway.services.counter.dto.LeadSearchRequest;
import com.solvway.services.counter.repo.EventLeadRepository;
import com.solvway.services.counter.repo.LeadRepository;
import org.junit.jupiter.api.Test;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/** An all-companies lead search must tell each row's company. */
class LeadServiceCompanyIdTest {
@Test
void searchMapsTheRowsCompanyId() {
LeadRepository repo = mock(LeadRepository.class);
LeadRepository.SummaryRow row = mock(LeadRepository.SummaryRow.class);
when(row.getLeadUuid()).thenReturn(7L);
when(row.getCompanyId()).thenReturn(9L);
when(repo.search(any(), any(), any(), any(Pageable.class))).thenReturn(new PageImpl<>(List.of(row)));
var s = new LeadService(repo, mock(EventLeadRepository.class))
.search(new LeadSearchRequest(null, null, null, 0, 20)).getContent().get(0);
assertThat(s.companyId()).isEqualTo(9L);
}
}
@@ -110,6 +110,7 @@ class LeadServiceTest {
when(row.getLastEventName()).thenReturn("Expo");
when(row.getLastCapturedAt()).thenReturn(at);
when(row.getLatestSalespersonUserId()).thenReturn(11L);
when(row.getCompanyId()).thenReturn(null); // Mockito would otherwise answer 0 for a Long
when(leadRepository.search(eq(COMPANY), any(), any(), any(Pageable.class))).thenReturn(new PageImpl<>(List.of(row)));
LeadSummary s = service.search(new LeadSearchRequest(COMPANY, null, null, 0, 20)).getContent().get(0);