Data sharing method and device, equipment and medium
By creating data resource tables in business scenarios in the database and using common interfaces for data storage and query, the inefficient data sharing caused by the numerous development interfaces in the existing technology is solved, and efficient data sharing is achieved.
Patent Information
- Application Number
- CN202411099732.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-11-29
AI Technical Summary
The existing data sharing platform needs to develop a large number of interfaces for each business scenario, resulting in large development workloads, long cycles, low efficiency, and inability to quickly share data.
Create data resource database tables in each business scenario in the database, receive data transmission and query messages through the general transmission interface and query interface, and dynamically store and query data using identification information and statement splicing rules, reducing the number of data for each business scenario interface development requirements.
It realizes that data resources in various business scenarios are stored and queried through common interfaces, reducing development workload, shortening development cycles, improving data sharing efficiency, and no need to consider network issues between databases, making them more general and fast.
Smart Images

Figure CN119046353A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data sharing method, device, equipment and medium. Background Art
[0002] With the development of computer technology, data sharing methods are becoming more and more diverse, and data sharing through data sharing platforms is currently a more common method. Since different data publishers can transmit data to the data sharing platform, data users can view data from different publishers on the data sharing platform, which effectively improves data sharing efficiency.
[0003] In the related art, since different data publishers correspond to different business scenarios, the data sharing platform needs to develop a data transmission interface for each data publisher's business scenario for the publisher to transmit data to the data sharing platform, and develop a data query interface for the user to query data on the data sharing platform. However, based on the above approach, the data sharing platform needs to develop a large number of interfaces to realize data sharing in various business scenarios. The development workload is large, a large amount of development resources are required, and the development cycle is long, resulting in the inability to share data as soon as possible and low data sharing efficiency. Summary of the invention
[0004] The embodiments of the present application provide a data sharing method, apparatus, device and medium for improving data sharing efficiency.
[0005] In a first aspect, the present application provides a data sharing method, the method comprising:
[0006] Based on the data resources to be released in multiple business scenarios, respectively create database tables for the data resources in the database;
[0007] In any business scenario, a data transmission message is received through a universal transmission interface, wherein the data transmission message includes shared data and identification information of the shared data, wherein the identification information includes: a first identification of a first data resource to which the shared data belongs;
[0008] When it is determined based on the first identifier that a first database table corresponding to the first data resource exists in the database, storing the shared data in the first database table;
[0009] Receiving a data query message through a general query interface, wherein the data query message includes a second identifier of a second data resource to which the query data belongs;
[0010] When it is determined based on the second identifier that a second database table corresponding to the second data resource exists in the database, the query data is obtained from the second database table, and the query data is returned through the general query interface.
[0011] In a possible embodiment, the identification information further includes: a field type and a data identification of the shared data; when it is determined based on the first identification that a first database table corresponding to the first data resource exists in the database, storing the shared data in the first database table includes:
[0012] When it is determined based on the first identifier that the first database table exists in the database, searching the first database table for each piece of data under the field type;
[0013] Determining a statement concatenation rule for the shared data based on the data identifiers of the respective pieces of data and the data identifiers of the shared data;
[0014] Dynamically splicing the shared data based on the statement splicing rule to obtain a first splicing statement;
[0015] The shared data is stored in the first database table by executing the first concatenation statement.
[0016] In a possible embodiment, determining the statement concatenation rule of the shared data based on the data identifiers of the respective pieces of data and the data identifier of the shared data includes:
[0017] When the data identifiers of the respective pieces of data include the data identifier of the shared data, determining the update statement concatenation rule as the statement concatenation rule of the shared data;
[0018] When the data identifiers of the respective pieces of data do not include the data identifier of the shared data, the newly added statement concatenation rule is determined as the statement concatenation rule of the shared data.
[0019] In a possible embodiment, the data query message further includes a field type and a query condition of the query data; when it is determined based on the second identifier that a second database table corresponding to the second data resource exists in the database, obtaining the query data from the second database table includes:
[0020] When it is determined based on the second identifier that the second database table exists in the database, dynamically concatenate the field type of the query data, the query condition, and the second identifier to obtain a second concatenation statement;
[0021] The query data is obtained from the second database table by executing the second concatenation statement.
[0022] In a possible embodiment, returning the query data through the general query interface includes:
[0023] When it is determined that the amount of the query data is greater than a preset threshold, the query data is divided according to the preset threshold to obtain a plurality of sub-query data, wherein the amount of each sub-query data is not greater than the preset threshold;
[0024] The plurality of sub-query data are returned in sequence through the general query interface.
[0025] In a possible embodiment, returning the plurality of sub-query data in sequence through the general query interface includes:
[0026] Encrypting the plurality of sub-query data respectively based on a preset encryption algorithm to obtain encrypted data corresponding to each sub-query data;
[0027] The plurality of encrypted data are returned in sequence through the general query interface.
[0028] In a possible embodiment, the existence of the first database table is determined in the following manner:
[0029] Dynamically concatenate the first identifiers based on preset grammatical rules to obtain a query statement;
[0030] Sending the query statement to the database and receiving the returned query result;
[0031] When the query result includes a pass identifier, it is determined that the first database table exists.
[0032] In a possible embodiment, the step of creating respective database tables of the data resources to be released in the database based on the data resources to be released in multiple business scenarios includes:
[0033] Receiving a data publishing message sent by a data publisher in any business scenario, wherein the data publishing message includes: a field type included in a data resource to be published in a corresponding business scenario;
[0034] Based on the field types included in the data resource, a corresponding database table is created in the database.
[0035] In a second aspect, the present application provides a data sharing device, the device comprising:
[0036] A creation unit, configured to create respective database tables of the data resources to be released in a database based on the data resources to be released in multiple business scenarios;
[0037] A transmission unit, configured to receive a data transmission message through a universal transmission interface in any service scenario, wherein the data transmission message includes shared data and identification information of the shared data, wherein the identification information includes: a first identification of a first data resource to which the shared data belongs;
[0038] A storage unit, configured to store the shared data in the first database table when it is determined that a first database table corresponding to the first data resource exists in the database based on the first identifier;
[0039] A receiving unit, configured to receive a data query message through a universal query interface, wherein the data query message includes a second identifier of a second data resource to which the query data belongs;
[0040] A query unit is used to obtain the query data from the second database table when it is determined based on the second identifier that a second database table corresponding to the second data resource exists in the database, and return the query data through the general query interface.
[0041] In a possible embodiment, the identification information further includes: a field type and a data identifier of the shared data; and the storage unit is specifically used for:
[0042] When it is determined based on the first identifier that the first database table exists in the database, searching the first database table for each piece of data under the field type;
[0043] Determining a statement concatenation rule for the shared data based on the data identifiers of the respective pieces of data and the data identifiers of the shared data;
[0044] Dynamically splicing the shared data based on the statement splicing rule to obtain a first splicing statement;
[0045] The shared data is stored in the first database table by executing the first concatenation statement.
[0046] In a possible embodiment, the storage unit is specifically used for:
[0047] When the data identifiers of the respective pieces of data include the data identifier of the shared data, determining the update statement concatenation rule as the statement concatenation rule of the shared data;
[0048] When the data identifiers of the respective pieces of data do not include the data identifier of the shared data, the newly added statement concatenation rule is determined as the statement concatenation rule of the shared data.
[0049] In a possible embodiment, the data query message further includes the field type and query condition of the query data; and the query unit is specifically configured to:
[0050] When it is determined based on the second identifier that the second database table exists in the database, dynamically concatenate the field type of the query data, the query condition, and the second identifier to obtain a second concatenation statement;
[0051] The query data is obtained from the second database table by executing the second concatenation statement.
[0052] In a possible embodiment, the query unit is specifically used for:
[0053] When it is determined that the amount of the query data is greater than a preset threshold, the query data is divided according to the preset threshold to obtain a plurality of sub-query data, wherein the amount of each sub-query data is not greater than the preset threshold;
[0054] The plurality of sub-query data are returned in sequence through the general query interface.
[0055] In a possible embodiment, the query unit is specifically used for:
[0056] Encrypting the plurality of sub-query data respectively based on a preset encryption algorithm to obtain encrypted data corresponding to each sub-query data;
[0057] The plurality of encrypted data are returned in sequence through the general query interface.
[0058] In a possible embodiment, the existence of the first database table is determined in the following manner:
[0059] Dynamically concatenate the first identifiers based on preset grammatical rules to obtain a query statement;
[0060] Sending the query statement to the database and receiving the returned query result;
[0061] When the query result includes a pass identifier, it is determined that the first database table exists.
[0062] In a possible embodiment, the creating unit is specifically used for:
[0063] Receiving a data publishing message sent by a data publisher in any business scenario, wherein the data publishing message includes: a field type included in a data resource to be published in a corresponding business scenario;
[0064] Based on the field types included in the data resource, a corresponding database table is created in the database.
[0065] In a third aspect, the present application provides an electronic device, including:
[0066] A memory for storing program instructions;
[0067] The processor is used to call the program instructions stored in the memory, and execute the steps included in any one of the methods in the first aspect according to the obtained program instructions.
[0068] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes any one of the methods described in the first aspect.
[0069] In a fifth aspect, the present application provides a computer program product, comprising: a computer program code, when the computer program code is run on a computer, the computer executes any one of the methods described in the first aspect.
[0070] The beneficial effects of this application are as follows:
[0071] The embodiment of the present application provides a data sharing method, device, electronic device and storage medium. First, a database table of the data resources to be released in each business scenario is created in the database respectively. Then, in any business scenario, a data transmission message containing shared data is received through a universal transmission interface; when the corresponding first database table is determined based on the first identifier of the shared data, the shared data is stored in the first database table, and a data query message containing the second identifier of the second data resource to which the query data belongs is received through a universal query interface; when it is determined based on the second identifier that there is a corresponding second database table, the query data is obtained from the second database table, and the query data is returned through the universal query interface. Based on the above method, the data resources in each business scenario can be stored in the corresponding database table through the universal transmission interface, and can be queried from the database table through the universal query interface. There is no need to develop interfaces for each business scenario, which reduces the development workload, shortens the development cycle, improves development efficiency, and thus improves data sharing efficiency. Compared with data sharing at the database level, the method of sharing data through interfaces in the present application does not need to consider network issues between databases, and is more universal and fast.
[0072] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] Figure 1 A schematic diagram of an application scenario provided in an embodiment of the present application;
[0074] Figure 2 A flowchart of a data sharing method provided in an embodiment of the present application;
[0075] Figure 3 A structural diagram of a data sharing device provided in an embodiment of the present application;
[0076] Figure 4 A structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0077] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.
[0078] The terms "first" and "second" in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive protection. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in the present application can mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.
[0079] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description. It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0080] In the technical solution of this application, the acquisition, transmission, storage, and use of data are in compliance with the requirements of relevant national laws and regulations.
[0081] The following is an introduction to some concepts involved in the embodiments of the present application.
[0082] Structured Query Language (SQL): is a special-purpose programming language, a database query and programming language used to access data and query, update, and manage relational database systems. Different database systems with completely different underlying structures can use the same SQL as an interface for data input and management. Because SQL statements can be nested, it has great flexibility and powerful functions.
[0083] Database: It can be regarded as an electronic filing cabinet - a place to store electronic files, where users can add, query, update, delete, etc. The so-called "database" is a collection of data that is stored together in a certain way, can be shared with multiple users, has as little redundancy as possible, and is independent of the application.
[0084] Before introducing the data sharing method provided in the embodiment of the present application, in order to facilitate understanding, the technical background of the embodiment of the present application is first introduced in detail below.
[0085] With the development of computer technology, data sharing methods are becoming more and more diverse, and data sharing through data sharing platforms is currently a more common method. Since different data publishers can transmit data to the data sharing platform, data users can view data from different publishers on the data sharing platform, which effectively improves data sharing efficiency.
[0086] In the related art, since different data publishers correspond to different business scenarios, the data sharing platform needs to develop a data transmission interface for each data publisher's business scenario for the publisher to transmit data to the data sharing platform, and develop a data query interface for the user to query data on the data sharing platform. However, based on the above approach, the data sharing platform needs to develop a large number of interfaces to realize data sharing in various business scenarios. The development workload is large, a large amount of development resources are required, and the development cycle is long, resulting in the inability to share data as soon as possible and low data sharing efficiency.
[0087] In view of this, the embodiment of the present application provides a data sharing method, device, electronic device and storage medium. First, a database table of the data resources to be released in each business scenario is created in the database respectively. Then, in any business scenario, a data transmission message containing shared data is received through a universal transmission interface; when the corresponding first database table is determined based on the first identifier of the shared data, the shared data is stored in the first database table, and a data query message containing the second identifier of the second data resource to which the query data belongs is received through a universal query interface; when it is determined based on the second identifier that there is a corresponding second database table, the query data is obtained from the second database table, and the query data is returned through the universal query interface. Based on the above method, the data resources in each business scenario can be stored in the corresponding database table through the universal transmission interface, and can be queried from the database table through the universal query interface. There is no need to develop interfaces for each business scenario, which reduces the development workload, shortens the development cycle, improves the development efficiency, and thus improves the data sharing efficiency. Compared with data sharing at the database level, the method of sharing data through interfaces in the present application does not need to consider network issues between databases, and is more universal and fast.
[0088] like Figure 1 As shown, it is a schematic diagram of an application scenario of an embodiment of the present application. The application scenario diagram includes a data provider 110, a data query party 120 and a data sharing platform 210.
[0089] In the embodiment of the present application, the data provider 110 and the data query party 120 can be terminal devices, including but not limited to mobile phones, tablet computers, laptop computers, desktop computers, e-book readers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals and other devices; a client related to data sharing can be installed on the terminal device, which can be software (such as a browser, data sharing software, etc.), or a web page, a small program, etc. The data sharing platform 210 can be a server, and the server is a background server corresponding to the software or web page, small program, etc., or a server specifically used for the data sharing platform 210 server, which is not specifically limited in the present application. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms.
[0090] In an optional implementation, the data provider 110 , the data query party 120 , and the data sharing platform 210 may communicate with each other via a communication network.
[0091] In an optional implementation, the communication network is a wired network or a wireless network.
[0092] It should be noted that Figure 1 The figure is only an example. In fact, the number of data providers 110, data query parties 120 and data sharing platforms 210 is not limited and is not specifically limited in the embodiments of the present application.
[0093] The following describes the code processing method provided by the exemplary embodiment of the present application in combination with the application scenario described above and with reference to the accompanying drawings. It should be noted that the above application scenario is only shown to facilitate understanding of the spirit and principles of the present application, and the implementation of the present application is not limited in this respect.
[0094] Figure 2 A flow chart of a data sharing method provided in an embodiment of the present application is shown as follows: Figure 2 As shown, the embodiment of the present application provides a data sharing method, and the processing process of the method is as follows:
[0095] S21: Based on the data resources to be released in multiple business scenarios, create a database table for each data resource in the database;
[0096] Specifically, a database table for each data resource needs to be created in advance on the data sharing platform to store the data provided by subsequent data providers and to obtain the data that the data query party needs to query. Each business scenario may include multiple data resources to be released by the data provider. For example, the data resources to be released by the data provider include: data resource 1 is a first-hand house sale and purchase information resource, data resource 2 is a second-hand house sale and purchase information resource, and data resource 3 is a house rental information resource. In this case, a corresponding database table 1 is created for data resource 1, a corresponding database table 2 is created for data resource 2, and a corresponding database table 3 is created for data resource 3.
[0097] Optionally, step S21 may be implemented as follows:
[0098] A data publishing message is received from a data publisher in any business scenario. The data publishing message includes: field types contained in the data resources to be published in the corresponding business scenario; and based on the field types contained in the data resources, a corresponding database table is created in the database.
[0099] Specifically, the field type may be: age, region, price, area, etc., which is set according to the data resource and is not specifically limited here.
[0100] The data publisher (i.e., data provider) in each business scenario needs to first publish the data directory on the data sharing platform, including specific data resource items. The data sharing platform will create a database table for the corresponding business based on the specific fields in the data resources. For example, when the platform is connected with the housing and construction department, the housing and construction department will create a real estate resource information directory and publish first-hand housing sales information resources, second-hand housing sales information resources, etc. under this directory. After successful publication, the platform will create a corresponding database table for each data resource to collect data.
[0101] The backend of the data exchange platform is based on the Java development language and development frameworks such as Springboot and Springcloud. The database can use a relational database (MySQL), Oracle database, Renmin University of China Golden Warehouse database or other domestic databases, without specific restrictions here.
[0102] S22: receiving a data transmission message through a universal transmission interface in any service scenario;
[0103] Among them, the data provider pushes data to the data sharing platform through the general transmission interface, specifically through the data transmission message carrying the data to be released, that is, the shared data. The data transmission message contains the shared data and the identification information of the shared data. The identification information includes the first identification of the first data resource to which the shared data belongs (also known as the entity identity identification number (Identity Document, ID)). For example, shared resource 1 is: region A province B city, area 120 square meters, price 300,000 yuan, the first data resource to which shared resource 1 belongs is a first-hand house sale and purchase information resource, and the first identification is 001001.
[0104] In addition, after each data provider registers on the platform, a set of proprietary keys and security tokens and other parameters will be generated. Before each data provider requests the interface, it will generate a signature using the public key and token and encrypt the message. The data exchange platform will decrypt the message and obtain the content.
[0105] S23: when it is determined based on the first identifier that a first database table corresponding to the first data resource exists in the database, storing the shared data in the first database table;
[0106] Among them, because it is a universal transmission interface, it is necessary to identify in which database table the data provider stores the data, and verify whether the corresponding database table exists through the first identifier. If the verification does not exist, it means that the database table does not exist and the shared data cannot be stored.
[0107] Optionally, the existence of the first database table is determined in the following manner:
[0108] The first identifier is dynamically spliced based on a preset grammatical rule to obtain a query statement; the query statement is sent to a database, and a returned query result is received; when the query result contains a pass identifier, it is determined that the first database table exists.
[0109] Specifically, since the first identifiers of different database tables are different, each time you query whether a table exists, you need to dynamically splice query statements. You can use the Java native database connection (Java Database Connectivity, JDBC) application programming interface (Application Programming Interface, API) method to first create a connection with the database through a database connection (Connection) object, and then execute the spliced query statement by calling the relevant methods of the statement (Statement) object. Finally, the result set (ResultSet) object receives the execution result set, that is, the query result. The query interface includes a pass identifier or a fail identifier. The pass identifier indicates the existence of the first database table, and the fail identifier indicates the non-existence of the first database table. 1 can be used to indicate a pass identifier, and 0 can be used to indicate a fail identifier.
[0110] Optionally, step S23 may be implemented as follows:
[0111] S231: when it is determined based on the first identifier that a first database table exists in the database, searching for each piece of data under a field type in the first database table;
[0112] S232: Determine a statement concatenation rule for the shared data based on the data identifiers of the respective data pieces and the data identifiers of the shared data;
[0113] S233: Dynamically splicing the shared data based on the sentence splicing rule to obtain a first spliced sentence;
[0114] S234: Storing the shared data in the first database table by executing the first concatenation statement.
[0115] Specifically, when creating a database table on the data exchange platform, specific fields need to be created. When pushing data, the fields in the data transmission message must also correspond one-to-one with the fields in the database table.
[0116] In the standard docking specifications provided by the data sharing platform, it must be agreed that each shared data pushed by the data provider must have a unique identifier, namely the data identifier, so that it can be determined whether the data is updated or newly added, and then the corresponding statement splicing rules are used to obtain the first splicing statement. There are some fixed fields in the statement splicing rules, such as conditional (where) statements and insert (insert) statements. These fields are dynamically spliced with the shared data to obtain the first splicing statement.
[0117] Optionally, step S232 may be implemented as follows:
[0118] When the data identifiers of the respective data pieces include the data identifier of the shared data, the update statement concatenation rule is determined as the statement concatenation rule of the shared data;
[0119] When the data identifiers of the respective data pieces do not include the data identifier of the shared data, the newly added statement concatenation rule is determined as the statement concatenation rule of the shared data.
[0120] Specifically, if the data identifiers of each piece of data include the data identifier of shared data, indicating that an update operation is performed on the data, the statement splicing rules include a where conditional statement, etc. If the data identifier of the shared data is not included, indicating that new data needs to be added, the statement splicing rules include an insert statement, etc., and the various fields of the insert statement are dynamically spliced according to the shared data.
[0121] S24: receiving a data query message through a general query interface;
[0122] Among them, the data query message contains the second identifier of the second data resource to which the queried data belongs. Similarly, before querying the data, the data query party needs to find the second identifier corresponding to the data to be queried in the data resources mounted under the resource directory of the data provider, and carry the second identifier in the data query message so that the data exchange platform can query the corresponding database table according to the second identifier.
[0123] The general query interface also needs to be verified for security, otherwise, once a loophole is bypassed, sensitive / important data information will be leaked. For example, the data query message can be encrypted through the national secret SM4, national secret SM2 algorithm, etc., and signature verification can be added, etc., without specific restrictions here.
[0124] S25: When it is determined based on the second identifier that a second database table corresponding to the second data resource exists in the database, query data is obtained from the second database table, and the query data is returned through the general query interface.
[0125] Specifically, the general query interface needs to identify which database table the data query party queries data from, and verify whether there is a corresponding database table through the second identifier. If the verification does not exist, it means that the database table does not exist and the data cannot be queried.
[0126] Optionally, step S25 may be implemented as follows:
[0127] When it is determined based on the second identifier that a second database table exists in the database, the field type of the query data, the query condition and the second identifier are dynamically concatenated to obtain a second concatenation statement; and the query data is obtained from the second database table by executing the second concatenation statement.
[0128] Specifically, the second concatenation statement is dynamically concatenated according to the input fields, query conditions, and the second identifier, a database connection is created through JDBC, the concatenated second concatenation statement is executed, and the returned query data is obtained.
[0129] Optionally, step S25 may be implemented as follows:
[0130] S251: when it is determined that the amount of the query data is greater than a preset threshold, the query data is divided according to the preset threshold to obtain a plurality of sub-query data, wherein the amount of each sub-query data is not greater than the preset threshold;
[0131] S252: Return multiple sub-query data in sequence through the general query interface.
[0132] Specifically, because the present application provides a universal interface, multiple business scenarios query data through one interface and transmit data through one interface. In order to prevent excessive access volume from exceeding the system / interface load, flow control needs to be set. When the amount of query data is greater than the preset threshold, the query data will be divided into multiple parts and then transmitted separately.
[0133] You can also limit the data transmitted each time through the general transmission interface, for example, limit the maximum transmission to 500 at a time, and limit the data queried each time through the general query interface, for example, return a maximum of 1000 in one query. The specific settings can be made according to needs and are not specifically limited here.
[0134] Optionally, step S252 may be implemented as follows:
[0135] Based on a preset encryption algorithm, multiple sub-query data are encrypted respectively to obtain encrypted data corresponding to each sub-query data; and multiple encrypted data are returned in sequence through a general query interface.
[0136] Specifically, the preset encryption algorithm can be national encryption SM2, national encryption SM4, etc., which is not specifically limited here.
[0137] In an embodiment of the present application, first, a database table of the data resources to be released in each business scenario is created in the database, and then, in any business scenario, a data transmission message containing shared data is received through a universal transmission interface; when the corresponding first database table is determined based on the first identifier of the shared data, the shared data is stored in the first database table, and a data query message containing the second identifier of the second data resource to which the query data belongs is received through a universal query interface; when it is determined based on the second identifier that there is a corresponding second database table, the query data is obtained from the second database table, and the query data is returned through the universal query interface. Based on the above method, the data resources in each business scenario can be stored in the corresponding database table through the universal transmission interface, and can be queried from the database table through the universal query interface. There is no need to develop interfaces for each business scenario, which reduces the development workload, shortens the development cycle, improves development efficiency, and thus improves data sharing efficiency. Compared with data sharing at the database level, the method of sharing data through interfaces in the present application does not need to consider network issues between databases, and is more universal and fast.
[0138] In this application, the log records of the general transmission interface and the general query interface calls are preferably recorded asynchronously to improve the interface response speed. If the data sharing and exchange platform is applied in a wide range of fields and has a large business volume, a general interface can be created for each field according to different fields, that is, refined classification.
[0139] Based on the same inventive concept, the present application embodiment provides a data sharing device 300, please refer to Figure 3 , the device comprises:
[0140] A creation unit 301 is used to create a database table for each data resource in a database based on each data resource to be released in multiple business scenarios;
[0141] The transmission unit 302 is used to receive a data transmission message through a universal transmission interface in any service scenario, where the data transmission message includes shared data and identification information of the shared data, where the identification information includes: a first identification of a first data resource to which the shared data belongs;
[0142] The storage unit 303 is used to store the shared data in the first database table when it is determined that there is a first database table corresponding to the first data resource in the database based on the first identifier;
[0143] A receiving unit 304 is configured to receive a data query message through a general query interface, wherein the data query message includes a second identifier of a second data resource to which the query data belongs;
[0144] The query unit 305 is used to obtain query data from the second database table when it is determined based on the second identifier that a second database table corresponding to the second data resource exists in the database, and return the query data through the general query interface.
[0145] In a possible embodiment, the identification information further includes: a field type and a data identification of the shared data; the storage unit 303 is specifically used for:
[0146] When it is determined that the first database table exists in the database based on the first identifier, searching for each piece of data under the field type in the first database table;
[0147] Determine the statement concatenation rule of the shared data based on the data identifiers of the respective data pieces and the data identifiers of the shared data;
[0148] Dynamically splicing the shared data based on the sentence splicing rule to obtain a first spliced sentence;
[0149] By executing the first concatenation statement, the shared data is stored in the first database table.
[0150] In a possible embodiment, the storage unit 303 is specifically used for:
[0151] When the data identifiers of the respective data pieces include the data identifier of the shared data, the update statement concatenation rule is determined as the statement concatenation rule of the shared data;
[0152] When the data identifiers of the respective data pieces do not include the data identifier of the shared data, the newly added statement concatenation rule is determined as the statement concatenation rule of the shared data.
[0153] In a possible embodiment, the data query message further includes the field type of the query data and the query condition; the query unit 305 is specifically used to:
[0154] When it is determined that the second database table exists in the database based on the second identifier, the field type of the query data, the query condition and the second identifier are dynamically concatenated to obtain a second concatenation statement;
[0155] By executing the second concatenation statement, query data is obtained from the second database table.
[0156] In a possible embodiment, the query unit 305 is specifically configured to:
[0157] When it is determined that the amount of the query data is greater than the preset threshold, the query data is divided according to the preset threshold to obtain a plurality of sub-query data, wherein the amount of each sub-query data is not greater than the preset threshold;
[0158] Multiple sub-query data are returned sequentially through the general query interface.
[0159] In a possible embodiment, the query unit 305 is specifically configured to:
[0160] Encrypting multiple sub-query data respectively based on a preset encryption algorithm to obtain encrypted data corresponding to each sub-query data;
[0161] Multiple encrypted data are returned in sequence through the general query interface.
[0162] In a possible embodiment, the existence of the first database table is determined in the following manner:
[0163] Dynamically concatenate the first identifier based on a preset grammatical rule to obtain a query statement;
[0164] Send query statements to the database and receive returned query results;
[0165] When the query result includes the pass identifier, it is determined that the first database table exists.
[0166] In a possible embodiment, the creating unit 301 is specifically used for:
[0167] Receive a data publishing message sent by a data publisher in any business scenario. The data publishing message includes: the field type of the data resource to be published in the corresponding business scenario;
[0168] Based on the field types contained in the data resource, create the corresponding database table in the database.
[0169] Based on the same inventive concept, the present application embodiment provides an electronic device, which can realize the functions of the data sharing device discussed above. Please refer to Figure 4 The device includes at least one processor 401 and a memory 402 connected to the at least one processor. The specific connection medium between the processor 401 and the memory 402 is not limited in the embodiment of the present application. Figure 4 The processor 401 and the memory 402 may be connected via a bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 The fact that only one line is used in the diagram does not mean that there is only one bus or only one type of bus.
[0170] Among them, the processor 401 is the control center of the electronic device, which can use various interfaces and lines to connect various parts of the electronic device, and realize data processing by running or executing instructions stored in the memory 402 and calling data stored in the memory 402. Optionally, the processor 401 may include one or more processing units, and the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, etc., and the modem processor mainly processes the issuance of instructions. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401. In some embodiments, the processor 401 and the memory 402 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on independent chips.
[0171] Processor 401 can be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiment of the code processing method can be directly embodied as a hardware processor for execution, or can be executed by a combination of hardware and software modules in the processor.
[0172] The memory 402 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 402 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (Random Access Memory, RAM), a static random access memory (Static Random Access Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 402 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 402 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.
[0173] In the embodiment of the present application, the memory 402 stores a computer program. When the program is executed by the processor 401, the processor 401 executes:
[0174] In any business scenario, a data transmission message is received through a universal transmission interface, the data transmission message includes shared data and identification information of the shared data, and the identification information includes: a first identification of a first data resource to which the shared data belongs;
[0175] When it is determined based on the first identifier that a first database table corresponding to the first data resource exists in the database, storing the shared data in the first database table;
[0176] Receiving a data query message through a general query interface, wherein the data query message includes a second identifier of a second data resource to which the query data belongs;
[0177] When it is determined based on the second identifier that a second database table corresponding to the second data resource exists in the database, query data is obtained from the second database table, and the query data is returned through the general query interface.
[0178] Based on the same inventive concept, the embodiment of the present application provides a computer-readable storage medium, and the computer program product includes: computer program code, when the computer program code is executed on a computer, the computer executes any of the data sharing methods discussed above. Since the principle of solving the problem by the above-mentioned computer-readable storage medium is similar to that of the data sharing method, the implementation of the above-mentioned computer-readable storage medium can refer to the implementation of the method, and the repeated parts will not be repeated.
[0179] Based on the same inventive concept, the embodiment of the present application also provides a computer program product, which includes: computer program code, when the computer program code is run on a computer, the computer executes any of the data sharing methods discussed above. Since the principle of solving the problem by the above computer program product is similar to that of the data sharing method, the implementation of the above computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.
[0180] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0181] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0182] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0183] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of user-operated steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0184] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A data sharing method, characterized in that: The method comprises: Based on the data resources to be released in multiple business scenarios, respectively create database tables for the data resources in the database; In any business scenario, a data transmission message is received through a universal transmission interface, wherein the data transmission message includes shared data and identification information of the shared data, wherein the identification information includes: a first identification of a first data resource to which the shared data belongs; When it is determined based on the first identifier that a first database table corresponding to the first data resource exists in the database, storing the shared data in the first database table; Receiving a data query message through a general query interface, wherein the data query message includes a second identifier of a second data resource to which the query data belongs; When it is determined based on the second identifier that a second database table corresponding to the second data resource exists in the database, the query data is obtained from the second database table, and the query data is returned through the general query interface.
2. The method according to claim 1, characterized in that The identification information further includes: a field type and a data identification of the shared data; when it is determined based on the first identification that a first database table corresponding to the first data resource exists in the database, storing the shared data in the first database table includes: When it is determined based on the first identifier that the first database table exists in the database, searching the first database table for each piece of data under the field type; Determining a statement concatenation rule for the shared data based on the data identifiers of the respective pieces of data and the data identifiers of the shared data; Dynamically splicing the shared data based on the statement splicing rule to obtain a first splicing statement; The shared data is stored in the first database table by executing the first concatenation statement.
3. The method according to claim 2, characterized in that The determining, based on the data identifiers of the respective pieces of data and the data identifiers of the shared data, a statement concatenation rule of the shared data includes: When the data identifiers of the respective pieces of data include the data identifier of the shared data, determining the update statement concatenation rule as the statement concatenation rule of the shared data; When the data identifiers of the respective pieces of data do not include the data identifier of the shared data, the newly added statement concatenation rule is determined as the statement concatenation rule of the shared data.
4. The method according to claim 1, characterized in that The data query message also includes the field type and query condition of the query data; when it is determined based on the second identifier that a second database table corresponding to the second data resource exists in the database, obtaining the query data from the second database table includes: When it is determined based on the second identifier that the second database table exists in the database, dynamically concatenate the field type of the query data, the query condition, and the second identifier to obtain a second concatenation statement; The query data is obtained from the second database table by executing the second concatenation statement.
5. The method according to claim 1, characterized in that The returning the query data through the general query interface includes: When it is determined that the amount of the query data is greater than a preset threshold, the query data is divided according to the preset threshold to obtain a plurality of sub-query data, wherein the amount of each sub-query data is not greater than the preset threshold; The plurality of sub-query data are returned in sequence through the general query interface.
6. The method according to claim 5, characterized in that The returning the plurality of sub-query data in sequence through the general query interface includes: Encrypting the plurality of sub-query data respectively based on a preset encryption algorithm to obtain encrypted data corresponding to each sub-query data; The plurality of encrypted data are returned in sequence through the general query interface.
7. The method according to any one of claims 1 to 6, characterized in that: The existence of the first database table is determined by: Dynamically concatenate the first identifiers based on preset grammatical rules to obtain a query statement; Sending the query statement to the database and receiving the returned query result; When the query result includes a pass identifier, it is determined that the first database table exists.
8. The method according to any one of claims 1 to 6, characterized in that: The data resources to be released in multiple business scenarios are based on the creation of respective database tables for the data resources in the database, including: Receiving a data publishing message sent by a data publisher in any business scenario, wherein the data publishing message includes: a field type included in a data resource to be published in a corresponding business scenario; Based on the field types included in the data resource, a corresponding database table is created in the database.
9. A data sharing device, characterized in that: include: A creation unit, configured to create respective database tables of the data resources to be released in a database based on the data resources to be released in multiple business scenarios; A transmission unit, configured to receive a data transmission message through a universal transmission interface in any service scenario, wherein the data transmission message includes shared data and identification information of the shared data, wherein the identification information includes: a first identification of a first data resource to which the shared data belongs; A storage unit, configured to store the shared data in the first database table when it is determined that a first database table corresponding to the first data resource exists in the database based on the first identifier; A receiving unit, configured to receive a data query message through a universal query interface, wherein the data query message includes a second identifier of a second data resource to which the query data belongs; A query unit is used to obtain the query data from the second database table when it is determined based on the second identifier that a second database table corresponding to the second data resource exists in the database, and return the query data through the general query interface.
10. The device according to claim 9, characterized in that The identification information further includes: the field type and data identification of the shared data; the storage unit is specifically used for: When it is determined based on the first identifier that the first database table exists in the database, searching the first database table for each piece of data under the field type; Determining a statement concatenation rule for the shared data based on the data identifiers of the respective pieces of data and the data identifiers of the shared data; Dynamically splicing the shared data based on the statement splicing rule to obtain a first splicing statement; The shared data is stored in the first database table by executing the first concatenation statement.
11. The device according to claim 10, characterized in that The storage unit is specifically used for: When the data identifiers of the respective pieces of data include the data identifier of the shared data, determining the update statement concatenation rule as the statement concatenation rule of the shared data; When the data identifiers of the respective pieces of data do not include the data identifier of the shared data, the newly added statement concatenation rule is determined as the statement concatenation rule of the shared data.
12. The device according to claim 9, characterized in that The data query message also includes the field type and query condition of the query data; the query unit is specifically used for: When it is determined based on the second identifier that the second database table exists in the database, dynamically concatenate the field type of the query data, the query condition, and the second identifier to obtain a second concatenation statement; The query data is obtained from the second database table by executing the second concatenation statement.
13. An electronic device, characterized in that: include: A memory for storing program instructions; A processor is used to call the program instructions stored in the memory, and execute the steps included in any one of the methods of claims 1-8 according to the obtained program instructions.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes the method according to any one of claims 1 to 8.
15. A computer program product, characterized in that The computer program product comprises: a computer program code, and when the computer program code is run on a computer, the computer is enabled to execute the method according to any one of claims 1 to 8.
