Information sharing method, apparatus and electronic device
By receiving and converting API interface messages to generate executable scripts, the problem of low efficiency in sharing data from information platforms to databases is solved, and automated, efficient data sharing is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MOBILE SHANGHAI ICT CO LTD
- Filing Date
- 2021-11-03
- Publication Date
- 2026-06-19
AI Technical Summary
In existing technologies, data sharing from information platforms to databases requires manual addition of data one by one, resulting in low efficiency.
By receiving API interface messages from the data source, parsing the index information and converting it into a database programming language, an executable script is generated to automate data sharing.
It enables the rapid sharing of data from data sources to the database without manual intervention, thus improving the efficiency of information sharing.
Smart Images

Figure CN116069977B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to an information sharing method, apparatus, and electronic device. Background Technology
[0002] To fully utilize data from various information platforms, the data can be shared with a database. However, in existing technologies, because the programming languages of the information platforms and the databases may differ, sharing data from the information platforms to the database requires manual addition of each piece of data, resulting in low efficiency. Summary of the Invention
[0003] This invention provides an information sharing method, apparatus, and electronic device to solve the problem that existing methods for sharing data from an information platform to a database require manual addition of data from the information platform to the database one by one, resulting in low efficiency.
[0004] To solve the above-mentioned technical problems, the present invention is implemented as follows:
[0005] In a first aspect, embodiments of the present invention provide an information sharing method, the method comprising:
[0006] Receive a first application programming interface (API) message sent by a data source. The first API message includes information to be shared described in a first programming language. The information to be shared includes index information and data to be shared corresponding to the index information.
[0007] Parse the index information and convert the language type of the data to be shared corresponding to the index information from the first programming language to the second programming language;
[0008] An executable script is generated based on the data to be shared as described in the second programming language.
[0009] Optionally, generating an executable script based on the data to be shared described in the second programming language includes:
[0010] Create a Map object;
[0011] The Map object is populated based on the index information and the data to be shared described in the second programming language;
[0012] An executable script is generated based on the populated Map object.
[0013] Optionally, if the first API interface message is a message in Extensible Markup Language (XML) format, the index information is a tag name, and the data to be shared corresponding to the index information is a tag value;
[0014] The step of populating the Map object based on the index information and the data to be shared described in the second programming language includes:
[0015] Format the tag name;
[0016] The formatted tag name and the data to be shared described in the second programming language are populated into the Map object as key-value pairs.
[0017] Optionally, generating an executable script based on the populated Map object includes:
[0018] Constructing a string involves creating a StringBuilder object;
[0019] Obtain the key and value information from the populated Map object;
[0020] Concatenate the key information and the value information into a target string according to a preset format;
[0021] Append the target string to the end of the StringBuilder object;
[0022] An executable script is generated based on the concatenated StringBuilder object.
[0023] Optionally, before receiving the first application programming interface (API) message sent by the data source, the method further includes:
[0024] Display the first interactive interface;
[0025] Receive a second API interface message input by the user in the first interactive interface, the second API interface message being used to request the data source to send the information to be shared;
[0026] Send the second API interface message to the data source;
[0027] The first API interface message is a response message to the second API interface message.
[0028] Optionally, before generating the executable script based on the data to be shared described in the second programming language, the method further includes:
[0029] Display the second interactive interface;
[0030] The system receives the script directory address input by the user in the second interactive interface, and the script directory address is used to store the executable script.
[0031] Verify that the script directory address is a valid address;
[0032] If the script directory address is a valid address, store the script directory address.
[0033] Optionally, after generating the executable script based on the data to be shared described in the second programming language, the method further includes:
[0034] Receive database connection information input by the user;
[0035] A connection is established with the database based on the aforementioned database connection information;
[0036] The executable script is executed on the database to generate a data table in the database for storing the data to be shared.
[0037] Secondly, embodiments of the present invention provide an information sharing device, the device comprising:
[0038] The first receiving module is used to receive a first application programming interface (API) message sent by a data source. The first API message includes information to be shared described in a first programming language. The information to be shared includes index information and data to be shared corresponding to the index information.
[0039] A conversion module is used to parse the index information and convert the language type of the data to be shared corresponding to the index information from the first programming language to the second programming language.
[0040] The generation module is used to generate an executable script based on the data to be shared described in the second programming language.
[0041] Optionally, the generation module includes:
[0042] Create a unit used to create a Map object;
[0043] A filling unit is used to fill the Map object based on the index information and the data to be shared described in the second programming language;
[0044] A generation unit is used to generate an executable script based on the populated Map object.
[0045] Optionally, if the first API interface message is a message in Extensible Markup Language (XML) format, the index information is a tag name, and the data to be shared corresponding to the index information is a tag value;
[0046] The filling unit is specifically used for:
[0047] Format the tag name;
[0048] The formatted tag name and the data to be shared described in the second programming language are populated into the Map object as key-value pairs.
[0049] Optionally, the generation unit is specifically used for:
[0050] Constructing a string involves creating a StringBuilder object;
[0051] Obtain the key and value information from the populated Map object;
[0052] Concatenate the key information and the value information into a target string according to a preset format;
[0053] Append the target string to the end of the StringBuilder object;
[0054] An executable script is generated based on the concatenated StringBuilder object.
[0055] Optionally, the first receiving module is further configured to:
[0056] Display the first interactive interface;
[0057] Receive a second API interface message input by the user in the first interactive interface, the second API interface message being used to request the data source to send the information to be shared;
[0058] Send the second API interface message to the data source;
[0059] The first API interface message is a response message to the second API interface message.
[0060] Optionally, the device further includes:
[0061] The display module is used to display the second interactive interface;
[0062] The second receiving module is used to receive the script directory address input by the user in the second interactive interface, and the script directory address is used to store the executable script;
[0063] The verification module is used to verify whether the script directory address is a valid address;
[0064] The storage module is used to store the script directory address if the script directory address is a valid address.
[0065] Optionally, the device further includes:
[0066] The third receiving module is used to receive database connection information input by the user;
[0067] The connection module is used to establish a connection with the database based on the database connection information;
[0068] An execution module is used to execute the executable script against the database to generate a data table in the database for storing the data to be shared.
[0069] Thirdly, embodiments of the present invention provide an electronic device, including: a processor, a memory, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, it implements the steps of the information sharing method described in the first aspect.
[0070] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the information sharing method described in the first aspect.
[0071] In this embodiment of the invention, a first application programming interface (API) message sent by a data source is received. The first API message includes information to be shared, described in a first programming language. This information includes index information and data to be shared corresponding to the index information. The index information is parsed, and the language type of the data to be shared corresponding to the index information is converted from the first programming language to a second programming language. An executable script is generated based on the data to be shared described in the second programming language. In this way, data from the data source can be quickly shared to the database using the executable script, eliminating the need for manual addition of data from the information platform to the database one by one, thereby improving the efficiency of information sharing. Attached Figure Description
[0072] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0073] Figure 1 This is a flowchart of an information sharing method provided in an embodiment of the present invention;
[0074] Figure 2 This is one of the structural schematic diagrams of an information sharing device provided in an embodiment of the present invention;
[0075] Figure 3 This is a second schematic diagram of the structure of an information sharing device provided in an embodiment of the present invention;
[0076] Figure 4This is the third structural schematic diagram of an information sharing device provided in an embodiment of the present invention;
[0077] Figure 5 This is the fourth structural schematic diagram of an information sharing device provided in an embodiment of the present invention;
[0078] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0079] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0080] In this embodiment of the invention, an information sharing method, apparatus, and electronic device are proposed to solve the problem that existing methods for sharing data from an information platform to a database require manual addition of data from the information platform to the database one by one, resulting in low efficiency in information sharing.
[0081] See Figure 1 , Figure 1 This is a flowchart of an information sharing method provided in an embodiment of the present invention, such as... Figure 1 As shown, the method includes the following steps:
[0082] Step 101: Receive a first application programming interface (API) message sent by the data source. The first API message includes information to be shared described in a first programming language. The information to be shared includes index information and data to be shared corresponding to the index information.
[0083] The data source can be an information platform created using the first programming language, or a database created using the first programming language, etc. The first programming language can be Java or other programming languages. The index information can be used to locate the data to be shared. When the first Application Programming Interface (API) message is in Extensible Markup Language (xml) format, the index information is a tag name, and the data to be shared corresponding to the index information is the tag value. When the first API message is in JavaScript Object Notation (JSON) format, the index information is the key of a Map object, and the data to be shared corresponding to the index information is the value of the Map object.
[0084] It should be noted that after receiving the first API interface message, its validity can be verified. If the first API interface message is in JSON format, it can be parsed string by string according to the JSON syntax standard for syntax validity verification. If the JSON message is valid, the index information is parsed; if the JSON message is invalid, a message indicating invalid JSON message is generated. If the first API interface message is in XML format, it can be parsed tag by tag using the stax API provided by the Java Development Kit (JDK), and its syntax validity verified according to the XML standard syntax. If the XML message is valid, the index information is parsed; if the XML message is invalid, a message indicating invalid XML message is generated.
[0085] Step 102: Parse the index information and convert the language type of the data to be shared corresponding to the index information from the first programming language to the second programming language.
[0086] The second programming language is different from the first programming language. The second programming language can be Structured Query Language (SQL) or another programming language. When the first API interface message is in Extensible Markup Language (XML) format, the index information is the tag name. This can be obtained by parsing each tag individually using the stax API, extracting the tag value, determining the corresponding Java language type, and converting the Java language type to an SQL language type. Here, stax, or Streaming API for XML, is the latest standard for processing XML. When the first API interface message is in JSON format, the index information is the key of a Map object. This can be obtained by using the Jackson JSON parsing library to parse the JSON message into a corresponding Map object, determining the corresponding Java language type of the value in the Map object, and converting the Java language type to an SQL language type.
[0087] Step 103: Generate an executable script based on the data to be shared described in the second programming language.
[0088] The executable script can be used to generate a data table in the database to store the data to be shared. A Map object can be created, populated with the index information and the data to be shared described in the second programming language, and the executable script can be generated based on the populated Map object.
[0089] It should be noted that the system can receive database connection information input by the user; a connection is established with the database based on this information, and after a successful connection, the successful connection information can be saved to the database connection pool. If the connection fails, the input database connection information is considered unusable, thus verifying the availability of the database. A list of successfully connected databases can be displayed on the third interactive interface. For connection objects saved in the database connection pool, taking an SQL script as an example, the SQL script can be used as a parameter to create a PreparedStatement object; depending on the PreparedStatement object, the executeUpdate() method of the object is executed to execute the SQL script in the database; if no exception is thrown, the database construction is successful, and the third interactive interface is refreshed, displaying metadata information of the successfully constructed database; otherwise, a message indicating database construction failure is generated.
[0090] In one implementation, the database can be a relational database. After executing an SQL script on the relational database, a new data table is added to the relational database. The refreshed third interactive interface can then display the metadata information of the newly added data table and the original data table.
[0091] Taking Java as the first programming language as an example, this embodiment of the invention can quickly share data from the data source to the database through an executable script, which can solve the problem in the Java technology field of automatically generating data tables of relational databases based on API interface messages during the API interface interface process.
[0092] In this embodiment of the invention, a first application programming interface (API) message sent by a data source is received. The first API message includes information to be shared, described in a first programming language. This information includes index information and data to be shared corresponding to the index information. The index information is parsed, and the language type of the data to be shared corresponding to the index information is converted from the first programming language to a second programming language. An executable script is generated based on the data to be shared described in the second programming language. In this way, data from the data source can be quickly shared to the database using the executable script, eliminating the need for manual addition of data from the information platform to the database one by one, thereby improving the efficiency of information sharing.
[0093] Optionally, generating an executable script based on the data to be shared described in the second programming language includes:
[0094] Create a Map object;
[0095] The Map object is populated based on the index information and the data to be shared described in the second programming language;
[0096] An executable script is generated based on the populated Map object.
[0097] In the case where the first API interface message is in XML format, the index information is the tag name, and the data to be shared corresponding to the index information is the tag value. The tag name can be formatted, and the formatted tag name and the data to be shared described in the second programming language are used as key-value pairs to populate the Map object. An executable script is generated based on the populated Map object. In the case where the first API interface message is in JSON format, the index information is the key in the Map object, and the data to be shared corresponding to the index information is the value in the Map object. The Java language type corresponding to the value can be converted to an SQL language type, and the key and the corresponding SQL language type value are used as new key-value pairs to populate a new Map object. An executable script is generated based on the populated Map object.
[0098] In one implementation, the first API interface message is a JSON format message. A new Map object can be created, and the Map objects in the first API interface message can be traversed. The keys and values of each Map object in the first API interface message are extracted one by one. The Java language type corresponding to the value is determined, and the Java language type corresponding to the value is converted to an SQL language type. The key and the corresponding SQL language type value are then used as new key-value pairs to populate the created Map object. Using a Map collection masks the differences between JSON and XML messages, and using key-value pairs to store the field names and field types of the SQL statement to be generated avoids the bloated and inefficient process of converting messages into JavaBean methods.
[0099] In this embodiment, a Map object is created, and the Map object is populated with the index information and the data to be shared described by the second programming language. An executable script is generated based on the populated Map object. In this way, by populating the data to be shared with the Map object, the efficiency of information sharing can be further improved.
[0100] Optionally, if the first API interface message is a message in Extensible Markup Language (XML) format, the index information is a tag name, and the data to be shared corresponding to the index information is a tag value;
[0101] The step of populating the Map object based on the index information and the data to be shared described in the second programming language includes:
[0102] Format the tag name;
[0103] The formatted tag name and the data to be shared described in the second programming language are populated into the Map object as key-value pairs.
[0104] In one implementation, the first API interface message is an XML format message. A new Map object can be created. The stax API can be used to parse each tag of the first API interface message, extract the tag name, format the tag name, extract the tag value, determine the Java language type corresponding to the tag value, convert the Java language type to an SQL language type, and then populate the created Map object with the formatted tag name and its corresponding SQL language type value as new key-value pairs. Using stax technology to parse the XML message, based on event-driven parsing, improves the performance of XML message parsing.
[0105] In this embodiment, the tag name is formatted, and the formatted tag name and the data to be shared described in the second programming language are used as key-value pairs to populate the Map object, thereby enabling the data to be shared in the XML format message to be quickly populated into the Map object.
[0106] Optionally, generating an executable script based on the populated Map object includes:
[0107] Constructing a string involves creating a StringBuilder object;
[0108] Obtain the key and value information from the populated Map object;
[0109] Concatenate the key information and the value information into a target string according to a preset format;
[0110] Append the target string to the end of the StringBuilder object;
[0111] An executable script is generated based on the concatenated StringBuilder object.
[0112] The generated executable script can be displayed on the fourth interactive interface. After concatenating the target strings corresponding to the key and value information of the first API interface message to the end of the StringBuilder object, the comma at the end of the concatenated StringBuilder object can be replaced with backticks. The executable script includes the replaced StringBuilder object.
[0113] In addition, after the generated executable script is displayed on the fourth interactive interface, the user can make fine-tuning adjustments to the displayed executable script to optimize it.
[0114] It should be noted that the preset format can be set in advance. For example, the preset format can be to concatenate the target string according to the order of key information + whitespace + value information + comma. The key information can be the key of the Map object, and the value information can be the value of the Map object.
[0115] In one implementation, a StringBuilder object can be constructed using the string "CREATE TABLE TBL_TEMP(id int(11)PRIMARY KEY)" as a parameter; the key list of the collection of filled Map objects is traversed; if the Map object collection is not empty, key-value pairs in the Map object collection are retrieved one by one until the Map object collection is empty; the target string is concatenated according to the order of key + whitespace + value + comma, and the target string is appended to the end of the StringBuilder object; after the Map object collection is empty, the comma at the end of the StringBuilder object is replaced with backticks, and the executable script includes the replaced StringBuilder object.
[0116] In this implementation, a StringBuilder object is constructed; the key and value information in the populated Map object are obtained; the key and value information are concatenated into a target string according to a preset format; the target string is appended to the end of the StringBuilder object; and an executable script is generated based on the concatenated StringBuilder object. This allows for the rapid generation of an executable script that can share data from a data source to a database, based on the populated Map object.
[0117] Optionally, before receiving the first application programming interface (API) message sent by the data source, the method further includes:
[0118] Display the first interactive interface;
[0119] Receive a second API interface message input by the user in the first interactive interface, the second API interface message being used to request the data source to send the information to be shared;
[0120] Send the second API interface message to the data source;
[0121] The first API interface message is a response message to the second API interface message.
[0122] The first interactive interface can be used to receive the second API interface message input by the user and verify its validity. After receiving the second API interface message input by the user on the first interactive interface, its validity can be verified. If the second API interface message is in JSON format, it can be parsed string by string according to the JSON syntax standard for syntax validity verification; if the JSON message is valid, a "JSON message valid" message is generated; if the JSON message is invalid, a "JSON message invalid" message is generated. If the second API interface message is in XML format, it can be parsed tag by tag according to the stax API provided by the JDK and its syntax validity verified according to the XML standard syntax; if the XML message is valid, an "XML message valid" message is generated; if the XML message is invalid, an "XML message invalid" message is generated.
[0123] In this embodiment, a first interactive interface is displayed; a second API interface message input by the user on the first interactive interface is received, the second API interface message being used to request the data source to send the information to be shared; the second API interface message is sent to the data source, thus enabling information sharing to be requested from the data source through the first interactive interface.
[0124] Optionally, before generating the executable script based on the data to be shared described in the second programming language, the method further includes:
[0125] Display the second interactive interface;
[0126] The system receives the script directory address input by the user in the second interactive interface, and the script directory address is used to store the executable script.
[0127] Verify that the script directory address is a valid address;
[0128] If the script directory address is a valid address, store the script directory address.
[0129] The script directory address can be the export directory address of the executable script. The second interactive interface can include a configuration verification button, which the user can click to verify whether the entered script directory address is valid. The JDK API can be used to verify the script directory address's validity. If the script directory address exists, it can be saved to local memory, and a message indicating that the script directory address is valid can be generated. If the script directory address does not exist, a message indicating that the script directory address is invalid can be generated. For example, the `exists` function of the Java `File` class can be used to check if a file or folder exists, thereby verifying the validity of the script directory address.
[0130] In this embodiment, a second interactive interface is displayed, and the script directory address input by the user on the second interactive interface is received. The script directory address is used to store the executable script. The system verifies whether the script directory address is a valid address. If the script directory address is a valid address, the script directory address is stored, thereby enabling quick determination of the storage address of the executable script.
[0131] Optionally, after generating the executable script based on the data to be shared described in the second programming language, the method further includes:
[0132] Receive database connection information input by the user;
[0133] A connection is established with the database based on the aforementioned database connection information;
[0134] The executable script is executed on the database to generate a data table in the database for storing the data to be shared.
[0135] The database can be a relational database. Database connection information may include the database's network address, username, and password, which allows a connection to the database to be established. The system can receive user-inputted database connection information on a second interactive interface. Based on the user input on the second interactive interface, the database driver is loaded and a database connection object is obtained. If the database connection object is successfully obtained, a successful database connection message is generated on the second interactive interface, and the successful database connection information is saved to the database connection pool for future database interaction. If the database connection object is not successfully obtained, a database connection failure message is generated on the second interactive interface. A database connection failure indicates that the input database connection information is unusable, thus verifying the availability of the database.
[0136] In this embodiment, database connection information input by the user is received; a connection is established with the database based on the database connection information; and the executable script is executed on the database to generate a data table in the database for storing the data to be shared. This allows for a quick connection to the database containing the information to be shared and the generation of a data table in the database for storing the data to be shared.
[0137] As a specific embodiment, the information sharing method may include the following process:
[0138] A second interactive interface is generated based on the relational database configuration. The second interactive interface is used to receive user input of relational database connection information, SQL script export directory address, and configuration verification interactive button.
[0139] Based on the user input on the second interactive interface, configure and validate the loading of the relational database driver and obtain the database connection object; if the user on the second interactive interface inputs the directory address for exporting an SQL script, then use the JDK API to verify whether the directory exists; if the directory address exists, then save the directory address to local memory.
[0140] A first interactive interface is generated based on the API interface message. The first interactive interface is used to receive the API interface message input by the user and verify the legality of the API interface message; the legality of the API interface message input by the user is verified.
[0141] Generate a Map object based on a valid API interface message; generate an SQL script based on the Map object;
[0142] Based on the SQL script generated by the Map object, a fourth interactive interface is generated. The fourth interactive interface is used to display the generated SQL script and allow the user to fine-tune the SQL script.
[0143] Based on the user-tuned SQL script, a third interactive interface is generated, which is used to display the database connection information input by the user.
[0144] The system creates a PreparedStatement object using an SQL script as a parameter, relying on the connection object stored in the database connection pool. Then, it executes the SQL script in the relational database using the PreparedStatement object's executeUpdate() method. If no exception is thrown, the database construction is successful, and the third interactive interface is refreshed; otherwise, a database construction failure message is generated.
[0145] In this embodiment of the invention, JavaFX desktop application technology is used for the interactive interface design, which facilitates user download and installation and improves the convenience of user interaction; a method for directly converting API interface messages into database tables is provided to improve project development efficiency; and an interactive interface for directly converting API interface messages into SQL scripts is provided to increase the convenience of project development.
[0146] See Figure 2 , Figure 2 This is a schematic diagram of the structure of an information sharing device provided in an embodiment of the present invention, as shown below. Figure 2 As shown, the information sharing device 200 includes:
[0147] The first receiving module 201 is used to receive a first application programming interface (API) message sent by a data source. The first API message includes information to be shared described in a first programming language. The information to be shared includes index information and data to be shared corresponding to the index information.
[0148] The conversion module 202 is used to parse the index information and convert the language type of the data to be shared corresponding to the index information from the first programming language to the second programming language;
[0149] The generation module 203 is used to generate an executable script based on the data to be shared described in the second programming language.
[0150] Optional, such as Figure 3 As shown, the generation module 203 includes:
[0151] Create unit 2031 to create a Map object;
[0152] Filling unit 2032 is used to fill the Map object according to the index information and the data to be shared described by the second programming language;
[0153] The generation unit 2033 is used to generate an executable script based on the filled Map object.
[0154] Optionally, if the first API interface message is a message in Extensible Markup Language (XML) format, the index information is a tag name, and the data to be shared corresponding to the index information is a tag value;
[0155] The filling unit 2032 is specifically used for:
[0156] Format the tag name;
[0157] The formatted tag name and the data to be shared described in the second programming language are populated into the Map object as key-value pairs.
[0158] Optionally, the generation unit 2033 is specifically used for:
[0159] Constructing a string involves creating a StringBuilder object;
[0160] Obtain the key and value information from the populated Map object;
[0161] Concatenate the key information and the value information into a target string according to a preset format;
[0162] Append the target string to the end of the StringBuilder object;
[0163] An executable script is generated based on the concatenated StringBuilder object.
[0164] Optionally, the first receiving module 201 is further configured to:
[0165] Display the first interactive interface;
[0166] Receive a second API interface message input by the user in the first interactive interface, the second API interface message being used to request the data source to send the information to be shared;
[0167] Send the second API interface message to the data source;
[0168] The first API interface message is a response message to the second API interface message.
[0169] Optional, such as Figure 4 As shown, the device 200 further includes:
[0170] Display module 204 is used to display the second interactive interface;
[0171] The second receiving module 205 is used to receive the script directory address input by the user in the second interactive interface, and the script directory address is used to store the executable script;
[0172] Verification module 206 is used to verify whether the script directory address is a valid address;
[0173] Storage module 207 is used to store the script directory address when the script directory address is a valid address.
[0174] Optional, such as Figure 5 As shown, the device 200 further includes:
[0175] The third receiving module 208 is used to receive database connection information input by the user;
[0176] Connection module 209 is used to establish a connection with the database based on the database connection information;
[0177] The execution module 210 is used to execute the executable script against the database to generate a data table in the database for storing the data to be shared.
[0178] Information sharing devices can achieve Figure 1 The various processes implemented in the method embodiments can achieve the same technical effect, and will not be described again here to avoid repetition.
[0179] like Figure 6 As shown, this embodiment of the invention also provides an electronic device 300, including: a processor 301, a memory 302, and a program stored in the memory 302 and executable on the processor 301. When the program is executed by the processor 301, it implements the various processes of the above-described information sharing method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0180] This invention also provides a computer-readable storage medium storing a computer program. When executed by a processor, this computer program implements the various processes of the above-described information sharing method embodiments and achieves the same technical effects. To avoid repetition, it will not be described again here. The computer-readable storage medium may be, for example, ROM, RAM, a magnetic disk, or an optical disk.
[0181] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0182] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0183] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of the present invention.
Claims
1. An information sharing method, characterized in that, The method includes: Receive a first API interface message sent by a data source. The first API interface message includes information to be shared described in a first programming language. The information to be shared includes index information and data to be shared corresponding to the index information. Parse the index information and convert the language type of the data to be shared corresponding to the index information from the first programming language to the second programming language; Generate an executable script based on the data to be shared as described in the second programming language; The step of generating an executable script based on the data to be shared described in the second programming language includes: Create a Map object; The Map object is populated based on the index information and the data to be shared described in the second programming language; An executable script is generated based on the populated Map object.
2. The method according to claim 1, characterized in that, When the first API interface message is a message in Extensible Markup Language (XML) format, the index information is the tag name, and the data to be shared corresponding to the index information is the tag value; The step of populating the Map object based on the index information and the data to be shared described in the second programming language includes: Format the tag name; The formatted tag name and the data to be shared described in the second programming language are populated into the Map object as key-value pairs.
3. The method according to claim 1, characterized in that, The generation of an executable script based on the populated Map object includes: Constructing a string involves creating a StringBuilder object; Obtain the key and value information from the populated Map object; Concatenate the key information and the value information into a target string according to a preset format; Append the target string to the end of the StringBuilder object; An executable script is generated based on the concatenated StringBuilder object.
4. The method according to claim 1, characterized in that, Before receiving the first API interface message sent by the data source, the method further includes: Display the first interactive interface; Receive a second API interface message input by the user in the first interactive interface, the second API interface message being used to request the data source to send the information to be shared; Send the second API interface message to the data source; The first API interface message is a response message to the second API interface message.
5. The method according to claim 1, characterized in that, Before generating the executable script based on the data to be shared described in the second programming language, the method further includes: Display the second interactive interface; The system receives the script directory address input by the user in the second interactive interface, and the script directory address is used to store the executable script. Verify that the script directory address is a valid address; If the script directory address is a valid address, store the script directory address.
6. The method according to claim 1, characterized in that, After generating the executable script based on the data to be shared described in the second programming language, the method further includes: Receive database connection information input by the user; A connection is established with the database based on the aforementioned database connection information; The executable script is executed on the database to generate a data table in the database for storing the data to be shared.
7. An information sharing device, characterized in that, The device includes: The first receiving module is used to receive a first API interface message sent by the data source. The first API interface message includes information to be shared described in a first programming language. The information to be shared includes index information and data to be shared corresponding to the index information. A conversion module is used to parse the index information and convert the language type of the data to be shared corresponding to the index information from the first programming language to the second programming language. A generation module is used to generate an executable script based on the data to be shared described in the second programming language. The generation module includes: Create a unit used to create a Map object; A filling unit is used to fill the Map object based on the index information and the data to be shared described in the second programming language; A generation unit is used to generate an executable script based on the populated Map object.
8. An electronic device, characterized in that, include: A processor, a memory, and a program stored in the memory and executable on the processor, wherein the program, when executed by the processor, implements the steps of the information sharing method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the information sharing method as described in any one of claims 1 to 6.