Column-mapped Data Import (Import Mapping)
Overview
Import Mapping imports CSV data in order to update line_user records that already exist
in the system. This distinguishes it from Customer Database, which stores data in a separate
table, and from the import-all-friends flow, which creates new friend records.
Customers upload a CSV in any layout and decide for themselves:
- Which column acts as the unique key for matching against a LINE user — a phone number or membership ID, for example
- Which columns map onto which standard fields or custom attributes
A validation step reports how many rows will match and how many will not before the user commits. The actual updates are handed off to worker-go and processed asynchronously through RabbitMQ.
Business Flow
- Upload —
POST /api/import-mapping/uploadaccepts a multipart file, stores it in object storage, and returns the column headers it was able to read. - Fetch mappable targets —
GET /api/import-mapping/fieldsreturns the fields and attributes data can be mapped onto: custom attributes fromattribute_mastercombined with the standardline_userfields. - Validate — after mapping the columns, the user calls
POST /api/import-mapping/validate. The system checks each row against the current OA'sline_userrecords and reports which rows matched a LINE user, which did not, and which contain values of the wrong type. - Confirm —
POST /api/import-mappingcreates a row inimport_mapping_jobwith statuspendingand publishes the job id to the RabbitMQ queueimport_mapping_job. - Worker processing — worker-go picks up the job, applies the updates to
line_user, and writes the job status back. - Track progress —
GET /api/import-mappingreturns a paginated list of all jobs with their current status, used to follow each import through to completion.
Every query is scoped by the CLS values lineOaId and organizationId, consistent with the
rest of the system.
Key Files & Functions
The code lives in internal/modules/importmapping/, split across controller.go,
service.go and dto.go.
| Method | Route | Handler | Policy |
|---|---|---|---|
| POST | /api/import-mapping/upload | ct.upload | create import-mapping |
| GET | /api/import-mapping/fields | ct.fields | read import-mapping |
| POST | /api/import-mapping/validate | ct.validate | create import-mapping |
| POST | /api/import-mapping | ct.createJob | create import-mapping |
| GET | /api/import-mapping | ct.list | readAll import-mapping |
Every route is wrapped in modulegate.ModuleGate(d, "import-mapping").
Connections to Other Services
- Permissions — requires
ModuleGate("import-mapping")and carriesPolicyModuleImportMappingas metadata. - Tables —
import_mapping_job,line_user,attribute_masterandline_oa. - RabbitMQ — jobs are dispatched on the
import_mapping_jobqueue, configured through theRABBITMQ_QUEUE_IMPORT_MAPPING_JOBenvironment variable, with the consumer living in line-management-worker-go. - Storage — the original CSV files are kept in object storage.
- Related modules — LINE User Management as the destination for the data, Attribute Master which defines the target fields, Customer Database, and All Friend Listing where import history is reviewed.