File import function, usually used for Excel table import.
Use the data import component in Tables as a process.
This chapter introduces the Excel import function.
process | Description |
---|---|
xiang.import.Run | Start running the import function |
xiang.import.Data | Get table data |
xiang.import.Setting | Get the mapping field setting of the table |
xiang.import.DataSetting | Get mapping data |
xiang.import.Mapping | Get Mapping |
xiang.import.MappingSetting | Get mapping data |
Interface | Description |
---|---|
/api/xiang/import/<table_name>/setting | Get the Setting of the table |
/api/xiang/import/<table_name>/mapping | Get the mapping field of the table |
/api/xiang/import/<table_name>/mapping/setting | Get the mapping field setting of the table |
/api/xiang/import/<table_name>/data | Get data |
/api/xiang/import/<table_name>/data/setting | setting to get data |
/api/xiang/import/<table_name> | Import data interface |
{"setting": "/api/xiang/import/ticket/setting","mapping": "/api/xiang/import/ticket/mapping","mapping_setting": "/api/xiang/import/ticket/mapping/setting","preview": "/api/xiang/import/ticket/data","preview_setting": "/api/xiang/import/ticket/data/setting","import": "/api/xiang/import/ticket"}
/models/ticket.mod.json
Add the table directory file /tables/ticket.tab.json
:
/imports/ticket.imp.json
Application directory structure:
├── apis # Used to store interface description files│├──tables| └──ticket.tab.json #import excel table|├── models # Used to store data model description files│├── db└── imports #map file for importing data| └── ticket.imp.json||──scripts| └──imports| └──ticket.js||└── app.json
Write the code ticket.imp.json
:
Write the code /scripts/imports/ticket.js
:
function Import(columns, data) {// todo handles import logic// print the implicit relationconsole.log(columns);// print the obtained dataconsole.log(data);var success = 0;var fail = 0;return [success, fail];}function Output(data) {// todo handles the logic after import, this function will be called automatically after import: "output": "scripts.imports.ticket.Output",return data;}
/api/xiang/storage/upload
Parameter Name | Required | Type | Description |
---|---|---|---|
file | yes | file | file name |
"20220411/0C3A5E7FCA0FE897710DE2CA00240FFE.xlsx"
/api/xiang/import/ticket/mapping
Parameter Name | Required | Type | Description |
---|---|---|---|
file | yes | string | file name url |
/api/xiang/import/ticket
Parameter Name | Required | Type | Description |
---|---|---|---|
file | yes | string | file name |
mapping | yes | string | mapping relation returns all data |
File import function, usually used for Excel table import.
Use the data import component in Tables as a process.
This chapter introduces the Excel import function.
process | Description |
---|---|
xiang.import.Run | Start running the import function |
xiang.import.Data | Get table data |
xiang.import.Setting | Get the mapping field setting of the table |
xiang.import.DataSetting | Get mapping data |
xiang.import.Mapping | Get Mapping |
xiang.import.MappingSetting | Get mapping data |
Interface | Description |
---|---|
/api/xiang/import/<table_name>/setting | Get the Setting of the table |
/api/xiang/import/<table_name>/mapping | Get the mapping field of the table |
/api/xiang/import/<table_name>/mapping/setting | Get the mapping field setting of the table |
/api/xiang/import/<table_name>/data | Get data |
/api/xiang/import/<table_name>/data/setting | setting to get data |
/api/xiang/import/<table_name> | Import data interface |
{"setting": "/api/xiang/import/ticket/setting","mapping": "/api/xiang/import/ticket/mapping","mapping_setting": "/api/xiang/import/ticket/mapping/setting","preview": "/api/xiang/import/ticket/data","preview_setting": "/api/xiang/import/ticket/data/setting","import": "/api/xiang/import/ticket"}
/models/ticket.mod.json
Add the table directory file /tables/ticket.tab.json
:
/imports/ticket.imp.json
Application directory structure:
├── apis # Used to store interface description files│├──tables| └──ticket.tab.json #import excel table|├── models # Used to store data model description files│├── db└── imports #map file for importing data| └── ticket.imp.json||──scripts| └──imports| └──ticket.js||└── app.json
Write the code ticket.imp.json
:
Write the code /scripts/imports/ticket.js
:
function Import(columns, data) {// todo handles import logic// print the implicit relationconsole.log(columns);// print the obtained dataconsole.log(data);var success = 0;var fail = 0;return [success, fail];}function Output(data) {// todo handles the logic after import, this function will be called automatically after import: "output": "scripts.imports.ticket.Output",return data;}
/api/xiang/storage/upload
Parameter Name | Required | Type | Description |
---|---|---|---|
file | yes | file | file name |
"20220411/0C3A5E7FCA0FE897710DE2CA00240FFE.xlsx"
/api/xiang/import/ticket/mapping
Parameter Name | Required | Type | Description |
---|---|---|---|
file | yes | string | file name url |
/api/xiang/import/ticket
Parameter Name | Required | Type | Description |
---|---|---|---|
file | yes | string | file name |
mapping | yes | string | mapping relation returns all data |