Method and system for generating service interface based on structured data

By introducing query specification definition modules, business rule definition modules and interface compilation and loading modules into the service interface generation system, the original code of the service interface is dynamically generated, which solves the problem of inefficient service interface generation in the existing technology, and achieves a more efficient development process and better system scalability.

CN120144097APending Publication Date: 2025-06-13BEIJING INST OF TECH XINYUAN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510233206.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-28
Publication Date
2025-06-13

AI Technical Summary

Technical Problem

In the prior art, service interface generation is inefficient, which leads to developers need to repeatedly write a large amount of similar code, which increases development costs and complexity.

Method used

Provides a service interface generation method and system based on structured data, including query specification definition module, business rule definition module and interface compilation and loading module, and dynamically generates the original code of the service interface through preset Schema definition and service interface protocol to reduce manual encoding work.

Benefits of technology

It improves the efficiency of service interface generation, reduces the repetitive development work of developers, and enhances the flexibility and scalability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120144097A_ABST
    Figure CN120144097A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of service interface design, and discloses a method and system for generating a service interface based on structured data, and the method comprises the following steps: a query specification definition module for defining an SQL (Structured Query Language) language query specification; the business rule definition module is used for processing the structured data based on a preset business rule and determining intermediate data; according to a Schema language, defining field information of each field in the intermediate data, and determining a preset Schema definition; the interface compiling and loading module is used for dynamically generating an original code of a service interface based on a preset Schema definition and a preset service interface protocol; and generating a service interface instance corresponding to the service interface based on the original code. According to the method provided by the embodiment of the invention, the original code of the service interface is automatically generated by presetting the Schema definition and the service interface protocol, so that the manual coding work of developers is reduced, and the generation efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of service interface design, and particularly to a method and system for generating service interfaces based on structured data. Background Art

[0002] A service interface is an important concept in software design, which mainly describes the set of functions provided by a service provider externally and the ways to call these functions. The generation of service interfaces often involves multiple links, including data acquisition, application of business rules, formatted output, and service interface encapsulation.

[0003] However, in related technologies, there is often a problem of low efficiency in generating service interfaces due to developers having to repeatedly write a large number of similar codes during the service interface generation process. Therefore, how to reduce the repetitive development work of developers and improve the efficiency of service interface generation has become a problem to be solved. Summary of the Invention

[0004] In view of this, the present disclosure provides a method and system for generating service interfaces based on structured data to solve the problem of how to reduce the repetitive development work of developers and improve the efficiency of service interface generation.

[0005] On the one hand, the present disclosure provides a method for generating service interfaces based on structured data, which is applied to a service interface generation system. The service interface generation system includes: a query specification definition module, a business rule definition module, and an interface compilation and loading module. The method includes: the query specification definition module defines a SQL language query specification; the SQL language query specification is used to obtain structured data by using corresponding query methods in a database, a local file service, or a cloud storage respectively; the business rule definition module processes the structured data based on preset business rules to determine intermediate data; according to the Schema language, field information of each field in the intermediate data is defined to determine a preset Schema definition; the interface compilation and loading module dynamically generates the original code of the service interface based on the preset Schema definition and a preset service interface protocol; and based on the original code, a service interface instance corresponding to the service interface is generated.

[0006] On the other hand, the present disclosure also provides a service interface generation system, which includes a query specification definition module, a business rule definition module, and an interface compilation and loading module, where: The query specification definition module is used to define the SQL language query specification; the SQL language query specification is used to obtain structured data by using corresponding query methods in a database, a local file service, or a cloud storage respectively; the business rule definition module is used to process the structured data based on preset business rules to determine intermediate data; according to the Schema language, define the field information of each field in the intermediate data to determine the preset Schema definition; the interface compilation and loading module is used to dynamically generate the original code of the service interface based on the preset Schema definition and the preset service interface protocol; and generate a service interface instance corresponding to the service interface based on the original code.

[0007] On the other hand, the present disclosure also provides a computer-readable storage medium, on which computer instructions are stored, and the computer instructions are used to cause a computer to implement the above method for generating a service interface based on structured data.

[0008] On the other hand, the present disclosure also provides a computer program product, including computer instructions, and the computer instructions are used to cause a computer to execute the above method for generating a service interface based on structured data.

[0009] Through the method and system for generating a service interface based on structured data according to the above embodiments of the present disclosure, the original code of the service interface is automatically generated through the preset Schema definition and the service interface protocol, reducing the manual coding work of developers and improving the generation efficiency.

[0010] In addition, through the preset Schema definition and the preset service interface protocol, different data sources, query rules, and field structures can be adapted through simple configuration without modifying the underlying code, thereby improving the flexibility and scalability of the generation of the service interface. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the related art, the following will briefly introduce the drawings required for use in the description of the specific embodiments or the related art. Obviously, the drawings in the following description are some embodiments of the present disclosure. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0012] Figure 1a FIG. shows an exemplary schematic diagram of the architecture of a service interface generation system to which the method for generating a service interface based on structured data according to an embodiment of the present disclosure is applied;

[0013] Figure 1bIt is a schematic flowchart of a method for generating a service interface based on structured data provided by an embodiment of the present disclosure;

[0014] Figure 2 It is a schematic diagram for generating a preset Schema definition of a method for generating a service interface based on structured data provided by an embodiment of the present disclosure;

[0015] Figure 3 It shows an exemplary schematic diagram of a database query specification for a method of generating a service interface based on structured data according to an embodiment of the present disclosure;

[0016] Figure 4 It shows an exemplary schematic diagram of another architecture of a service interface generation system applied to a method for generating a service interface based on structured data according to an embodiment of the present disclosure;

[0017] Figure 5 It shows a service interface protocol schematic diagram of a method for generating a service interface based on structured data according to an embodiment of the present disclosure;

[0018] Figure 6 It shows a specific schematic diagram of an HTTP service interface for a method for generating a service interface based on structured data according to an embodiment of the present disclosure;

[0019] Figure 7 It shows a service interface generation schematic diagram of a method for generating a service interface based on structured data according to an embodiment of the present disclosure;

[0020] Figure 8 It shows a schematic flowchart of service interface example loading for a method for generating a service interface based on structured data according to an embodiment of the present disclosure;

[0021] Figure 9 It is a schematic structural diagram of a service interface generation system provided by an embodiment of the present disclosure;

[0022] Figure 10 It is another schematic structural diagram of a service interface generation system provided by an embodiment of the present disclosure. Detailed implementation manners

[0023] In modern business service interface development, service interfaces usually need to interact with structured data, which are generally stored in a database in tabular form or in a local file system or cloud storage service in the form of files. To facilitate the operation of these data, database queries usually use Structured Query Language (SQL) to extract structured data by setting query conditions (such as query tables, query columns, filtering conditions, sorting conditions, etc.). For local files or cloud storage services, developers need to integrate the API libraries of relevant programming languages, read and parse the file streams, and convert the data into structured data that can be operated by the programming languages.

[0024] In the development process of service interfaces in related technologies, several steps are usually involved: First, data is obtained. This step involves writing SQL query statements (for databases) or obtaining file data through APIs (for local files or cloud storage). Next, business rules are applied to process the obtained data, which usually includes operations such as data verification, filtering, field calculation, sorting, etc. Then, the data is formatted for output. According to the definition requirements of the service interface, the output format needs to meet standards, such as the number of digits for dates, times, amounts, percentages, etc. Finally, the formatted data is encapsulated into a service interface for external invocation.

[0025] However, there are often the following problems in the generation of service interfaces in related technologies:

[0026] 1. The code complexity is relatively high. Since the code for data query, data processing, formatted output, and interface encapsulation is often mixed together, this not only increases the redundancy of the code but also makes maintenance difficult.

[0027] 2. There is a strong coupling between each link in the interface generation process. A change in one link may affect other links, so modification and extension become more complex and dangerous.

[0028] 3. The development mode usually relies on repetitive development. Each time a new module is developed, developers need to write similar code according to the same pattern. Although only the data structure and business rules change, this repetitive labor reduces development efficiency and increases development costs.

[0029] To solve the above problems, in the method for generating service interfaces based on structured data provided in various embodiments of the present disclosure, which is applied to a service interface generation system, the service interface generation system includes: a query specification definition module, a business rule definition module, and an interface compilation and loading module. The method includes: The query specification definition module defines the SQL language query specification; the SQL language query specification is used to obtain structured data in a database, a local file service, or a cloud storage respectively by using corresponding query methods; the business rule definition module processes the structured data based on preset business rules to determine intermediate data; according to the Schema language, it defines the field information of each field in the intermediate data to determine the preset Schema definition; the interface compilation and loading module dynamically generates the original code of the service interface based on the preset Schema definition and the preset service interface protocol; based on the original code, it generates a service interface instance corresponding to the service interface.

[0030] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Apparently, the described embodiments are some, but not all, of the embodiments of the present disclosure. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present disclosure without creative efforts shall fall within the scope of protection of the present disclosure.

[0031] Please refer to Figure 1a , Figure 1a which shows an exemplary schematic diagram of the architecture of a service interface generation system to which the method for generating a service interface based on structured data according to the embodiments of the present disclosure is applied. As Figure 1a shown, the service interface generation system includes: a query specification definition module, a business rule definition module, and an interface compilation and loading module.

[0032] Here, the service interface generation system can be used to be responsible for automatically generating a service interface through the cooperation of each module according to predefined structured data and business rules.

[0033] Among them, the query specification definition module can be used to define how to obtain structured data, that is, it can formulate an SQL query specification to describe how to query data from different data sources (such as databases, local files, cloud storage).

[0034] The business rule definition module can be used to process the data according to specific business rules after obtaining the structured data to ensure that the data conforms to the preset business rules. For example, the processing can include at least one of the following: data verification, filtering, calculation, sorting, etc.

[0035] The interface compilation and loading module can be used for compilation and code instantiation to provide a service interface instance externally.

[0036] Further referring to Figure 1b , Figure 1b which is a flowchart of the method for generating a service interface based on structured data provided by the embodiments of the present disclosure. The process of this method can include the following steps:

[0037] Step S101, the query specification definition module defines an SQL language query specification.

[0038] In this embodiment, the SQL language query specification is used to obtain structured data by using corresponding query methods in a database, a local file service, or cloud storage respectively.

[0039] Here, the Structured Query Language (SQL) statements can be the standard way to operate on a database, enabling data access and management in the database. For example, SQL statements can include, but are not limited to: query statements (SELECT), insert data (INSERT INTO), update data (UPDATE), delete data (DELETE), etc.

[0040] In a possible implementation, the query specification definition module defines the SQL language query specification, which can include:

[0041] Determine the specific content of the SQL statement and the query method for different data source types.

[0042] As an example, the specific content of the SQL statement can include: the data source type to be queried, target fields, filtering conditions, sorting conditions, etc.

[0043] Step S102, the business rule definition module processes the structured data based on preset business rules to determine intermediate data; according to the Schema language, defines the field information of each field in the intermediate data to determine the preset Schema definition.

[0044] In this embodiment, the preset business rules can refer to the rules defined in advance for processing structured data during the system design phase; the preset business rules can be used to process the data after the system obtains the data to ensure that the data meets specific business requirements.

[0045] In a possible implementation, the rules in the preset business rules can include, but are not limited to: data verification rules, field type rules, format conversion rules, data filtering and sorting rules.

[0046] Furthermore, the preset business rules can be written by developers using the corresponding programming language in the system environment.

[0047] For example, define a filtering rule in the form of JavaScript Object Notation (JSON). The rule requires returning data where the age is greater than 30 years old. The filtering rule is as follows:

[0048] {

[0049] "filter":{

[0050] "age":">30"

[0051] }

[0052] }

[0053] Further, after determining the preset business rules, based on the preset business rules, apply the preset business rules to each row of structured data one by one to determine the processed intermediate data. Here, the intermediate data can be structured data processed by the preset business rules.

[0054] For each field in the intermediate data, use the Schema language to define the data structure and field information of the field, correspond each field in the intermediate data to the fields in the Schema definition, determine the field information of each field, and generate a preset Schema definition.

[0055] Here, the Schema language refers to a language that uses a standardized way to describe and define data structures, which can be used to describe the attributes, types, constraint conditions, etc. of each field in the data model to ensure the validity and consistency of the data.

[0056] As an example, please refer to Figure 2 , Figure 2 is a schematic diagram for generating a preset Schema definition of the method for generating a service interface based on structured data provided by an embodiment of the present disclosure. Among them, apply the business rules (i.e., the preset business rules) to the original fields 1-5 in the queried structured data (i.e., the structured data) to determine the output fields 1-4 in the output data structure (i.e., the intermediate data); use the Schema language to define the data structure and field information of the output fields 1-4, and generate a preset Schema definition. Among them, classify the type of the output field 1 into the predefined string type, classify the output field 2 into the numerical type, classify the output field 3 into the date type, and classify the output field 4 into the time type.

[0057] Step S103, the interface compilation and loading module dynamically generates the original code of the service interface based on the preset Schema definition and the preset service interface protocol; based on the original code, generate a service interface instance corresponding to the service interface.

[0058] In this embodiment, the preset service interface protocol may refer to a standard predefined in the system design stage to describe information such as the behavior, communication format, input and output parameters, etc. of the service interface.

[0059] Here, the process of defining the preset service interface protocol may include: defining the protocol name, protocol version, protocol address, input parameters, output parameters, etc. in the service interface protocol.

[0060] Further, the original code dynamically generated based on the preset Schema definition and the preset service interface protocol may include the class structure of the service interface, the processing code of the input and output parameters, the interface call conforming to the service protocol, etc.

[0061] As an example, the original code of the service interface is generated using dynamic code generation technology; and the service interface instance corresponding to the service interface is generated using dynamic code compilation and loading technology. For example, the dynamic code generation technology can be JavaPoet, and the dynamic code compilation and loading technology can be Java-Runtime-Compiler.

[0062] Here, by using dynamic code generation technology to simulate the coding process of developers and using dynamic code compilation and loading technology to simulate the compilation and loading process of developers, the repetitive coding work of developers can be reduced.

[0063] In the method and system for generating a service interface based on structured data according to the above embodiments of the present disclosure, by modularizing the steps of query specification, business rules, formatted output, and interface encapsulation, code redundancy is reduced, and the maintainability of the code is enhanced. Each module is defined and processed independently, reducing the mutual dependence between links, making modification and extension easier, and reducing the impact of modification on other modules. By dynamically generating code and compiling and loading, the repetitive development work of developers is reduced, thereby improving development efficiency and reducing development costs. By presetting business rules and Schema definitions, the system can flexibly process data and generate service interfaces according to different requirements, enhancing the adaptability and scalability of the system.

[0064] In a possible implementation manner of the above step S101, the query specification definition module defines the SQL language query specification, including:

[0065] The query specification definition module constructs an SQL statement using the SELECT syntax of SQL based on the data source type to be queried and the target field; wherein, the data source type includes: database, local file service, and cloud storage;

[0066] The query specification definition module defines an SQL query interface, and defines the database query specification, local file service query specification, and cloud storage query specification during the execution of the SQL statement by the SQL query interface.

[0067] In this embodiment, the query specification definition module constructs an SQL statement using the SELECT syntax of SQL based on the data source type to be queried and the target field, which may include:

[0068] The query specification definition module determines that the data source type to be queried includes a database, a local file service, and cloud storage, and determines the data query method corresponding to each data source type;

[0069] The query specification definition module defines the target fields to be queried based on the user's requirements. For data sources of the database type, the SQL SELECT syntax is used to construct SQL statements.

[0070] Here, the target fields to be queried can be columns in a database table, data columns in a local file, or data fields in cloud storage.

[0071] Furthermore, the query specification definition module defines and creates an SQL query interface, which encapsulates the function of executing SQL statements.

[0072] As an example, a partial code snippet of the SQL query interface SqlExecutor defined in the Java language can be as follows:

[0073] public interface SqlExecutor{

[0074] Map<String,Object> execute(String sql) throws SQLException;

[0075] }

[0076] Among them, SqlExecutor, as an interface, defines the specification for SQL execution. Through the design of the interface, different implementation classes can follow the same operation specification, that is, classes using this interface must implement the execute method.

[0077] Even further, the database query specification can be used to specify how to query data in the database through SQL statements; the local file service query specification can be used to specify how to obtain structured data from the local file system; the cloud storage query specification can be used to specify how to query structured data in the storage service in the cloud environment.

[0078] In the method and system for generating a service interface based on structured data in the above embodiments of the present disclosure, by defining a unified SQL query specification, the operation process of querying data in different data sources can be simplified. Various data sources can access data through a standardized interface, avoiding differences in query methods between different data sources and improving development efficiency. In addition, defining a unified interface and query specification enables the reuse of query implementations for different data sources, enabling developers to write corresponding query codes for different data sources by implementing this interface, rather than rewriting different query logics for each data source, reducing repetitive development work and simplifying the development process.

[0079] In a possible implementation of the above embodiment, the query specification definition module defines the database query specification and is implemented based on the following steps: constructing a database connection instance based on the database driver and executing SQL statements using the database connection instance;

[0080] The query specification definition module defines the local file service query specification and is implemented based on the following steps: parsing the SQL statement to obtain the table name in the SQL statement; establishing a mapping relationship between the table name and the file name of the local file service, reading the target file based on the mapping relationship, and executing the SQL statement to extract the target fields;

[0081] The query specification definition module defines the cloud storage query specification and is implemented based on the following steps: the cloud storage query specification includes: parsing the SQL statement and obtaining the table name, constructing an API query request based on the table name, and using the API query request to extract the target fields.

[0082] In this embodiment, constructing a database connection instance based on the database driver and executing SQL statements using the database connection instance may include the following steps:

[0083] Loading the database driver during system runtime, constructing a database connection instance through the database URL, username, and password, and using the database connection instance for SQL queries.

[0084] Among them, as an example, the database driver can be automatically loaded through DriverManager; the connection can be established by using the DriverManager.getConnection() method and passing in the database URL, username, and password.

[0085] In a possible implementation, establishing a mapping relationship between the table name and the file name of the local file service may include:

[0086] Defining a preset mapping relationship through a preset configuration file or database table for mapping the table name in the SQL query statement to the file path where the actual stored data is located.

[0087] For example, the file path corresponding to the table name "users" can be "data / user.csv", and the preset mapping relationship can be stored using Map.

[0088] Furthermore, reading the target file based on the mapping relationship and executing the SQL statement to extract the target fields may include:

[0089] Based on the specified table name in the SQL statement, finding the corresponding file path according to the above preset mapping relationship, and determining the target file storing the data of the table based on the file path;

[0090] After finding the target file, the data in the target file can be parsed line by line according to the SELECT fields in the SQL statement to extract the target fields.

[0091] Further, parsing the SQL statement and obtaining the table name, constructing an API query request based on the table name, and using the API query request to extract the target fields may include:

[0092] Extract the table name to be queried in the SQL statement, use the API provided by the cloud storage to construct an API query request, execute the API query request, and obtain the data stored in the cloud storage, that is, the target fields.

[0093] As an example, please refer to Figure 3 , Figure 3 which shows an exemplary schematic diagram of the database query specification for generating a service interface party based on structured data according to an embodiment of the present disclosure.

[0094] As Figure 3 shown, the database query specification can be used for databases, local file services, and cloud storage. Among them, it is possible to interact with the database through Java Database Connectivity (JDBC) to execute the query corresponding to the SQL statement; it is also possible to interact with the local file service through a local file adaptor, convert the SQL query into a file operation through the local file API, obtain the data, and execute the query corresponding to the SQL statement; it is also possible to interact with the cloud storage service through a cloud storage adaptor, convert the SQL query into a cloud storage API request, and execute the query corresponding to the SQL statement.

[0095] In the method and system for generating a service interface based on structured data according to the above embodiments of the present disclosure, through a unified query specification, the database, local file service, and cloud storage can execute query operations through the same interface. Different data sources can follow the same SQL query syntax and structure, thereby improving the consistency and unity of query operations and reducing the repetitive work of developers. By using JDBC adaptors, local file adaptors, and cloud storage adaptors, different data sources are decoupled from the query specification. Through these adaptors, various data sources can adapt to the SQL query specification, reducing the operation differences between different data sources, making the operation of data sources more flexible and extensible, and further reducing the difficulty of development and maintenance.

[0096] In a possible implementation manner of the above step embodiments, further referring to Figure 4 , Figure 4An exemplary diagram showing another architecture of the service interface generation system to which the method for generating a service interface based on structured data according to an embodiment of the present disclosure is applied. As Figure 4 shown, the service interface generation system further includes: an interface protocol definition module, and the method further includes:

[0097] The interface protocol definition module defines a service interface protocol based on a preset Schema definition. The service interface protocol includes at least one of the following: protocol name, protocol version, protocol address, input parameter list, and output parameter list;

[0098] The interface protocol definition module selects the field information of at least one field in the preset Schema definition to participate in filtering and sets the filtering conditions of the service interface;

[0099] The interface protocol definition module selects the field information of at least one field in the preset Schema definition as an output parameter and sets the output fields of the service interface.

[0100] In this embodiment, referring to Figure 5 , Figure 5 shows a schematic diagram of the service interface protocol of the method for generating a service interface based on structured data according to an embodiment of the present disclosure. As Figure 5 shown, the service interface protocol may include a protocol name, a protocol version, a protocol address, an input parameter list, and an output parameter list.

[0101] Among them, the protocol name may be the unique identifier of the service interface protocol and can be used to distinguish different interface protocols. For example, UserService may represent an interface protocol related to user services.

[0102] The protocol version can specify the version number of the service interface to ensure that the old version of the system can still work properly when the interface changes, and at the same time enable developers to control the compatibility between different versions.

[0103] The protocol address may be the access uniform resource locator (URL) or terminal address of the service interface and is used to identify how to access the service interface.

[0104] The input parameter list can define the parameters that the client needs to provide when the service interface is called; while the output parameter list can define the data returned by the service interface after processing the request.

[0105] Further, please refer to Figure 6 , Figure 6 shows a specific schematic diagram of the HTTP service interface of the method for generating a service interface based on structured data according to an embodiment of the present disclosure. As Figure 6 shown, where:

[0106] The protocol name is http, indicating that the service interface communicates via the HyperText Transfer Protocol (HTTP), and the HTTP version is 1.1. The protocol address (https: / / www...) represents the access URL address of the service interface, and the client will access the service interface through this address. Content-Type (Content-Type: application / json) is used to indicate the content type of the request and response data expected by the service interface. Among them, application / json indicates that the service interface uses the JSON format to transmit data. The query string (?q1=${q1}&q2=${q2}) represents the input parameters included in the query string. Among them, q1 and q2 refer to the query parameters, and q1=${q1} and q2=${q2} represent the dynamic replacement of the query parameters. ${q1} and ${q2} can be placeholders.

[0107] The output parameter list may include traceId, timestamp, and data, and data contains user information (i.e., username, org, role) and a validity field (i.e., valid).

[0108] Furthermore, please refer to Figure 7 , Figure 7 shows a service interface generation schematic diagram of the method for generating a service interface based on structured data according to an embodiment of the present disclosure. As Figure 7 shown, where:

[0109] The interface protocol definition module selects the field information of at least one field in the preset Schema definition to participate in filtering and sets the filtering conditions of the service interface, which may include:

[0110] The interface protocol definition module selects field col1 and field col2 in the preset Schema definition to participate in filtering, and sets the filtering conditions of the service interface as "col1 = input parameter 1" and "col2 = f1(input parameter 2)".

[0111] The interface protocol definition module selects the field information of at least one field in the preset Schema definition as output parameters and sets the output fields of the service interface, which may include:

[0112] The interface protocol definition module selects col1, col3, and col4 in the preset Schema definition to construct the output fields. The output fields may include o1 = col1 + f2(col3) and o2 = col4.

[0113] In the method and system for generating service interfaces based on structured data according to the above embodiments of the present disclosure, through the interface protocol definition module, the system can clearly define all aspects of the service interface protocol. The standardized definition ensures the unity of the service interface, making the interaction between different modules and systems more standardized and consistent. In the interface protocol definition module, selecting field information for filtering and output field configuration can provide a flexible service interface design. By selecting specific fields for filtering and constructing output fields, interfaces that meet different requirements can be dynamically generated, enhancing the customization ability of the interfaces and ensuring that the system can be flexibly adjusted according to different query conditions and data requirements.

[0114] In a possible implementation manner of the above step S103, the interface compilation and loading module dynamically generates the original code of the service interface based on the preset Schema definition and the preset service interface protocol; based on the original code, a service interface instance corresponding to the service interface is generated, which is implemented based on the following steps:

[0115] The interface compilation and loading module dynamically generates the original code of the service interface based on the preset Schema definition, the service interface protocol, and the filtering conditions;

[0116] The interface compilation and loading module calls a programming language editor to compile the original code into target code, and loads the target code and instantiates the service interface during system operation to generate a service interface instance corresponding to the service interface.

[0117] In this embodiment, the interface compilation and loading module uses a dynamic code generation toolkit to dynamically generate the original code of the service interface based on the preset Schema definition, the service interface protocol, and the filtering conditions;

[0118] The interface compilation and loading module uses a code compilation toolkit to compile the original code into executable code; and uses a code loading technology to load the service interface instance corresponding to the service interface.

[0119] Here, the business rules for code generation and loading are abstracted, and the dynamic code generation technology is used to simulate the process of developers' coding to generate the original code for implementing specific functions; after generating the original code, tools of a specific programming language are needed to compile the original code, and finally target code is generated to be referenced and executed during system operation; finally, the code loading technology is used to create a specific service interface instance according to the generated target code during system operation.

[0120] As an example, please refer to Figure 8 , Figure 8 which shows the schematic flow diagram of the service interface example loading of the method for generating service interfaces based on structured data according to the embodiments of the present disclosure. As Figure 8 shown, wherein:

[0121] After generating the preset Schema definition, service interface protocol, and filtering conditions, a dynamic code generation toolkit is used to generate the original code; a code compilation toolkit is used to generate the executable code; and a code loading technology is used to generate service interface instances. Figure 7 After generating the preset Schema definition, service interface protocol, and filtering conditions, a dynamic code generation toolkit is used to generate the original code; a code compilation toolkit is used to generate the executable code; and a code loading technology is used to generate service interface instances.

[0122] In the method and system for generating a service interface based on structured data according to the above embodiments of the present disclosure, through the abstracted service interface rules, a dynamic code generation toolkit, a code compilation toolkit, and a dynamic loading technology are used to generate the original code file, executable code, and the final runtime instance, replacing all the development work of developers after business rule processing, enabling developers to focus on business function development, improving the efficiency of business function development, and reducing labor costs.

[0123] In one embodiment, a service interface generation system 900 is provided, and the service interface generation system 900 corresponds one-to-one with the method for generating a service interface based on structured data in the above embodiments. As Figure 9 shown, the system includes a query specification definition module 901, a business rule definition module 902, and an interface compilation and loading module 903. Among them, the detailed descriptions of each functional module are as follows:

[0124] The query specification definition module 901 is used to define the SQL language query specification; the SQL language query specification is used to obtain structured data by using corresponding query methods in a database, a local file service, or a cloud storage respectively;

[0125] The business rule definition module 902 is used to process the structured data based on preset business rules to determine intermediate data; according to the Schema language, define the field information of each field in the intermediate data to determine the preset Schema definition;

[0126] The interface compilation and loading module 903 is used to dynamically generate the original code of the service interface based on the preset Schema definition and the preset service interface protocol; and generate a service interface instance corresponding to the service interface based on the original code.

[0127] In one embodiment, the query specification definition module 901 is used to construct an SQL statement by using the SELECT syntax of SQL based on the data source type to be queried and the target field; wherein, the data source type includes: database, local file service, and cloud storage;

[0128] The query specification definition module 901 is used to define an SQL query interface, and define the database query specification, local file service query specification, and cloud storage query specification in the process of executing the SQL statement of the SQL query interface.

[0129] In one embodiment, a query specification definition module 901 is configured to define a local file service query specification, which is implemented based on the following steps: parsing an SQL statement to obtain the table name in the SQL statement; establishing a mapping relationship between the table name and the file name of the local file service, reading a target file based on the mapping relationship, and executing the SQL statement to extract target fields;

[0130] The query specification definition module 901 is configured to define a cloud storage query specification, which is implemented based on the following steps: The cloud storage query specification includes: parsing an SQL statement and obtaining the table name, constructing an API query request based on the table name, and using the API query request to extract target fields.

[0131] In one embodiment, the service interface generation system 900 further includes an interface protocol definition module 904, wherein:

[0132] The interface protocol definition module 904 is configured to define a service interface protocol based on a preset Schema definition. The service interface protocol includes at least one of the following: protocol name, protocol version, protocol address, input parameter list, and output parameter list;

[0133] The interface protocol definition module 904 is configured to select field information of at least one field in the preset Schema definition to participate in filtering, and set a filtering condition for the service interface;

[0134] The interface protocol definition module 904 is configured to select field information of at least one field in the preset Schema definition as an output parameter, and set an output field for the service interface.

[0135] In one embodiment, an interface compilation and loading module 903 is configured to dynamically generate original code of the service interface based on the preset Schema definition, service interface protocol, and filtering condition;

[0136] The interface compilation and loading module 903 is configured to call a programming language editor to compile the original code into target code, load the target code and instantiate the service interface during system operation, so as to generate a service interface instance corresponding to the service interface.

[0137] It should be noted that: when the service interface generation system provided in the above embodiment implements the corresponding method for generating a service interface based on structured data, only the division of the above program modules is used for illustration. In practical applications, the above processing can be allocated to different program modules according to needs, that is, the internal structure of the above system is divided into different program modules to complete all or part of the above-described processing. In addition, the system provided in the above embodiment and the corresponding Figure 1b embodiment of the method shown belong to the same concept, and the specific implementation process can be seen in the method embodiment, which will not be elaborated here.

[0138] The embodiments of the present disclosure further provide a computer device having the above-mentioned Figure 9 service interface generation system shown.

[0139] Please refer to Figure 10 , Figure 10 which is another structural schematic diagram of the service interface generation system provided by the embodiments of the present disclosure. As shown in Figure 10 , the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including a high-speed interface and a low-speed interface. Each component communicates with each other using different buses and can be installed on a common motherboard or installed in other ways as needed. The processor can process instructions executed within the computer device, including instructions stored in the memory or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some alternative embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a set of blade servers, or a multi-processor system). Figure 10 In

[0140] , a single processor 10 is taken as an example.

[0141] The processor 10 can be a central processing unit, a network processor, or a combination thereof. Among them, the processor 10 can further include a hardware chip. The above-mentioned hardware chip can be an application-specific integrated circuit, a programmable logic device, or a combination thereof. The above-mentioned programmable logic device can be a complex programmable logic device, a field programmable gate array, a general array logic, or any combination thereof.

[0141] Among them, the memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiments.

[0142] The memory 20 can include a program storage area and a data storage area. Among them, the program storage area can store an operating system and application programs required for at least one function; the data storage area can store data created according to the use of the computer device, etc. In addition, the memory 20 can include a high-speed random access memory and can also include a non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state storage devices. In some alternative embodiments, the memory 20 can optionally include a memory remotely set relative to the processor 10, and these remote memories can be connected to the computer device through a network. Examples of the above-mentioned network include but are not limited to the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.

[0143] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid state drive; the memory 20 may further include a combination of the above types of memory.

[0144] The computer device further includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected through a bus or other means. Figure 10 Taking connection through the bus as an example.

[0145] The input device 30 can receive input digital or character information, and generate key signal inputs related to the user settings and function controls of the computer device, such as touch screen, keypad, mouse, trackpad, touchpad, pointing stick, one or more mouse buttons, trackball, joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (such as an LED), and a haptic feedback device (such as a vibration motor), etc. The above display device includes but is not limited to liquid crystal display, light emitting diode, display and plasma display. In some alternative embodiments, the display device may be a touch screen.

[0146] The computer device further includes a communication interface for the computer device to communicate with other devices or communication networks.

[0147] The embodiments of the present disclosure also provide a computer-readable storage medium. The methods according to the embodiments of the present disclosure can be implemented in hardware, firmware, or be implemented as computer code that can be recorded on a storage medium, or be implemented as computer code originally stored in a remote storage medium or a non-transitory machine-readable storage medium and downloaded through a network and will be stored in a local storage medium, so that the methods described herein can be stored in such software processes on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk or a solid state drive, etc.; further, the storage medium may further include a combination of the above types of memory. It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component that can store or receive software or computer code, and when the software or computer code is accessed and executed by the computer, the processor or the hardware, the methods shown in the above embodiments are implemented.

[0148] A part of the present disclosure can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to the present disclosure through the operations of the computer. Those skilled in the art should understand that the forms in which computer program instructions exist in a computer-readable medium include but are not limited to source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include but are not limited to: the computer directly executes the instructions, or the computer compiles the instructions and then executes the corresponding compiled program, or the computer reads and executes the instructions, or the computer reads and installs the instructions and then executes the corresponding installed program. Herein, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.

[0149] Although the embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations all fall within the scope defined by the appended claims.

Claims

1. A method for generating a service interface based on structured data, characterized in that: Applied to a service interface generation system, the service interface generation system includes: a query specification definition module, a business rule definition module and an interface compilation and loading module, the method includes: A query specification definition module, which defines SQL language query specifications; the SQL language query specifications are used to obtain structured data using corresponding query methods in a database, a local file service or a cloud storage; A business rule definition module processes the structured data based on preset business rules to determine intermediate data; defines field information of each field in the intermediate data according to the Schema language to determine a preset Schema definition; The interface compiling and loading module dynamically generates the original code of the service interface based on the preset Schema definition and the preset service interface protocol; and generates a service interface instance corresponding to the service interface based on the original code.

2. The method according to claim 1, characterized in that The query specification definition module defines the SQL language query specification, including: A query specification definition module constructs an SQL statement using the SELECT syntax of SQL based on the data source type and target field to be queried; wherein the data source type includes: database, local file service and cloud storage; The query specification definition module defines an SQL query interface, and defines a database query specification, a local file service query specification, and a cloud storage query specification during execution of the SQL statement by the SQL query interface.

3. The method according to claim 2, characterized in that A query specification definition module defines a database query specification, which is implemented based on the following steps: constructing a database link instance based on a database driver, and executing SQL statements using the database link instance; A query specification definition module defines a local file service query specification, which is implemented based on the following steps: parsing the SQL statement to obtain the table name in the SQL statement; establishing a mapping relationship between the table name and the file name of the local file service, reading the target file based on the mapping relationship, and executing the SQL statement to extract the target field; The query specification definition module defines the cloud storage query specification, which is implemented based on the following steps: the cloud storage query specification includes: parsing the SQL statement and obtaining the table name, constructing an API query request based on the table name, and using the API query request to extract the target field.

4. The method according to any one of claims 1 to 3, characterized in that The service interface generation system further includes: an interface protocol definition module, and the method further includes: The interface protocol definition module defines a service interface protocol based on a preset Schema definition, wherein the service interface protocol includes at least one of the following: a protocol name, a protocol version, a protocol address, an input parameter list, and an output parameter list; The interface protocol definition module selects field information of at least one field in the preset Schema definition to participate in filtering and sets filtering conditions for the service interface; The interface protocol definition module selects field information of at least one field in the preset Schema definition as an output parameter, and sets the output field of the service interface.

5. The method according to claim 4, characterized in that The interface compiling and loading module dynamically generates the original code of the service interface based on the preset Schema definition and the preset service interface protocol; based on the original code, generates a service interface instance corresponding to the service interface, which is implemented based on the following steps: The interface compilation loading module dynamically generates the original code of the service interface based on the preset Schema definition, service interface protocol and filtering conditions; The interface compiling and loading module calls a programming language editor to compile the original code into a target code, loads the target code when the system is running, and instantiates the service interface to generate a service interface instance corresponding to the service interface.

6. A service interface generation system, characterized in that: The service interface generation system includes: a query specification definition module, a business rule definition module and an interface compilation and loading module, wherein: A query specification definition module, used to define SQL language query specifications; the SQL language query specifications are used to obtain structured data using corresponding query methods in a database, a local file service or a cloud storage; A business rule definition module is used to process the structured data based on preset business rules to determine intermediate data; define field information of each field in the intermediate data according to the Schema language to determine the preset Schema definition; The interface compiling and loading module is used to dynamically generate the original code of the service interface based on the preset Schema definition and the preset service interface protocol; based on the original code, generate a service interface instance corresponding to the service interface.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method for generating a service interface based on structured data according to any one of claims 1 to 5.

8. A computer program product, characterized in that The method comprises computer instructions for causing a computer to execute the method for generating a service interface based on structured data according to any one of claims 1 to 5.