Lists, adds, renames, orders and activates/deactivates interests, gated by BO_INTERESTS. API errors map to field messages under Name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
8.8 KiB
Tasks
Design: design.md (decision numbers below refer to it). Every task runs serially, and each task touches either a hotspot (SQL, 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:
sql/01-lead-tables.sql: the four tables exactly as in design decision 1, with engine InnoDB and charset utf8mb4.sql/02-lead-modules.sql: two module rows,40200000 BO_EVENT_LEADS'Event leads'/event-leadsClipboardListand40300000 BO_INTERESTS'Interests'/interestsTags. Both are area BO, type M, parent 40000000.sql/99-rollback.sql.
Mirror the tables and module rows into
local/seed/03-colite.sql. Seed no lead data.- Scope:
openspec/changes/add-event-lead-capture/sql/**,local/seed/** - Verify:
docker compose -f local/docker-compose.yml down -v && local/up.shexits 0, then a read-only SELECT shows the four tables and both module rows.
2. services-counter
-
2.1 Add the interests backend (design decision 8):
Interestentity and repository.GET /counter/interest/findByCompany/{companyId}, ordered by sort order then name.POST /counter/interest/save, which creates or updates by id within the company.POST /counter/interest/findByIdswith{companyId, ids}.
Tests first:
- ordering;
- save then find;
- a duplicate name in the same company (case-insensitive) is refused;
- the same name in another company is allowed;
findByIdsignores other companies' ids.- Scope:
solvway-services-counter/src/**/*Interest*, plus adto/record if needed. - Verify:
mvn -T 1C -B -q -pl solvway-services-counter -am verify.
-
2.2 Add the lead backend (design decisions 3, 6, 7):
Lead,EventLeadandEventLeadInterestentities and repositories. Uuids come fromSnowflakeIdWorker.getUUID().EventLeadControllerand service:POST /counter/lead/findMatcheswith{companyId, mobileE164, email}: leads matching either value in the company, at most 20, newest first. Each match carries theeventLeadUuidwhen the lead is already captured at the giveneventUuid.POST /counter/eventLead/capture: one@Transactionalmethod.- With
leadUuidnull, insert a new lead and mark the event lead NEW. - With
leadUuidset, load the lead in the company and fill only its blank fields; mark the event lead EXISTING. - Already at the event: 409
ALREADY_CAPTUREDwith theeventLeadUuid. A lead from another company: 404.
- With
GET /counter/eventLead/findByUuid/{companyId}/{eventLeadUuid}.POST /counter/eventLead/update: replaces salesperson, temperature, status, follow-up, notes and the interest set in one transaction.POST /counter/eventLead/findByEvent: paged, with optional filters on salesperson, temperature, status, interest (anexistssubquery) and lead type. Sorted bycaptured_atdesc, theniddesc. Interest ids for the page come from oneinquery.
Tests first, for each of these:
- New capture.
- Existing capture fills only blanks, never overwriting stored values.
- A duplicate capture at the same event is refused and nothing is written.
- A failure inserting interests rolls back the lead and the event lead.
- Matching by mobile only, by email only, and both values matching different leads.
- Company isolation in match, capture, find and listing.
- Each listing filter.
- Paging order with equal
captured_at. - Update replaces the interest set.
- Scope:
solvway-services-counter/src/**/*Lead*, plusdto/records if needed. - Verify:
mvn -T 1C -B -q -pl solvway-services-counter -am verify.
3. mobile-api
-
3.1 Add the interests admin API (design decision 8).
AdminInterestControllerwithGET,POSTandPUT /api/admin/interests, all@AppAuth @AdminModule("BO_INTERESTS"). The company id comes from the caller.Validation:
- Name is required, else
REQUIRED_FIELD. - At most 100 characters, else
TOO_LONG. - A duplicate answers 409
DUPLICATE_NAME. - Errors use the
detailsanderrorscontract from change 3.
Tests first, for each
lead-interestsscenario the API decides.- Scope:
solvway-mobile-api/src/**/*Interest*,solvway-mobile-api/src/main/java/**/constants/** - Verify:
mvn -T 1C -B -q -pl solvway-mobile-api -am verify.
- Name is required, else
-
3.2 Add the event-leads admin API (design decisions 2–7).
- Add
com.googlecode.libphonenumber:libphonenumber(latest 8.x, exact version) tosolvway-mobile-api/pom.xml. AdminEventLeadControllerandAdminEventLeadServiceunder/api/admin/event-leads, all@AppAuth @AdminModule("BO_EVENT_LEADS"):GET /eventsGET /interest-optionsGET /{eventUuid}/salesperson-optionsPOST /{eventUuid}/matchPOST /{eventUuid}(capture)GET /{eventUuid}/leadsGET /{eventUuid}/leads/{eventLeadUuid}PUT /{eventUuid}/leads/{eventLeadUuid}
- Uuids are JSON strings. Dates are
YYYY-MM-DD. - Codes:
REQUIRED_FIELD,TOO_LONG,INVALID_MOBILE,INVALID_EMAIL,INVALID_VALUE;NOT_ON_TEAM(salesperson rule, decision 4);INACTIVE_INTEREST;EVENT_DISABLED(409);ALREADY_CAPTURED(409,details.eventLeadUuid);- 404 for an unknown event or event lead.
- Never log a lead's name, mobile or email.
Tests first:
- A table test of the Malaysian mobile formats in the spec, plus invalid input.
- Email normalisation.
- Each
event-lead-capturescenario the API decides. - The salesperson keep-existing rule.
- The inactive-interest keep rule.
- An exact-JSON test that uuids are strings.
- Scope:
solvway-mobile-api/pom.xml,solvway-mobile-api/src/**/*EventLead*,solvway-mobile-api/src/main/java/**/constants/**,solvway-mobile-api/src/main/java/**/dto/admin/** - Verify:
mvn -T 1C -B -q -pl solvway-mobile-api -am verify.
- Add
4. Admin portal
-
4.1 Add the Interests screen (
app/interests/page.tsx, desktop-first, following the Roles page pattern). It provides a table with add, rename, active toggle and sort order. It needs route handlersapp/api/interests/**, a service, types,Int*i18n keys and/interestsmapped toBO_INTERESTSinrouteModules.Tests first (vitest), for each portal-visible
lead-interestsscenario.- Scope:
solvway-admin-portal/app/interests/**,solvway-admin-portal/app/api/interests/**,solvway-admin-portal/app/lib/** - Verify:
cd solvway-admin-portal && npx vitest run && npx tsc --noEmit && npm run lint && npm run build.
- Scope:
-
4.2 Add the event-floor screens (design decision 10):
- Pages:
app/event-leads/page.tsx: event picker.app/event-leads/[eventUuid]/page.tsx: listing.DataTableatmdand up; a card list belowmd, with filters.app/event-leads/[eventUuid]/new/page.tsx: two-step key-in form. Step 1 is match, with candidate cards and "This person", "Open" and "Different person". Step 2 is the details.app/event-leads/[eventUuid]/[eventLeadUuid]/page.tsx: edit.
ALREADY_CAPTUREDopens the existing event lead.- Supporting code:
- route handlers
app/api/event-leads/**; - service, types,
Lead*i18n keys; /event-leadsmapped toBO_EVENT_LEADS.
- route handlers
- Mobile input attributes:
type="tel",inputMode="tel"andautoComplete="tel". - Touch targets of at least 44 px.
- Reuse the change-3
DatePickerfor the follow-up date.
Tests first (vitest), for each portal-visible
event-lead-capturescenario. They include the match step's three outcomes, and the card list rendering belowmd(assert the card markup is present, not the layout).- Scope:
solvway-admin-portal/app/event-leads/**,solvway-admin-portal/app/api/event-leads/**,solvway-admin-portal/app/components/event-leads/**,solvway-admin-portal/app/lib/** - Verify:
cd solvway-admin-portal && npx vitest run && npx tsc --noEmit && npm run lint && npm run build.
- Pages:
5. Verification
-
5.1 Rebuild the stack and drive the portal with Playwright, using only local dev data and test leads made up for this check.
- At desktop width:
- Grant
BO_EVENT_LEADSandBO_INTERESTSto a role. - Add interests, try a duplicate, and deactivate one.
- Capture a NEW lead.
- Capture the same mobile in another format at another event. It shows as a match; pick it, and it is EXISTING with its blanks filled.
- Capture a different person with the same mobile.
- Show the already-captured block.
- Show that an outsider salesperson is refused.
- Show the invalid mobile and missing contact errors.
- Filter the listing, and edit status, temperature and follow-up.
- Grant
- At 360×780: the event picker, listing cards, key-in form and edit page.
- A user without the modules gets not-authorised.
Screenshots go in
verification/.- Verify: each scenario observed as specified, and
local/smoke.shprintssmoke: OK.
- At desktop width: