Method and system for automatically generating API (Application Program Interface) based on model design

Through the API automatic generation method based on model design, the business model extracts metadata and combines generation rules to automatically generate APIs, the problems of long development cycle and low efficiency of existing API generation methods are solved, and more efficient API development is achieved.

CN120104115APending Publication Date: 2025-06-06HEBEI WANYUE INFORMATION TECHNOLOGY CO LTD

Patent Information

Application Number
CN202510211924.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-25
Publication Date
2025-06-06

AI Technical Summary

Technical Problem

Existing API generation methods require developers to manually write a large amount of code, resulting in long development cycles, low efficiency and prone to human errors.

Method used

Using the API automatic generation method based on model design, the first user creates a business model and extracts metadata, and automatically generates the API in combination with preset generation rules, and provides it to the second user.

Benefits of technology

It greatly reduces the workload of developers in writing API code, shortens the development cycle, and improves the efficiency of API development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120104115A_ABST
    Figure CN120104115A_ABST
Patent Text Reader

Abstract

The invention provides an API automatic generation method and system based on model design, and belongs to the technical field of software development. The method comprises the steps that metadata is extracted based on a service model created by a first user; generating a corresponding API based on the metadata and a preset generation rule; and providing the API for a second user. According to the model design-based API automatic generation method and system provided by the invention, the development efficiency of the API can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure belongs to the field of software development technology, and more specifically, to a method and system for automatically generating an API based on model design. Background Art

[0002] API, or Application Programming Interface, is a set of definitions, protocols, and tools that enable communication and interaction between different software systems, allowing one software system to access and use the functions and data of another software system without having to understand the specific implementation details of the other system.

[0003] At present, the generation of API requires developers to manually write a large amount of API code, which has a long development cycle, low efficiency, and is prone to human errors. Therefore, it is urgent to improve the existing API generation method to improve the efficiency of API development. Summary of the invention

[0004] The purpose of the present invention is to provide a method and system for automatically generating an API based on model design to improve the efficiency of API development.

[0005] A first aspect of an embodiment of the present disclosure provides an API automatic generation method based on model design, comprising: extracting metadata based on a business model created by the first user; Generate a corresponding API based on the metadata and preset generation rules; The API is provided to a second user.

[0006] A second aspect of the embodiments of the present disclosure provides an API automatic generation system based on model design, including: A metadata extraction module, configured to extract metadata based on a business model created by a first user; An API generation module, used to generate a corresponding API based on the metadata and preset generation rules; The API publishing module is used to provide the API to a second user.

[0007] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of the above-mentioned method for automatic API generation based on model design when executing the computer program.

[0008] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned method for automatically generating an API based on model design are implemented.

[0009] The beneficial effects of the model-based API automatic generation method and system provided by the embodiments of the present disclosure are: In the disclosed embodiment, the first user is a business person or a system analyst, and the second user is a developer. The first user designs and creates a business model according to actual business needs, extracts metadata from the business model, and can obtain various attributes, relationships, constraints and other information in the business model; maps the information in the metadata to pre-set generation rules to generate a corresponding API; publishes the generated API to an accessible platform or environment, and the second user can call the corresponding API according to his own needs.

[0010] Therefore, this embodiment automatically generates an API based on the business model, and developers only need to focus on the design of the business model, which greatly reduces the workload of writing API codes and shortens the development cycle. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0012] Figure 1 A flowchart of an API automatic generation method based on model design provided in one embodiment of the present disclosure; Figure 2 A structural block diagram of an API automatic generation system based on model design provided in one embodiment of the present disclosure; Figure 3 A schematic block diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0013] In the following description, specific details such as specific system structures and technologies are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present disclosure. However, it should be clear to those skilled in the art that the present disclosure may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obstructing the description of the present disclosure with unnecessary details.

[0014] In order to make the purpose, technical solutions and advantages of the present disclosure more clear, specific embodiments will be described below in conjunction with the accompanying drawings.

[0015] Please refer to Figure 1 , Figure 1 A flowchart of a method for automatically generating an API based on model design provided in an embodiment of the present disclosure, the method being applied to an automatic API generation system (or platform), comprising: S101: Extract metadata based on a business model created by a first user.

[0016] In this embodiment, the first user may be a business person or a system analyst, and the first user designs and creates a business model according to actual business needs. The business model is an abstract representation of business processes, business entities and their relationships. For example, in an e-commerce system, the business model includes a product model, an order model, a user model, etc. In the product model, various attributes of the product are defined, such as product name, price, inventory, etc.; in the order model, information such as order number, order time, order status, etc. is included.

[0017] Metadata is data that describes data. It contains key information about the business model, including various attributes, relationships, constraints, etc. in the business model. Taking the product model as an example, the extracted metadata can include the name of the product attribute, the data type (such as the product name is a string type, the price is a floating point type), whether it is a required item, etc.

[0018] Specifically, metadata can be obtained by parsing the design document of the business model, or by using a dedicated metadata extraction tool (such as Metadata Scraper, Apache Tika, etc.), or by obtaining relevant information from the database where the business model is stored.

[0019] S102: Generate a corresponding API based on the metadata and preset generation rules.

[0020] In this embodiment, the preset generation rules may include generation rules for creating data API, modifying data API, querying data API, deleting data API, importing data API, exporting data API, etc. The preset generation rules are a series of predefined logics used to specify how to generate APIs based on metadata. The rules cover all aspects of the API, including interface naming conventions, request methods (such as GET, POST, PUT, DELETE), parameter formats, return value structures, etc.

[0021] For example, for an API for creating products, the rules can specify that the interface name is / api / products, the request method is POST, the request parameters must include all required attributes of the product, and the return value is the detailed information of the newly created product.

[0022] According to the extracted metadata and the preset generation rules, the corresponding API can be automatically generated. Specifically, the corresponding API generation rules can be derived according to the structure and semantics of the business model. For example, in a system modeled in the Unified Modeling Language (UML), the generation rules of the database table structure and API interface can be derived from the model elements such as UML class diagrams and use case diagrams to ensure that the system design is consistent with the business model.

[0023] The preset generation rules directly determine whether the generated API functions meet business requirements. Therefore, before generating the corresponding API based on metadata and preset generation rules, it is necessary to check the preset generation rules and correct any problems found in a timely manner. The inspection contents include: syntax and logic check, matching check with metadata, performance and efficiency check, security check, etc.

[0024] S103: Provide the API to the second user.

[0025] In this embodiment, the system can generate APIs such as create data / modify data / query data / delete data / import data / export data by using the above method, and can publish the generated APIs to an accessible platform or environment, which can be an internal API gateway of the enterprise or an open API platform for external developers. During the publishing process, the platform will provide detailed documentation of the interface, including information such as the functional description of the interface, request and response formats, and usage examples, so that the second user can understand and use the interface.

[0026] The second user can be a developer, who can call these API interfaces according to their own needs. For example, front-end developers can call the product query API interface to obtain product data and display it on the web page; third-party developers can integrate the API interface of the e-commerce system to develop their own e-commerce applications.

[0027] From the above, it can be concluded that in this embodiment, the first user designs and creates a business model according to actual business needs, extracts metadata from the business model, and obtains various attributes, relationships, constraints and other information in the business model; maps the information in the metadata to pre-set generation rules to generate a corresponding API; publishes the generated API to an accessible platform or environment, and the second user can call the corresponding API according to his own needs.

[0028] Therefore, this embodiment automatically generates an API based on the business model, and developers only need to focus on the design of the business model, which greatly reduces the workload of writing API codes and shortens the development cycle.

[0029] In one embodiment of the present disclosure, based on metadata and preset generation rules, a corresponding API is generated, including: The dynamic SQL construction library is used to dynamically splice and execute SQL statements according to metadata and preset generation rules when the program is running, realize interactive operations with the database, and encapsulate the interactive operations as APIs.

[0030] In this embodiment, the preset generation rules specify the basic structure of SQL statements in different business scenarios. For example, the preset generation rules define the API interface for querying the product list. When there is a need for fuzzy query by product name, a SELECT statement structure containing the LIKE keyword should be generated, such as "SELECT * FROM products WHERE product_name LIKE?". Here, the preset generation rules clarify the components and general framework of the SQL statement, and guide the program to construct a specific SQL statement based on the table name (such as products) and field name (such as product_name) in the metadata.

[0031] When the program is running, the dynamic SQL building library is used to dynamically splice SQL statements based on metadata and business requirements. For example, if the metadata indicates that you want to obtain a list of orders for a specific user, you can dynamically generate the following SQL statement based on the user ID in the metadata: SELECT * FROM orders WHERE user_id = [specific user ID] By building a library with dynamic SQL, the program can connect to different types of databases according to the configuration and use a unified interface to perform data operations, without having to write complex interaction code for each database separately. The interaction operations with the database (such as query, insert, update, delete, etc.) are abstracted into a set of simple interfaces, that is, the API.

[0032] From the above, it can be concluded that this embodiment uses the dynamic SQL construction library to dynamically splice SQL statements, and can flexibly adjust the logic of SQL statements at runtime according to new business needs and metadata changes, so that the system can quickly respond to business changes and have stronger adaptability.

[0033] In one embodiment of the present disclosure, a dynamic SQL building library is used to dynamically splice and execute SQL statements according to metadata and preset generation rules when the program is running, including: Build basic SQL statements based on user input instructions; Based on the value input by the user, add the operation condition after the basic SQL statement to obtain the dynamic splicing SQL statement; Execute dynamic splicing SQL statements.

[0034] In this embodiment, dynamically generated SQL statements need to be reparsed, compiled, and optimized each time they are executed, which may lead to performance bottlenecks in high-concurrency scenarios. To solve this problem, this embodiment optimizes SQL statements, minimizes the dynamically changing parts of SQL statements, keeps more statement structures consistent, and facilitates database caching and optimization.

[0035] Specifically, some optional operation conditions can be processed in the code through logical judgment, rather than all placed in dynamic SQL. For example, for the need to query user information, you can first build a basic SQL statement: "SELECT *FROM users WHERE 1 = 1". Here, "1 = 1" is a condition that is always true. Subsequent query conditions can be connected using "AND", which is convenient for adding subsequent query conditions. Then, check whether each optional query condition has an actual value passed in, such as the optional query condition is the user's name and age range. If a certain optional query condition has a value passed in, add the corresponding query condition to the basic SQL statement. For example, if the user name "Zhang San" is passed in, add "AND name = 'Zhang San'" after the basic SQL statement; if the age range is passed in, such as the minimum age is 20 years old and the maximum age is 30 years old, add "AND age>= 20 AND age<= 30".

[0036] It can be concluded from the above that this embodiment decomposes the dynamically spliced ​​SQL statement into basic SQL statements and operation conditions, which can minimize the dynamically changing parts in the dynamically spliced ​​SQL statement, keep more statement structures consistent, and facilitate database caching and optimization.

[0037] In one embodiment of the present disclosure, the basic SQL statement includes a placeholder, and an operation condition is added after the basic SQL statement to obtain a dynamically spliced ​​SQL statement, including: The operation conditions are arranged in the order of the placeholders in the basic SQL statement to form an operation condition value list; The basic SQL statement and the operation condition value list are passed to the database to instruct the database to bind the numerical values ​​in the operation condition value list to the placeholders of the SQL statement to generate a dynamically spliced ​​SQL statement.

[0038] In the embodiment, if the operation conditions are directly spliced ​​into the SQL statement, it may cause SQL injection attacks. Malicious users can tamper with the original SQL logic by entering special characters or SQL statement fragments to obtain sensitive information, modify data or perform other malicious operations.

[0039] Still taking the query operation as an example, to avoid the above problems, when adding query conditions, the value of the query condition can be passed as a parameter instead of directly splicing it into the SQL statement, thereby avoiding the risk of SQL injection and helping the database cache and optimize the SQL statement. For example, for user name query, use the placeholder "AND name =?" in the SQL statement, and then pass "Zhang San" as a parameter to the database to execute the statement.

[0040] It can be concluded from the above that this embodiment avoids directly splicing user input into SQL statements by using placeholders and operation condition value lists, thereby effectively preventing SQL injection attacks.

[0041] In one embodiment of the present disclosure, the business model includes key indicator data, and extracting metadata based on the business model created by the first user includes: Input key indicator data and various business data into the support vector machine model; The values ​​of each business data are changed respectively to obtain the change in the output amplitude of the support vector machine model; The business data whose corresponding change amount is greater than a set threshold is determined as metadata.

[0042] In this embodiment, the business data refers to various specific data related to the business model. For example, the business data corresponding to the e-commerce platform may include user behavior data, sales data, product inventory data, etc.

[0043] Considering the large amount of business data in the business model, there may be missing items or multiple items when extracting metadata from it, resulting in inaccurate extracted metadata, which in turn affects subsequent API generation.

[0044] To solve the above problem, the first user can set key indicator data in the business model. Key indicator data is an important data indicator for measuring business results. For example, in e-commerce business, key indicator data can be sales volume and customer conversion rate; in manufacturing industry, key indicator data can be product qualification rate, production efficiency, etc.

[0045] On this basis, key indicator data and business data are input into the support vector machine model, the values ​​of each business data are changed respectively, and the change in the output amplitude of the support vector machine model is calculated. For example, the inventory quantity of goods is changed from 100 to 120, and the change in the output result of the SVM model is calculated.

[0046] If the change of a certain business data leads to a significant change in the output of the support vector machine model, it indicates that the business data has a significant impact on the key indicator data, and the business data is determined as metadata.

[0047] Specifically, a set threshold may be predetermined. If a change in certain business data causes a change in the output amplitude of the support vector machine model to be greater than the set threshold, the business data is determined as metadata.

[0048] It can be concluded from the above that this embodiment inputs key indicator data and business data into the support vector machine model, and uses the powerful classification and regression capabilities of the support vector machine to mine the potential relationships between the data and extract valuable information from the business data as metadata, thereby improving the accuracy of metadata extraction.

[0049] In one embodiment of the present disclosure, the API automatic generation method based on model design also includes: Perform linear fitting on each business data within the set sliding window to obtain multiple fitting parameters corresponding to multiple sliding windows; If the relative standard deviation of the plurality of fitting parameters is greater than a first threshold, setting the penalty parameter of the support vector machine model to a first value; If the relative standard deviations of the multiple fitting parameters are less than or equal to the first threshold, the penalty parameter of the support vector machine model is set to a second value; and the first value is less than the second value.

[0050] In this embodiment, the penalty parameter is a key hyperparameter of the support vector machine model. When the penalty parameter is large, the support vector machine model will be more inclined to reduce the classification errors in the training data and correctly classify all training samples as much as possible, which will make the decision boundary of the model more complex, increase the model complexity, and easily lead to overfitting; when the penalty parameter is small, the support vector machine model has a greater tolerance for classification errors in the training data and will choose a simpler decision boundary to reduce the model complexity, but this may cause the model to be underfitting.

[0051] In order to make the setting of penalty parameters suitable for the needs of most scenarios, this embodiment classifies various scenarios according to the nonlinearity of business data, and sets corresponding penalty parameters for scenarios of different classifications.

[0052] Specifically, scenarios with a high degree of nonlinearity may include risk assessment, weather forecasting, user behavior analysis, and other scenarios. Taking user behavior analysis as an example, there is a nonlinear relationship between user activity and retention rate on the Internet platform and factors such as platform functions, content recommendations, and user experience. For example, the optimization of the platform's recommendation algorithm may cause a sudden increase in user activity, but when the recommended content is too single or does not meet the user's interests, the activity will drop rapidly. In this type of scenario, setting the penalty parameter to a smaller first value can make the support vector machine model more flexible during the training process. It will not be too obsessed with achieving completely accurate classification on the training set, but will focus more on finding a way to better fit the data distribution overall, reduce the risk of overfitting, and improve the adaptability of the model.

[0053] Scenarios with a low degree of nonlinearity can include simple manufacturing, logistics and transportation. For example, in logistics and transportation, if the transportation route is fixed, the freight is usually linearly related to the transportation distance. For example, in a certain area, the logistics company stipulates that the transportation fee per kilometer is a fixed value, such as 5 yuan per ton of goods per kilometer, then the total freight is equal to the weight of the goods multiplied by the transportation distance and then multiplied by the unit price per kilometer, that is, freight = weight of goods × transportation distance × 5. In this type of scenario, setting the penalty parameter to a larger second value can allow the support vector machine model to treat the misclassification in the training data more strictly, thereby better mining the rules in the data and improving the accuracy of the support vector machine model.

[0054] Exemplarily, when evaluating the degree of nonlinearity between business data, a sliding window can be set, and linear fitting can be performed on various types of business data in each sliding window. If the relative standard deviation of the fitting parameters in different sliding windows is greater than the first threshold, it indicates that the fitting parameters have changed a lot, and the business data has nonlinear characteristics locally, and the data may be highly nonlinear as a whole.

[0055] Among them, the fitting parameters include the slope and intercept of the straight line, and the relative standard deviation of the slope and intercept of the straight line can be calculated respectively. If the relative standard deviation of the slope of the straight line is greater than the first threshold, or the relative standard deviation of the intercept is greater than the first threshold, it is judged that the fitting parameter is greater than the first threshold, and the business data is data with strong nonlinearity; if the relative standard deviation of the slope of the straight line is less than or equal to the first threshold, and the relative standard deviation of the intercept is less than or equal to the first threshold, it is judged that the fitting parameter is less than or equal to the first threshold, and the business data is data with weak nonlinearity.

[0056] It can be concluded from the above that this embodiment selects corresponding penalty parameters based on the characteristics of business data in different scenarios, which is conducive to improving the accuracy and versatility of the support vector machine model.

[0057] In one embodiment of the present disclosure, providing the API to the second user includes: Generate unique API access credentials for the second user to ensure authentication and access authorization.

[0058] In this embodiment, the unique API access credential may include an API Key, an OAuth token, etc. A unique API access credential is generated for the second user before the API is provided to the second user. This can confirm whether the request comes from a legitimate second user and avoid impersonation or malicious access by illegal users. Different access permissions can be configured for different second users to accurately control which API resources users can access and what operations they can perform on these resources, such as reading, writing, or deleting.

[0059] From the above, we can conclude that different second users may have different needs when using APIs. Access authorization through unique access credentials can meet various complex business scenarios and make the use of APIs more in line with actual business needs.

[0060] Corresponding to the API automatic generation method based on model design in the above embodiment, Figure 2 A structural block diagram of an API automatic generation system based on model design provided by an embodiment of the present disclosure. For ease of explanation, only the parts related to the embodiment of the present disclosure are shown. Figure 2 The API automatic generation system 20 based on model design includes: a metadata extraction module 21, an API generation module 22 and an API publishing module 23. The metadata extraction module 21 is used to extract metadata based on the business model created by the first user; An API generation module 22, used to generate a corresponding API based on metadata and preset generation rules; The API publishing module 23 is used to provide the API to the second user.

[0061] In one embodiment of the present disclosure, the API generation module 22 is specifically used to: The dynamic SQL construction library is used to dynamically splice and execute SQL statements according to metadata and preset generation rules when the program is running, realize interactive operations with the database, and encapsulate the interactive operations as APIs.

[0062] In one embodiment of the present disclosure, the API generation module 22 is further configured to: Build basic SQL statements based on user input instructions; Based on the value input by the user, add the operation condition after the basic SQL statement to obtain the dynamic splicing SQL statement; Execute dynamic splicing SQL statements.

[0063] In one embodiment of the present disclosure, the basic SQL statement includes a placeholder, and the API generation module 22 is further configured to: The operation conditions are arranged in the order of the placeholders in the basic SQL statement to form an operation condition value list; The basic SQL statement and the operation condition value list are passed to the database to instruct the database to bind the numerical values ​​in the operation condition value list to the placeholders of the SQL statement, generate a dynamic splicing SQL statement, and execute the dynamic splicing SQL statement.

[0064] In one embodiment of the present disclosure, the business model includes key indicator data, and the metadata extraction module 21 is specifically used to: Input key indicator data and various business data into the support vector machine model; The values ​​of each business data are changed respectively to obtain the change in the output amplitude of the support vector machine model; The business data whose corresponding change amount is greater than a set threshold is determined as metadata.

[0065] In one embodiment of the present disclosure, the metadata extraction module 21 is further used to: Perform linear fitting on each business data within the set sliding window to obtain multiple fitting parameters corresponding to multiple sliding windows; If the relative standard deviation of the plurality of fitting parameters is greater than a first threshold, setting the penalty parameter of the support vector machine model to a first value; If the relative standard deviations of the multiple fitting parameters are less than or equal to the first threshold, the penalty parameter of the support vector machine model is set to a second value; and the first value is less than the second value.

[0066] In one embodiment of the present disclosure, the API publishing module 23 is specifically used to: Generate unique API access credentials for the second user to ensure authentication and access authorization.

[0067] See also Figure 3 , Figure 3 A schematic block diagram of an electronic device provided by an embodiment of the present disclosure. Figure 3 The electronic device 300 in the embodiment shown may include: one or more processors 301, one or more input devices 302, one or more output devices 303 and one or more memories 304. The processors 301, input devices 302, output devices 303 and memories 304 communicate with each other via a communication bus 305. The memory 304 is used to store computer programs, which include program instructions. The processor 301 is used to execute the program instructions stored in the memory 304. The processor 301 is configured to call the program instructions to execute the functions of each module / unit in the above-mentioned device embodiments, such as Figure 2 The functions of modules 21 to 23 are shown.

[0068] It should be understood that in the embodiment of the present disclosure, the processor 301 may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0069] The input device 302 may include a touch panel, a fingerprint collection sensor (for collecting the user's fingerprint information and fingerprint direction information), a microphone, etc., and the output device 303 may include a display (LCD, etc.), a speaker, etc.

[0070] The memory 304 may include a read-only memory and a random access memory, and provide instructions and data to the processor 301. A portion of the memory 304 may also include a non-volatile random access memory. For example, the memory 304 may also store information about the device type.

[0071] In a specific implementation, the processor 301, input device 302, and output device 303 described in the embodiments of the present disclosure can execute the implementation methods described in the first and second embodiments of the API automatic generation method based on model design provided in the embodiments of the present disclosure, and can also execute the implementation methods of the electronic device described in the embodiments of the present disclosure, which will not be repeated here.

[0072] In another embodiment of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by the processor, all or part of the processes in the above-mentioned embodiment method are implemented, and the computer program can also be completed by instructing the relevant hardware through the computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, the steps of each of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc.

[0073] The computer-readable storage medium may be an internal storage unit of the electronic device of any of the aforementioned embodiments, such as a hard disk or memory of the electronic device. The computer-readable storage medium may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Furthermore, the computer-readable storage medium may also include both an internal storage unit of the electronic device and an external storage device. The computer-readable storage medium is used to store computer programs and other programs and data required by the electronic device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.

[0074] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this disclosure.

[0075] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the electronic devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0076] In the several embodiments provided in the present application, it should be understood that the disclosed electronic devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces or units, or it can be an electrical, mechanical or other form of connection.

[0077] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present disclosure.

[0078] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0079] The above are only specific embodiments of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present disclosure, and these modifications or replacements should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A method for automatically generating an API based on model design, characterized in that: include: extracting metadata based on a business model created by the first user; Generate a corresponding API based on the metadata and preset generation rules; The API is provided to a second user.

2. The method for automatically generating an API based on model design as claimed in claim 1, characterized in that: The generating a corresponding API based on the metadata and a preset generating rule includes: The dynamic SQL construction library is used to dynamically splice and execute SQL statements according to metadata and preset generation rules when the program is running, so as to realize interactive operations with the database, and the interactive operations are encapsulated as the API.

3. The method for automatically generating an API based on model design as claimed in claim 2, characterized in that: Use the dynamic SQL construction library to dynamically splice and execute SQL statements based on metadata and preset generation rules when the program is running, including: Build basic SQL statements based on user input instructions; Based on the value input by the user, add the operation condition after the basic SQL statement to obtain the dynamic splicing SQL statement; Execute the dynamically concatenated SQL statement.

4. The method for automatically generating an API based on model design as claimed in claim 3, characterized in that: The basic SQL statement includes a placeholder, and the executing the dynamic splicing SQL statement includes: The operation conditions are formed into an operation condition value list according to the order of the placeholders in the basic SQL statement; The basic SQL statement and the operation condition value list are delivered to a database to instruct the database to bind the values ​​in the operation condition value list to the placeholders of the SQL statement, generate a dynamic splicing SQL statement, and execute the dynamic splicing SQL statement.

5. The method for automatically generating an API based on model design as claimed in claim 1, characterized in that: The business model includes key indicator data, and the step of extracting metadata based on the business model created by the first user includes: Inputting the key indicator data and each business data into a support vector machine model; The values ​​of each business data are changed respectively to obtain the change in the output amplitude of the support vector machine model; The business data whose corresponding change amount is greater than a set threshold is determined as the metadata.

6. The method for automatically generating an API based on model design as claimed in claim 5, characterized in that: Also includes: Perform linear fitting on each business data within the set sliding window to obtain multiple fitting parameters corresponding to multiple sliding windows; If the relative standard deviation of the plurality of fitting parameters is greater than a first threshold, setting the penalty parameter of the support vector machine model to a first value; If the relative standard deviation of the plurality of fitting parameters is less than or equal to a first threshold, the penalty parameter of the support vector machine model is set to a second value; and the first value is less than the second value.

7. The method for automatically generating an API based on model design as claimed in claim 1, characterized in that: Providing the API to the second user includes: Generate unique API access credentials for the second user to ensure authentication and access authorization.

8. An API automatic generation system based on model design, characterized in that: include: A metadata extraction module, configured to extract metadata based on a business model created by a first user; An API generation module, used to generate a corresponding API based on the metadata and preset generation rules; The API publishing module is used to provide the API to a second user.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • A method for predict power consumption behavior of a distribution us

    CN109345013A

  • Addition, deletion, modification and check service interface generation method based on database metadata

    CN114443015A

  • Report generation method, computer device and storage medium

    CN118446197A

  • Asset analysis report generation method, equipment and medium

    CN118586527A

  • Method, system and equipment for generating SQL (Structured Query Language) statement based on large model

    CN119127913A

Cited By

  • Crystal pulling information processing method, system and equipment, storage medium and single crystal product

    CN120804175A

  • Data denoising method for distributed artificial source electromagnetic exploration method

    CN121559617A