data import

API list:

InterfaceDescription
/api/xiang/import/<table_name>/settingGet the Setting of the table
/api/xiang/import/<table_name>/mappingGet the mapping field of the table
/api/xiang/import/<table_name>/mapping/settingGet the mapping field setting of the table
/api/xiang/import/<table_name>/dataGet data
/api/xiang/import/<table_name>/data/settingsetting 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"
}

Code example:

Add the models directory file /models/ticket.mod.json:

View source code

Add the table directory file /tables/ticket.tab.json:

View source code

Import the Excel file and add the directory file /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:

View source code

Write the code /scripts/imports/ticket.js:

function Import(columns, data) {
// todo handles import logic
// print the implicit relation
console.log(columns);
// print the obtained data
console.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;
}

The import method is divided into three steps:

  • Step 1: Get the file url
Request URL, request method: POST
  • /api/xiang/storage/upload
Parameters
Parameter NameRequiredTypeDescription
fileyesfilefile name
Return to example
"20220411/0C3A5E7FCA0FE897710DE2CA00240FFE.xlsx"
  • Step 2: Get the mapping relationship
Request URL, request method GET
  • /api/xiang/import/ticket/mapping
Parameters
Parameter NameRequiredTypeDescription
fileyesstringfile name url
  • Step 3: Pass all the data
Request URL, request method POST
  • /api/xiang/import/ticket
Parameters
Parameter NameRequiredTypeDescription
fileyesstringfile name
mappingyesstringmapping relation returns all data

Request parameter example

View source code

data import

API list:

InterfaceDescription
/api/xiang/import/<table_name>/settingGet the Setting of the table
/api/xiang/import/<table_name>/mappingGet the mapping field of the table
/api/xiang/import/<table_name>/mapping/settingGet the mapping field setting of the table
/api/xiang/import/<table_name>/dataGet data
/api/xiang/import/<table_name>/data/settingsetting 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"
}

Code example:

Add the models directory file /models/ticket.mod.json:

View source code

Add the table directory file /tables/ticket.tab.json:

View source code

Import the Excel file and add the directory file /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:

View source code

Write the code /scripts/imports/ticket.js:

function Import(columns, data) {
// todo handles import logic
// print the implicit relation
console.log(columns);
// print the obtained data
console.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;
}

The import method is divided into three steps:

  • Step 1: Get the file url
Request URL, request method: POST
  • /api/xiang/storage/upload
Parameters
Parameter NameRequiredTypeDescription
fileyesfilefile name
Return to example
"20220411/0C3A5E7FCA0FE897710DE2CA00240FFE.xlsx"
  • Step 2: Get the mapping relationship
Request URL, request method GET
  • /api/xiang/import/ticket/mapping
Parameters
Parameter NameRequiredTypeDescription
fileyesstringfile name url
  • Step 3: Pass all the data
Request URL, request method POST
  • /api/xiang/import/ticket
Parameters
Parameter NameRequiredTypeDescription
fileyesstringfile name
mappingyesstringmapping relation returns all data

Request parameter example

View source code