Same columns and filters as the screen, all pages, refused above 20,000 rows. Mobiles are text and dates are dates. Each export is logged with user, listing and row count only. Adds poi-ooxml 4.1.0, as in services-system. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
5.9 KiB
Tasks
Design: design.md (decision numbers below refer to it). All tasks run serially. Each task touches a hotspot (SQL or pom.xml) or files the next task builds on. Every task is TDD: tests first, run red, then implement.
1. Database
-
1.1 Write the SQL files (design decision 1):
sql/01-lead-index.sql:ALTER TABLE event_lead ADD KEY idx_event_lead_company_lead (company_id, lead_uuid).sql/02-lead-modules.sql: the three module rows.sql/99-rollback.sql.
Mirror them into
local/seed/03-colite.sql. Then apply the index and the module rows to the running local database, because a reset would wipe its test data.- Scope:
openspec/changes/add-lead-listing-export/sql/**,local/seed/** - Verify: a read-only
SHOW INDEX FROM event_leadandSELECTonmoduleshow the new index and the three rows.
2. services-counter
-
2.1 Add lead search, detail and update (design decisions 2 and 3):
POST /counter/lead/search: the native query withcnt,lastandsp.GET /counter/lead/detail/{companyId}/{leadUuid}: the lead with its history and shared contacts.POST /counter/lead/update:@Transactional.
Tests first. The unit tests cover:
- the page size cap;
- blank
q; - escaping of
%and_; - passing the digits key;
- 404 for another company's lead;
- update sets the six fields plus
updatedByandupdatedAt, and is transactional; - shared contacts exclude the lead itself and ignore nulls.
Prove the native query live against local MySQL through the gateway:
- counts, last event and latest non-null salesperson;
- a lead with no capture;
- order;
- each search form (name, email,
012-345 6701). - Scope:
solvway-services-counter/src/**(lead files anddto/) - Verify:
mvn -T 1C -B -q -pl solvway-services-counter -am verify.
3. mobile-api
-
3.1 Add the leads admin API (design decision 4): list, detail and update under
/api/admin/leads, with the module rules and the second check in code.Tests first:
- each validation code, with update normalisation the same as capture;
- the digits key built from
012-345 6701and from+60 12-345 6701; @AdminModule(also=…)inAppAccessAspect: missing analsomodule gives 403, super admin passes, injectedROLE_ADMINgrants nothing; the update is refused 403 withoutBO_LEADS, even withBO_LEADS_EDIT;- uuids are strings;
- the latest salesperson and history names are resolved once per request.
Live check through the gateway.
- Scope:
solvway-mobile-api/src/**(lead files) - Verify:
mvn -T 1C -B -q -pl solvway-mobile-api -am verify.
-
3.2 Add both xlsx exports (design decision 5):
- Add
poi-ooxml4.1.0 tosolvway-mobile-api/pom.xmland record thedependency:treeresult. - Add the
exportendpoints for leads and event leads.
Tests first:
- the header row and column order of each export;
- the mobile cell is a string;
- follow-up and capture cells are dates;
- all pages are collected;
- more than 20,000 rows gives 422
EXPORT_TOO_LARGEbefore any write; - 403 without the listing module;
- the audit log line has no lead data.
Tests read the workbook back with POI. Live check: download both files through the gateway and open them with POI.
- Scope:
solvway-mobile-api/pom.xml,solvway-mobile-api/src/** - Verify:
mvn -T 1C -B -q -pl solvway-mobile-api -am verify.
- Add
4. Portal
-
4.1 Add the Lead Listing and lead detail (design decision 6):
- the leads data layer: route
app/api/leads/[...path], service, types, and/leadsmapped toBO_LEADS; - the
/leadslisting with search; - the
/leads/[leadUuid]detail page, with an edit form when the user hasBO_LEADS_EDIT, the shared-contact warning, the event history and not-found; - a "View lead" link on the event lead edit page when the user has
BO_LEADS.
Leads*i18n keys. Tests first, one per portal-visiblelead-recordsscenario.- Scope:
solvway-admin-portal/app/leads/**,solvway-admin-portal/app/api/leads/**,solvway-admin-portal/app/lib/**,solvway-admin-portal/app/event-leads/[eventUuid]/[eventLeadUuid]/** - Verify:
cd solvway-admin-portal && npx vitest run && npx tsc --noEmit && npm run lint && npm run build.
- the leads data layer: route
-
4.2 Add the Export buttons (design decision 6):
- a binary variant of
callMobileApiwith the same error shape; - the
app/api/leads/exportandapp/api/event-leads/[eventUuid]/exportroutes, which pass throughContent-TypeandContent-Disposition; - an Export button on both listings when the user has
BO_LEADS_EXPORT. It sends the current search or filters, downloads via Blob under the server's filename, showsEXPORT_TOO_LARGEand other errors on the page, and is disabled while running.
Tests first.
- Scope:
solvway-admin-portal/app/api/**/export/**,solvway-admin-portal/app/lib/**,solvway-admin-portal/app/leads/page*,solvway-admin-portal/app/event-leads/[eventUuid]/page* - Verify: as 4.1.
- a binary variant of
5. Browser check
- 5.1 Rebuild the changed services and drive the portal with Playwright, using only local dev data and made-up test leads.
- Desktop:
- Grant the three modules to a role.
- On Leads, check the counts, last event and latest salesperson of a lead captured at two events.
- Search by name, by email and by
012-345 6701. - Open a lead and check the history and the shared-mobile warning.
- Edit the email and company.
- Try an invalid mobile.
- Export Leads with a search, and export an event's leads with a filter. Open both files and check the columns, the rows and that the mobile is text.
- 360×780: the lead detail page and its edit form.
- Restricted users:
- A user without
BO_LEADS_EDITsees the lead read-only. - A user without
BO_LEADS_EXPORTsees no Export button, and the export API returns 403. - A user without
BO_LEADSgets not-authorised on/leads.
- A user without
- Desktop: