Business data acquisition method, equipment and medium
By designing a public query interface and a configuration interface in the ERP system, decoupling the interface and business details, the generation and security check of dynamic query statements are realized, which solves the problem that the query interface in the ERP system is difficult to adapt to different business scenarios and improves data efficiency. Gain efficiency and system security.
Patent Information
- Application Number
- CN202410761593.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-06-13
AI Technical Summary
In ERP systems, a single query interface is difficult to adapt to the needs of different business scenarios, resulting in high difficulty in interface development and low efficiency in obtaining business data, and tight coupling increases expansion and maintenance costs.
Design a business data acquisition method that obtains query ID and condition data through a public query interface, generates encrypted query statements, decrypts and assembles the final query statement, conducts database queries, and ensures the security and effectiveness of the query statements through configured interfaces and security checks. to reduce the coupling between interfaces and business details.
It implements a dynamically configured business data acquisition method, improves the scalability and maintainability of the system, reduces the difficulty of interface development, improves the efficiency of business data acquisition, and prevents potential injection attacks through SQL security checks.
Smart Images

Figure CN118673074A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device and medium for acquiring business data. Background Art
[0002] In the ERP system, the data flow between different business modules involves a large number of query operations, including data reference, business reports and rule verification. Therefore, the business data within the ERP system is huge and complex, involving multiple modules and business processes.
[0003] At present, due to the different requirements in different business scenarios, the business tables and fields involved in the query are also different. The design of a single query interface is often difficult to adapt to the needs of different business scenarios. That is, although the query interface preset by the standard product has a certain degree of versatility, it is often difficult to meet the personalized needs of the project. With the continuous improvement of the information system, the increase of business modules and the change of requirements, new query interfaces are constantly generated. These query interfaces are often tightly coupled with the product details of the ERP system. This means that once the product details change, the relevant query interface also needs to be adjusted accordingly. This tight coupling not only increases the difficulty of interface development, but also increases the cost of subsequent expansion and maintenance, and reduces the efficiency of business data acquisition. Summary of the invention
[0004] The embodiments of the present application provide a business data acquisition method, device and medium, which are used to solve the problems of high difficulty in interface development and low efficiency in business data acquisition.
[0005] The present application embodiment adopts the following technical solutions:
[0006] On the one hand, an embodiment of the present application provides a business data acquisition method, the method comprising: in a set public query interface, obtaining query ID data and query condition data passed in by the caller; in an information table database, according to the query ID data, retrieving the query information table corresponding to the query ID data; querying the query information table to obtain an encrypted query statement; decrypting the encrypted query statement to restore the original query statement; assembling the original query statement with the query condition data to obtain a final query statement; creating a database connection, and querying the database based on the final query statement to obtain the business data queried by the caller.
[0007] In one example, in the set public query interface, before obtaining the query ID data and query condition data passed in by the caller, the method also includes: receiving a query statement uploaded by the client; generating ID data of a unique primary key, and encrypting the query statement to obtain an encrypted query statement; calling a query information table template, the fields of the query information table template including ID, query content and query event name; the ID is the unique primary key of the query information table, the query content is used to represent the encrypted query statement, and the query event name is used to represent the content description of the query statement; according to the ID data and the encrypted query data, the query information table template is filled to generate a query information table corresponding to the query statement, and the query information table is output to the information table database.
[0008] In one example, after outputting the query information table to the information table database, the method further includes: receiving an update statement request from the client; the update statement request includes the ID data and an update query statement; based on the ID data, retrieving the query information table in the information table database; replacing the query statement in the query content field with the update query statement, and updating the field data of the query event name.
[0009] In one example, after receiving the query statement uploaded by the client, the method also includes: verifying the configuration authority of the client; when the client has the configuration authority, performing a security check on the query statement to verify the security of the query statement; when the security verification fails, providing feedback to the client that the query statement has risks, so as to receive the query statement re-uploaded by the client.
[0010] In one example, the fields of the query information table template also include whether they are preset by the system; when the ID, query content and query event name are preset by the system, the fields of the ID, query content and query event name are restricted from being deleted.
[0011] In one example, after obtaining the query ID data and query condition data passed in by the caller, the method also includes: performing a SQL injection attack protection check on the query ID data and the query condition data to determine that there is no attack behavior; performing a format check on the query ID data and the query condition data to determine that the interface input complies with parameter rules.
[0012] In one example, after assembling the original query statement with the query condition data to obtain the final query statement, the method further includes: verifying the query authority of the client; when the client has query authority, performing a SQL injection attack protection check on the final query statement to determine that there is no attack behavior in the final query statement; and performing a format check on the final query statement to determine that the final query statement is a valid query.
[0013] In one example, after querying the database based on the final query statement to obtain the business data queried by the caller, the method also includes: converting the format of the business data to obtain business data in JSON format; passing the business data to the caller; within a preset time interval, determining whether to receive feedback information from the caller; if so, determining that the business data is successfully passed based on the feedback information; if not, re-passing the business data to the caller.
[0014] On the other hand, an embodiment of the present application provides a business data acquisition device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a business data acquisition method described in any one of the above items.
[0015] On the other hand, an embodiment of the present application provides a non-volatile computer storage medium for acquiring business data, which stores computer executable instructions, and the computer executable instructions can execute any of the business data acquisition methods described above.
[0016] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:
[0017] Based on the dynamically configurable business data acquisition method, it is possible to handle the diverse business scenario requirements in the ERP system by designing a unified and highly flexible public query interface. The core is to reduce the coupling between product implementation details and interfaces, thereby improving the scalability and maintainability of the system. Based on this, a configurable interface is provided to allow users to freely organize query statements according to actual business needs, so that users can customize query logic according to their own needs without making code-level modifications to the system. The system will generate a unique primary key for the customized query statement, which will be used as an input parameter of the public query interface to identify and call specific query logic, that is, call the query statement to build a query information table, and pre-customize the query statement. When the number of query fields in the query statement is large, the system performance will not be seriously affected and the query speed will not be reduced. In addition, encrypted query statements are stored in the query information table, which can protect the security of the query statement. In this way, business needs and interface content are effectively decoupled, making the interface more general and flexible. There is no need for each business need to correspond to an interface. When business modules are added and needs are changed, there is no need to generate new query interfaces, which reduces the difficulty of interface development and ultimately improves the efficiency of business data acquisition.
[0018] At the same time, in order to ensure the security of the system, all custom query statements will undergo strict SQL security checks to prevent potential injection attacks. After the security check, a unique primary key for the query statement will be generated. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solution of the present application, some embodiments of the present application will be described in detail below in conjunction with the accompanying drawings, in which:
[0020] Figure 1 A flowchart of a method for acquiring business data provided in an embodiment of the present application;
[0021] Figure 2 A flowchart of another method for acquiring business data provided in an embodiment of the present application;
[0022] Figure 3 A schematic diagram of the structure of a business data acquisition device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0024] Some embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0025] Figure 1 A flowchart of a business data acquisition method provided in an embodiment of the present application. The method can be applied to different business fields, such as Internet financial business field, e-commerce business field, instant messaging business field, game business field, official business field, etc. Certain input parameters or intermediate results in the process allow manual intervention and adjustment to help improve accuracy.
[0026] The analysis method involved in the embodiments of the present application can be implemented by a terminal device or a server, and the present application does not impose any special restrictions on this. For the convenience of understanding and description, the following embodiments are described in detail by taking a server as an example.
[0027] It should be noted that the server may be a single device or a system consisting of multiple devices, that is, a distributed server, and this application does not make any specific limitation on this.
[0028] Figure 1 The process in includes the following steps:
[0029] S101: In a set public query interface, obtain query ID data and query condition data passed in by the caller.
[0030] It should be noted that the public query interface has two parameters, the unique primary key ID and the query condition Filter. The field type of the unique primary key is String. The query condition can be dynamically configured according to the query SQL and business information. For example, the query condition is to query the business report data of Company A.
[0031] In some embodiments of the present application, it is necessary to pre-build an information table database, and the construction process is as follows:
[0032] First, receive the query statement uploaded by the client. Then, generate an ID data of a unique primary key, and encrypt the query statement to obtain an encrypted query statement. Then, call the query information table template, and the fields of the query information table template include ID, query content, and query event name. Among them, ID is the unique primary key of the query information table, the query content is used to represent the encrypted query statement, and the query event name is used to represent the content description of the query statement. Finally, fill in the query information table template according to the ID data and the encrypted query data, generate the query information table corresponding to the query statement, and output the query information table to the information table database.
[0033] It should be noted that the method for encrypting the query statement can be set according to actual needs, for example, using Base64 encryption.
[0034] More intuitively, the data structure of the query information table template is shown in Table 1:
[0035] Table 1:
[0036]
[0037] It should be noted that when ID, query content and query event name are system preset fields, deletion of the fields of ID, query content and query event name is restricted.
[0038] It should be noted that by building an information table database, the system presets multiple sets of standard query statements, which are designed based on common business scenarios and query requirements and can be directly referenced and used by the caller. The caller only needs to find the appropriate encrypted query statement from the information table database to quickly implement the corresponding query function without having to write complex SQL statements from scratch. When the existing query cannot meet the actual needs of the user, the user can freely organize the query statement according to the actual business needs.
[0039] In some embodiments of the present application, a security check is performed on the query statements to be preset to prevent security issues caused by attacks such as SQL injection, such as injection attacks, SQL syntax checks, data integrity checks, etc.
[0040] Based on this, first, the client is verified for configuration permissions. Then, if the client has configuration permissions, a security check is performed on the query statement to verify the security of the query statement. Finally, if the security verification fails, feedback is given to the client that the query statement has risks, so as to receive the query statement re-uploaded by the client.
[0041] It should be noted that when the client does not have the configuration authority, feedback indicating that the client does not have the configuration authority is given.
[0042] In some embodiments of the present application, when the business logic changes, the existing query information can be modified without rewriting the query statement or modifying the system code, thereby realizing a rapid change of the query logic.
[0043] Specifically, an update statement request from a client is received, wherein the update statement request includes ID data and an update query statement.
[0044] Then, according to the ID data, the query information table is retrieved in the information table database. Finally, the query statement in the query content field is replaced with an update query statement, and the field data of the query event name is updated.
[0045] It should be noted that the information table database supports deleting obsolete query information. The delete function can be used to remove unused query statements from the system to avoid the accumulation of redundant data and affect system performance. In addition, an export function is provided to export the written query information to a data file to achieve the backup, migration and reuse of query information, thus improving the portability of the query.
[0046] That is, the configurable interface may include five functions: adding, modifying, editing, deleting, querying, and exporting.
[0047] S102: In an information table database, according to the query ID data, searching for a query information table corresponding to the query ID data.
[0048] In some embodiments of the present application, the query ID data and the query condition data are checked for SQL injection attack protection to determine if there is no attack behavior, and the query ID data and the query condition data are checked for format to determine if the interface input complies with the parameter rules.
[0049] It should be noted that if there is an attack or the parameter rules are not met, it is not allowed to search in the information table database to obtain updated query ID data and query condition data from the caller.
[0050] S103: query the query information table to obtain an encrypted query statement.
[0051] It should be noted that a query information table usually has a query encryption query statement.
[0052] S104: Decrypt the encrypted query statement to restore the original query statement.
[0053] It should be noted that since storing plain text SQL may pose a security risk, Base64 encryption can be used to protect the security of query statements. After obtaining the encrypted SQL, the encrypted SQL is decrypted by Base64 to restore the original query SQL.
[0054] S105: Assemble the original query statement with the query condition data to obtain a final query statement.
[0055] That is to say, the decrypted query SQL needs to be assembled with the parameter Filter to form the final query statement. The Filter parameter usually contains user-defined filter conditions, which can be dynamically set according to actual needs to achieve more accurate query results. By combining the decrypted SQL with the Filter, the system can construct a final query statement that meets user needs and has passed security verification.
[0056] The security verification process is as follows: First, verify the query permission of the client. Then, if the client has the query permission, perform a SQL injection attack protection check on the final query statement to determine that there is no attack behavior in the final query statement. Finally, perform a format check on the final query statement to determine that the final query statement is a valid query.
[0057] That is, after assembling the query statement, the system will perform a secondary check to ensure the correctness and legality of the statement and prevent security issues caused by attacks such as SQL injection.
[0058] S106: Create a database connection, query the database based on the final query statement, and obtain the business data queried by the caller.
[0059] In some embodiments of the present application, after the final query statement passes verification, a database connection is created for querying. The query results are returned to the caller in the form of JSON. JSON is a lightweight data exchange format. By converting the query results into JSON format, the system can easily pass the data to the caller to achieve data sharing and exchange.
[0060] Specifically, first, the business data is converted into a format to obtain business data in JSON format. Then, the business data is delivered to the caller. Then, within a preset time interval, it is determined whether the caller's acquisition feedback information is received. If so, it is determined based on the acquisition feedback information that the business data is successfully delivered. If not, the business data is delivered to the caller again.
[0061] That is to say, the whole process is to query the query information table according to the passed parameters, decrypt the query SQL, assemble the final query statement, double-check the correctness and legality of the statement, create a database connection for query, and return the query results to the caller in JSON format. This process not only improves the flexibility and security of the query, but also provides users with convenient and efficient data query services.
[0062] More intuitively, Figure 2 A flowchart of another method for acquiring business data provided in an embodiment of the present application.
[0063] exist Figure 2 In the query statement, design the query statement and perform SQL security check on the query statement. If it passes, save the query statement and generate the primary key. If it fails, redesign the query statement and edit and modify the saved query statement.
[0064] Furthermore, through the unified query entry (public query interface), the query ID data and query condition data are obtained, and then SQL assembly is performed (the original query statement and the query condition data are assembled). Then, the assembled query statement is checked twice. After the check is passed, the database query is performed based on the query processing logic to return the query results.
[0065] It should be noted that although the embodiments of the present application are based on Figure 1 Steps S101 to S106 are described in sequence, but this does not mean that steps S101 to S106 must be performed in a strict order. Figure 1 The order shown in the figure is to introduce and explain step S101 to step S106 in sequence, in order to facilitate those skilled in the art to understand the technical solution of the embodiment of the present application. In other words, in the embodiment of the present application, the order between step S101 to step S106 can be appropriately adjusted according to actual needs.
[0066] pass Figure 1The method can handle the diverse business scenario requirements in the ERP system by designing a unified and highly flexible public query interface. The core lies in reducing the coupling between product implementation details and interfaces, thereby improving the scalability and maintainability of the system. Based on this, a configurable interface is provided to allow users to freely organize query statements according to actual business needs, so that users can customize query logic according to their own needs without making code-level modifications to the system. The system will generate a unique primary key for the customized query statement, which will be used as an input parameter of the public query interface to identify and call specific query logic, that is, call the query statement to build a query information table, and the query information table stores encrypted query statements, which can protect the security of the query statements. In this way, business requirements and interface content are effectively decoupled, making the interface more general and flexible. There is no need for each business requirement to correspond to an interface. When business modules are added and requirements are changed, there is no need to generate new query interfaces, which reduces the difficulty of interface development and ultimately improves the efficiency of business data acquisition.
[0067] At the same time, in order to ensure the security of the system, all custom query statements will undergo strict SQL security checks to prevent potential injection attacks. After the security check, a unique primary key for the query statement will be generated.
[0068] Based on the same idea, some embodiments of the present application also provide devices and non-volatile computer storage media corresponding to the above methods.
[0069] Figure 3 A schematic diagram of the structure of a business data acquisition device provided in an embodiment of the present application, the device includes:
[0070] at least one processor; and,
[0071] a memory communicatively connected to the at least one processor; wherein,
[0072] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any one of the business data acquisition methods described above.
[0073] Some embodiments of the present application provide a non-volatile computer storage medium for acquiring business data, which stores computer-executable instructions, and the computer-executable instructions can execute any of the business data acquisition methods described above.
[0074] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0075] The devices and media provided in the embodiments of the present application correspond one-to-one to the methods. Therefore, the devices and media also have similar beneficial technical effects as the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be repeated here.
[0076] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0077] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks 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.
[0078] 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.
[0079] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing 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.
[0080] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0081] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0082] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0083] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0084] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the technical principle of the present application should all fall within the protection scope of the present application.
Claims
1. A method for acquiring business data, characterized in that: The method comprises: In the set public query interface, obtain the query ID data and query condition data passed in by the caller; In the information table database, according to the query ID data, searching the query information table corresponding to the query ID data; Querying the query information table to obtain an encrypted query statement; Decrypting the encrypted query statement to restore the original query statement; Assembling the original query statement with the query condition data to obtain a final query statement; A database connection is created, and the database is queried based on the final query statement to obtain the business data queried by the caller.
2. The method according to claim 1, characterized in that Before obtaining the query ID data and query condition data passed in by the caller in the set public query interface, the method further includes: Receive query statements uploaded by the client; Generate ID data of a unique primary key, and encrypt the query statement to obtain an encrypted query statement; Calling a query information table template, wherein the fields of the query information table template include an ID, a query content, and a query event name; the ID is a unique primary key of the query information table, the query content is used to represent an encrypted query statement, and the query event name is used to represent a content description of the query statement; The query information table template is filled in according to the ID data and the encrypted query data, a query information table corresponding to the query statement is generated, and the query information table is output to the information table database.
3. The method according to claim 2, characterized in that After outputting the query information table to the information table database, the method further includes: receiving an update statement request from the client; the update statement request includes the ID data and an update query statement; According to the ID data, the query information table is retrieved in the information table database; The query statement in the query content field is replaced with the update query statement, and the field data of the query event name is updated.
4. The method according to claim 2, characterized in that After receiving the query statement uploaded by the client, the method further includes: Performing configuration authority verification on the client; When the client has configuration authority, performing a security check on the query statement to verify the security of the query statement; When the security verification fails, feedback is given to the client indicating that the query statement has risks, so as to receive the query statement re-uploaded by the client.
5. The method according to claim 2, characterized in that: The fields of the query information table template also include whether the system is preset; When the ID, query content and query event name are system preset fields, the fields of the ID, query content and query event name are restricted from being deleted.
6. The method according to claim 1, characterized in that After obtaining the query ID data and query condition data passed in by the caller, the method further includes: Performing a SQL injection attack protection check on the query ID data and the query condition data to determine if there is no attack behavior; Perform a format check on the query ID data and the query condition data to determine whether the interface input complies with parameter rules.
7. The method according to claim 1, characterized in that After assembling the original query statement with the query condition data to obtain a final query statement, the method further includes: Verify the query permissions of the client; When the client has query permission, perform a SQL injection attack protection check on the final query statement to determine that there is no attack behavior in the final query statement; A format check is performed on the final query statement to determine whether the final query statement is a valid query.
8. The method according to claim 1, characterized in that After querying the database based on the final query statement to obtain the business data queried by the caller, the method further includes: Convert the business data into a JSON format. Passing the business data to the caller; Within a preset time interval, determining whether to receive acquisition feedback information from the caller; If yes, determining that the service data is successfully transmitted based on the acquired feedback information; If not, the business data is re-delivered to the caller.
9. A business data acquisition device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a business data acquisition method as described in any one of claims 1 to 8.
10. A business data acquisition non-volatile computer storage medium storing computer executable instructions, characterized in that: The computer executable instructions can execute a business data acquisition method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Method and device for data access based on SOA (Service-Oriented Architecture)
CN102110110A
Data query method and device
CN108228916A
Business data query method, device and equipment and readable storage medium
CN109739873A
Data query method and device based on configuration information
CN110019350A
Data security protection method and device, electronic equipment and storage medium
CN114372276A
