Interface calling method, device, storage medium and computer device
By introducing the checksum of the target interface model to the dynamic execution of SQL statements in the interface calling method, the problem of low efficiency of interface calling in the prior art is solved, and a more flexible and efficient interface calling process is achieved.
Patent Information
- Application Number
- CN202311602645.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-27
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2043-11-27
AI Technical Summary
In the prior art, when a component or model needs to be modified, the interface service needs to be redeployed and published, resulting in less efficient interface calls.
Provides an interface calling method, which obtains request parameters and request paths by receiving interface calling instructions, determines whether the target interface model is validated and determines the target SQL statement in its SQL module. This method supports the execution of Groovy scripts, allowing for flexible configuration of SQL statements to be performed until the result identifier of each SQL statement is assembled to return the target execution result.
Improves the flexibility and efficiency of interface calls, allowing modifications to take effect without redeployment of services, and reducing delays in interface calls.
Smart Images

Figure CN117609275B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of software development, and particularly to an interface call method, device, storage medium, and computer device. Background Art
[0002] With the development of computing software, customers have more and more requirements and shorter and shorter online cycles. However, the generation of interfaces for traditional software requires processes such as requirement collection, design, development, testing, and release, which are difficult to meet the customers' requirements for flexible response on time and with high quality. Low-code platforms and technologies provide a more flexible, efficient, and low-cost solution for enterprises.
[0003] Currently, the implementation method of low-code platforms based on domain model technology is to provide service interfaces according to models and components, and after generating the service interfaces, publish them for front-end personnel to use. However, when components or models need to be modified, the interface service needs to be redeployed and published, so that the modified content can take effect. As a result, the efficiency of interface calls is relatively low. Summary of the Invention
[0004] The purpose of this application aims to solve at least one of the above technical defects, especially the technical defect that when components or models need to be modified in the prior art, the interface service needs to be redeployed and published, so that the modified content can take effect. As a result, the efficiency of interface calls is relatively low.
[0005] In a first aspect, this application provides an interface call method, and the method includes:
[0006] Receiving an interface call instruction, and obtaining the request parameters and request path in the interface call instruction;
[0007] When the target interface model has been created and is in an enabled state, judging whether the target interface model passes the verification according to the request parameters; wherein, the target interface model is the interface model corresponding to the request path;
[0008] If the target interface model passes the verification, determining the target SQL statement to be executed currently in the SQL module in the target interface model;
[0009] When it is determined that the target SQL statement has an execution condition and the execution condition is established, or when it is determined that the target SQL statement has no execution condition, executing the target SQL statement to obtain an execution result;
[0010] Determine whether there is a corresponding Groovy script for the target SQL statement. If there is a corresponding Groovy script for the target SQL statement, execute the Groovy script corresponding to the target SQL statement to update the execution result;
[0011] Determine the execution result corresponding to the current target SQL statement as its corresponding result identifier;
[0012] Determine whether the target SQL statement is the last SQL statement in the SQL module. If not, return to the step of determining the target SQL statement to be executed currently and continue to execute. If so, assemble the result identifiers of each SQL statement in the SQL module to obtain the target execution result, and return the target execution result to the client.
[0013] In one embodiment, the step of creating the target interface model includes:
[0014] Receive a model creation instruction and obtain the creation parameters in the model creation instruction;
[0015] Determine the initial interface model;
[0016] According to the creation parameters, configure the interface name, interface path, request method, and input parameter fields for the initial interface model;
[0017] Determine at least one initial SQL statement and the execution order of each initial SQL statement to generate a target SQL module;
[0018] Send the target SQL module to the client, and configure the Groovy script and execution conditions for the initial SQL statements in the target SQL module according to the response data of the client;
[0019] Save the configured target SQL module into the configured initial interface model, and determine the configured target SQL module as the SQL module of the configured initial interface model to obtain a new initial interface model;
[0020] Determine the new initial interface model as the target interface model.
[0021] In one embodiment, the determining at least one initial SQL statement and the execution order of each initial SQL statement includes:
[0022] Determine the table model corresponding to the creation parameters;
[0023] Generate multiple SQL statements corresponding to the primary key of each table according to the relationships between the tables in the table model;
[0024] Determine at least one initial SQL statement among multiple SQL statements corresponding to the primary key of each table according to the creation parameters, and determine the execution order of each initial SQL statement;
[0025] Generate the target SQL module based on the execution order of each initial SQL statement.
[0026] In one embodiment, the determining whether the target interface model passes the verification according to the request parameters includes:
[0027] Obtain each input parameter field of the target interface model;
[0028] Compare each input parameter field of the target interface model with the corresponding field in the request parameters in sequence;
[0029] If there is an input parameter field in the target interface model that is inconsistent with the corresponding field in the request parameters, it indicates that the target interface model fails the verification;
[0030] If each input parameter field of the target interface model is consistent with the corresponding field in the request parameters, determine whether the field values corresponding to each field with a preset condition in the request parameters all meet the preset condition corresponding to the field;
[0031] If the field values corresponding to each field with a preset condition in the request parameters all meet the preset condition corresponding to the field, it indicates that the target interface model passes the verification;
[0032] If there is a field value corresponding to a field in the request parameters that does not meet the preset condition corresponding to the field, it indicates that the target interface model fails the verification.
[0033] In one embodiment, the determining whether the execution condition of the target SQL statement is established includes:
[0034] Obtain the parameter fields in the execution condition of the target SQL statement;
[0035] Search for the field value corresponding to the parameter field in the execution condition of the target SQL statement in the request parameters and the result identifier of the previous target SQL statement;
[0036] Determine whether the field value corresponding to the parameter field in the execution condition of the target SQL statement meets the execution condition of the target SQL statement;
[0037] If it meets, determine that the execution condition of the target SQL statement is established;
[0038] If not satisfied, it is determined that the execution condition of the target SQL statement does not hold.
[0039] In one embodiment, the method further includes:
[0040] When the target SQL statement has its corresponding execution condition and the corresponding execution condition does not hold, it is determined whether the target SQL statement is the last SQL statement in the SQL module;
[0041] If not, return to the step of determining the target SQL statement to be executed currently and continue to execute;
[0042] If so, assemble the result identifiers of each SQL statement in the SQL module to obtain a target execution result, and return the target execution result to the client.
[0043] In one embodiment, the method further includes:
[0044] If the target interface model verification fails, terminate the response to the interface call instruction and generate an alarm message;
[0045] Return the alarm message to the client.
[0046] In a second aspect, the present application provides an interface call device, and the device includes:
[0047] An instruction receiving module, configured to receive an interface call instruction and obtain request parameters and a request path in the interface call instruction;
[0048] A model verification module, configured to, when the target interface model has been created and is in an enabled state, determine whether the target interface model passes verification according to the request parameters; wherein, the target interface model is an interface model corresponding to the request path;
[0049] An SQL statement determination module, configured to, if the target interface model passes verification, determine a target SQL statement to be executed currently in the SQL module of the target interface model;
[0050] An SQL statement execution module, configured to execute the target SQL statement to obtain an execution result when it is determined that the target SQL statement has an execution condition and the execution condition holds, or when it is determined that the target SQL statement has no execution condition;
[0051] An execution result update module, configured to determine whether the target SQL statement has a corresponding Groovy script, and if the target SQL statement has a corresponding Groovy script, execute the Groovy script corresponding to the target SQL statement to update the execution result;
[0052] A result identification determination module, configured to determine the execution result corresponding to the current target SQL statement as its corresponding result identification;
[0053] A judgment module, configured to judge whether the target SQL statement is the last SQL statement in the SQL module. If not, return to the step of determining the target SQL statement to be executed currently and continue to execute. If so, assemble the result identifications of each SQL statement in the SQL module to obtain a target execution result, and return the target execution result to the client.
[0054] In a third aspect, the present application provides a storage medium, in which computer-readable instructions are stored. When the computer-readable instructions are executed by one or more processors, the one or more processors are caused to execute the steps of the interface call method described in any one of the above embodiments.
[0055] In a fourth aspect, the present application provides a computer device, including: one or more processors, and a memory;
[0056] The memory stores computer-readable instructions. When the one or more processors execute the computer-readable instructions, the steps of the interface call method described in any one of the above embodiments are executed.
[0057] As can be seen from the above technical solutions, the embodiments of the present application have the following advantages:
[0058] The interface call method, device, storage medium and computer device provided by the present application. The method includes: when the request parameters and request path in the interface call instruction are obtained, according to the request parameters and request path, judge whether the target interface model has been created and is in a startup state and passes the verification. If so, determine the target SQL statement. When the target SQL statement has an execution condition and the execution condition is established, or when the target SQL statement does not have an execution condition, execute the target SQL statement. And when there is a Groovy script for the target SQL statement, use the Groovy script to process the execution result of the target SQL statement until it is determined that the target SQL statement is the last SQL statement in the SQL module, and assemble the execution results of each SQL statement in the SQL module to obtain a target execution result. When calling an interface, it is necessary to judge whether the execution condition of the target SQL statement exists and whether it is established, and the actual execution order of the SQL statement can be configured flexibly. Thereby improving the flexibility of interface call. Moreover, since the executed script is a Groovy script, when the Groovy script is modified, it is not necessary to redeploy the service to make the modified content take effect, thereby improving the efficiency of interface call. Description of the Drawings
[0059] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0060] Figure 1 It is a schematic flowchart of an interface call method provided by an embodiment of the present application;
[0061] Figure 2 It is a schematic flowchart of the creation steps of the target interface model provided by an embodiment of the present application;
[0062] Figure 3 It is a schematic flowchart of determining whether the target interface model passes the verification provided by an embodiment of the present application;
[0063] Figure 4 It is a schematic flowchart of determining whether the execution condition of the target SQL statement is established provided by an embodiment of the present application;
[0064] Figure 5 It is a schematic structural diagram of an interface call device provided by an embodiment of the present application;
[0065] Figure 6 It is an internal structure diagram of a computer device provided by an embodiment of the present application. Specific embodiments
[0066] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, rather than all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.
[0067] In one of the embodiments, the present application provides an interface call method. The following embodiments are described by taking the application of this method to a server as an example. It can be understood that the execution of the interface call method can be a single server or a server cluster composed of multiple servers. The present application does not make specific limitations on this.
[0068] As Figure 1 shown, the present application provides an interface call method, and the method includes:
[0069] Step S101: Receive an interface call instruction, and obtain the request parameters and request path in the interface call instruction.
[0070] Among them, the request parameters are some data or information carried when sending a request to the server. The request path refers to the access address of the interface to be called.
[0071] In this step, when an interface needs to be called, the client can input the request parameters and request path corresponding to the interface. When the client receives the request parameters and request path, it generates an interface call instruction according to the request parameters and request path, and sends the interface call instruction to the server. When the server receives the interface call instruction, it parses the interface call instruction to obtain the request parameters and request path included in the interface call instruction.
[0072] Step S102: When the target interface model has been created and is in an enabled state, it is determined whether the target interface model passes the verification according to the request parameters.
[0073] Among them, the target interface model is the interface model corresponding to the request path. The target interface model includes the structure information, basic configuration information, parameter configuration information, SQL module, etc. of its corresponding API interface.
[0074] It can be understood that when the target interface model is in an enabled state, it means that the target interface model has been published and can be provided for users to use. In this step, when it is determined that the target interface model has been created and the target interface model is in an enabled state, it is necessary to determine whether the request parameters meet the parameter requirements of the target interface model, that is, to verify the target interface model according to the request parameters.
[0075] Step S103: If the target interface model passes the verification, determine the target SQL statement to be executed currently in the SQL module of the target interface model.
[0076] In this step, when the target interface model passes the verification, the target SQL statement to be executed currently is determined in turn according to the order of the SQL statements in the SQL module of the target interface model.
[0077] Step S104: Determine whether the target SQL statement has an execution condition and its execution condition holds, or, does not have an execution condition.
[0078] Among them, the execution condition consists of Groovy conditional statements.
[0079] Step S105: When it is determined that the target SQL statement has an execution condition and its execution condition holds, or, it is determined that the target SQL statement does not have an execution condition, execute the target SQL statement to obtain an execution result.
[0080] In this step, when the target SQL statement has an execution condition and the execution condition is satisfied, or when the target SQL statement has no execution condition, it can be determined that the target SQL statement needs to be executed. At this time, execute the target SQL statement to obtain the corresponding execution result. It can be understood that the target SQL statement having no execution condition means that the target SQL statement can be executed without satisfying any conditions.
[0081] Step S106: Determine whether there is a corresponding Groovy script for the target SQL statement.
[0082] Among them, the Groovy script is a dynamic scripting language based on Java syntax, which can run on the Java Virtual Machine (JVM). The Groovy script has a syntax that is highly compatible with Java and can directly call Java classes and libraries.
[0083] In this step, after executing the target SQL statement, it is necessary to determine whether there is a corresponding Groovy script configuration for the target SQL statement. If there is a corresponding Groovy script configuration for the target SQL statement, it is necessary to execute the Groovy script corresponding to the target SQL statement to perform operations such as filtering or processing on the execution result of the target SQL statement. Thus, a new execution result is obtained.
[0084] It can be understood that each SQL statement can be configured with its corresponding Groovy script. In other words, a Groovy script can be configured separately for the SQL statement. In this way, the execution results of different SQL statements can be processed individually. By improving the configuration flexibility when constructing the interface model, the flexibility of the interface call method is further improved.
[0085] Step S107: If there is a corresponding Groovy script for the target SQL statement, execute the Groovy script corresponding to the target SQL statement to update the execution result.
[0086] When there is a corresponding Groovy script for the target SQL statement, use the Groovy script to process the execution result to obtain a new execution result, and determine the new execution result as the execution result of the target SQL statement to complete the update of the execution result.
[0087] Exemplarily, assume that the execution result B of SQL statement A includes key-value pair a. At this time, the key-value pair a is {phone: "13500000001"}. When it is necessary to hide the phone number, a corresponding Groovy script can be configured so that after executing the Groovy script, the key-value pair a in the new execution result B obtained is {phone: "******"}. At this time, the new execution result B is determined as the execution result B of SQL statement A.
[0088] Step S108: Determine the execution result corresponding to the current target SQL statement as its corresponding result identifier.
[0089] In this step, there are two cases for the execution result corresponding to the current target SQL statement: one is that the target SQL statement has its corresponding Groovy script. At this time, the execution result corresponding to the current target SQL statement refers to the new execution result obtained after processing the execution result of the target SQL statement by executing the Groovy script. The other is that the target SQL statement does not have its corresponding Groovy script. At this time, the execution result corresponding to the current target SQL statement refers to the execution result obtained when executing the target SQL statement.
[0090] Step S109: Determine whether the target SQL statement is the last SQL statement in the SQL module.
[0091] It can be understood that determining whether the target SQL statement is the last SQL statement in the SQL module means whether the target SQL statement is the last SQL statement in the text structure of the SQL module.
[0092] Exemplarily, assume that SQL module A has SQL statement a, SQL statement b, and SQL statement c, and the text structure is in the order from front to back (from top to bottom) as SQL statement b, SQL statement a, and SQL statement c. Then, the execution order is SQL statement b, SQL statement a, and SQL statement c. At this time, SQL statement c is the last SQL statement in SQL module A.
[0093] Step S110: If so, assemble the result identifiers of each SQL statement in the SQL module to obtain the target execution result, and return the target execution result to the client.
[0094] In this step, when the target SQL statement is the last SQL statement in the SQL module, the result identifiers of each SQL statement in the SQL module can be assembled and summarized to obtain the target execution result, and then the target execution result is returned to the client, that is, the response to the interface call instruction is completed.
[0095] It is understandable that after assembling the result identifier of each SQL statement in the SQL module and obtaining the target execution result, the interface calling method further includes: clearing the result identifier of each SQL statement in the SQL module. Therefore, there may be SQL statements in the SQL module whose result identifier is empty, that is, there are SQL statements with execution conditions but the execution conditions are not met.
[0096] Step S111: If not, return to the step of determining the target SQL statement to be executed currently and continue execution.
[0097] In this step, when the target SQL statement is not the last SQL statement in the SQL module, it is necessary to redetermine the next target SQL statement in the SQL module. Exemplarily, assuming that SQL module A has SQL statement a, SQL statement b and SQL statement c, and the order of the text structure from front to back (from top to bottom) is SQL statement b, SQL statement a and SQL statement c, then the execution order is SQL statement b, SQL statement a and SQL statement c. The target SQL statement determined for the first time is SQL statement b, and the target SQL statement b is processed. At this time, SQL statement b is not the last SQL statement in SQL module A, then the target SQL statement is redetermined to be SQL statement a, and the target SQL statement a is processed. At this time, SQL statement a is not the last SQL statement in SQL module A, then the target SQL statement is redetermined to be SQL statement c, and the target SQL statement c is processed. At this time, SQL statement c is the last SQL statement in SQL module A, and step 112 can be entered.
[0098] Step S112: When the target SQL statement has its corresponding execution condition and its corresponding execution condition is not satisfied, it is determined whether the target SQL statement is the last SQL statement in the SQL module.
[0099] For the description of this step, please refer to the description of step 109.
[0100] Step S111: If not, return to the step of determining the target SQL statement to be executed currently and continue execution.
[0101] Step S113: If yes, assemble the result identifier of each SQL statement in the SQL module to obtain the target execution result, and return the target execution result to the client.
[0102] For the description of this step, please refer to the description of step 110 .
[0103] Step S114: If the target interface model verification fails, the response to the interface call instruction is terminated and an alarm message is generated.
[0104] It is understandable that when the verification of the target interface model fails, at this time, the response to the interface call instruction for this time is stopped, and an alarm message is generated to indicate that the verification of the interface model fails.
[0105] Step S115: Return the alarm message to the client.
[0106] The generated alarm message is returned to the client so that the client can display and prompt the alarm message, enabling the staff to take relevant measures in a timely manner.
[0107] The interface call method, device, storage medium, and computer device provided by this application. The method includes: when the request parameters and request path in the interface call instruction are obtained, according to the request parameters and request path, it is judged whether the target interface model has been created and is in the startup state and passes the verification. If so, the target SQL statement is determined. When the target SQL statement has an execution condition and the execution condition is established, or when the target SQL statement has no execution condition, the target SQL statement is executed. And when there is a Groovy script in the target SQL statement, the Groovy script is used to process the execution result of the target SQL statement. Until it is determined that the target SQL statement is the last SQL statement in the SQL module, the execution results of each SQL statement in the SQL module are assembled to obtain the target execution result. When calling the interface, it is necessary to judge whether the execution condition of the target SQL statement exists and whether it is established, which can flexibly configure the actual execution order of the SQL statement. Thus, the flexibility of interface call is improved. Moreover, since the executed script is a Groovy script, when the Groovy script is modified, it is not necessary to redeploy the service, and the modified content can take effect, thereby improving the efficiency of interface call.
[0108] As Figure 2 shown, in one of the embodiments, the steps for creating the target interface model include:
[0109] Step S201: Receive a model creation instruction and obtain the creation parameters in the model creation instruction.
[0110] Among them, the creation parameters include interface name, interface path, request method, input parameter fields, and so on.
[0111] In this step, when an interface model needs to be created, the creation parameters can be input through the client. After the client collects the creation parameters input by the user, a model creation instruction will be generated according to the creation parameters and sent to the server. When the server receives the model creation instruction, it parses the model creation instruction to obtain the creation parameters.
[0112] Step S202: Determine the initial interface model.
[0113] The initial interface model is a preset interface template structure.
[0114] Step S203: Configure the interface name, interface path, request method, and input parameter fields for the initial interface model according to the creation parameters.
[0115] It can be understood that configuring the interface name, interface path, request method, and input parameter fields for the initial interface model may specifically include: respectively obtaining the field values of the fields corresponding to the interface name, interface path, request method, and input parameter fields in the creation parameters, respectively searching for the fields corresponding to the interface name, interface path, request method, and input parameter fields in the initial interface model, and respectively filling the field values of the fields corresponding to the interface name, interface path, request method, and input parameter fields in the creation parameters into the corresponding fields in the initial interface model.
[0116] Step S204: Determine at least one initial SQL statement and the execution order of each initial SQL statement to generate a target SQL module.
[0117] When creating an interface model, it is necessary to configure corresponding SQL statements for the interface model, which can be one or more. Therefore, in this step, it is necessary to determine at least one initial SQL statement and the execution order of each initial SQL statement, and then generate a target SQL module. It can be understood that the execution order of each initial SQL statement corresponds one-to-one with its position in the target SQL module. The actual execution order of the SQL statements also needs to consider whether the execution conditions exist and whether the execution conditions are met.
[0118] Step S205: Send the target SQL module to the client, and configure Groovy scripts and execution conditions for the initial SQL statements in the target SQL module according to the response data of the client.
[0119] In this step, the generated target SQL module is sent to the client so that the staff can select Groovy scripts for the SQL statements in the target SQL module and determine the execution conditions of the SQL statements in the target SQL module through the client.
[0120] Step S206: Save the configured target SQL module into the configured initial interface model, and determine the configured target SQL module as the SQL module of the configured initial interface model to obtain a new initial interface model.
[0121] In this step, save the configured target SQL module into the current initial interface model as the SQL module of the initial interface model to obtain a new initial interface model, and use the new initial interface model as the target interface model.
[0122] It can be understood that when generating the target interface model, not only the basic information of the target interface model needs to be configured, but also the Groovy script configuration and execution condition configuration are performed for the SQL statements in the SQL module. In this way, the flexibility of the target interface model can be improved, and thus the flexibility of interface calls can be improved. Moreover, by using the Groovy script, the modification can take effect without redeployment when the model is modified, and Java classes can be called. Furthermore, the efficiency of interface calls can be improved.
[0123] Step S207: Determine the new initial interface model as the target interface model.
[0124] In one embodiment, determining at least one initial SQL statement and the execution order of each initial SQL statement includes:
[0125] Determine the table model corresponding to the creation parameters;
[0126] According to the relationships between the tables in the table model, generate multiple SQL statements corresponding to the primary key of each table;
[0127] According to the creation parameters, determine at least one initial SQL statement from the multiple SQL statements corresponding to the primary key of each table, and determine the execution order of each initial SQL statement;
[0128] Generate the target SQL module based on the execution order of each initial SQL statement.
[0129] Among them, the table model refers to the entity model used to maintain the business, including the Chinese name, English name, field type, field precision, whether it is the primary key, whether it is non-null, foreign key, index, etc. of the field.
[0130] In this embodiment, generating multiple SQL statements corresponding to the primary key of each table means generating SQL statements for adding, deleting, modifying, and querying corresponding to the primary key of each table respectively according to the primary key of each table. Exemplarily, assuming the primary key is id, among the generated SQL statements, the SQL statement corresponding to the query operation is select * from table where id = #{id}. For the management of SQL statements and parameter passing, etc., the Mybatis framework can be used to implement.
[0131] It is understandable that the creation parameters also include a functional description of its corresponding interface. Based on the interface functional description and request method in the creation parameters, at least one initial SQL statement can be determined among multiple SQL statements corresponding to the primary key of each table, and the execution order of each initial SQL statement can be determined.
[0132] As Figure 3 shown, in one embodiment, judging whether the target interface model passes the verification according to the request parameters includes:
[0133] Step S301: Obtain each input parameter field of the target interface model.
[0134] Step S302: Compare each input parameter field of the target interface model with the corresponding field in the request parameters in sequence.
[0135] Among them, the objects for comparison are the data types of the corresponding fields.
[0136] In this step, each input parameter field of the target interface model and the corresponding field in the request parameters are compared in sequence. To ensure that the parameter fields correspond one by one and are consistent. It is understandable that consistent comparison means that the data types of the corresponding fields are the same. The comparison results include two cases. One is that the data types of the corresponding fields are the same, that is, the comparison is consistent; the other is that the comparison is inconsistent. Among them, the inconsistent comparison includes two cases. One is that the data types of the corresponding fields are different, and the other is that there is no corresponding field.
[0137] Exemplarily, assume that the target interface model A has two input parameter fields, which are input parameter field a (id) and input parameter field b (array[]) in sequence. At this time, if the fields in the request parameters are field c (userid) and field d (array[]) in sequence, compare input parameter field a with field c, and input parameter field b with field d. At this time, input parameter field a corresponds to field c and the data type comparison is consistent, and input parameter field b corresponds to field d and the data type comparison is consistent.
[0138] Step S303: Judge whether there is an input parameter field in the target interface model that is inconsistent with the corresponding field in the request parameters.
[0139] Step S304: If there is an input parameter field in the target interface model that is inconsistent with the corresponding field in the request parameters, it indicates that the target interface model fails the verification.
[0140] When there is an input parameter field in the target interface model that is inconsistent with the corresponding field in the request parameters, it means that there is a mismatch between the request parameters and the input parameter requirements of the target interface model. Therefore, the target interface model fails the verification.
[0141] Step S305: If each input parameter field of the target interface model is compared and consistent with the corresponding field in the request parameters, then determine whether the field values corresponding to each field with a preset condition in the request parameters all meet the preset condition corresponding to the field.
[0142] When each input parameter field of the target interface model is compared and consistent with the corresponding field in the request parameters, it is also necessary to determine whether the field values in the request parameters are all legal, that is, to determine whether the field values in the request parameters meet the preset conditions of the target interface model for the field values.
[0143] It can be understood that the preset condition can be a restriction on the field type or a restriction on the field format, and can be set according to actual needs. This application does not make specific restrictions on this.
[0144] Step S306: If the field values corresponding to each field with a preset condition in the request parameters all meet the preset condition corresponding to the field, it indicates that the verification of the target interface model passes.
[0145] Step S307: If the field value corresponding to a field in the request parameters does not meet its corresponding preset condition, it indicates that the verification of the target interface model fails.
[0146] It can be understood that the interface model is verified to ensure that the interface call request can normally call the interface. In this way, the probability of call failure can be reduced, and the practicability and robustness of the interface call method can be improved.
[0147] Such as Figure 4 shown, in one embodiment, determining whether the execution condition of the target SQL statement is established includes:
[0148] Step S401: Obtain the parameter fields in the execution condition of the target SQL statement.
[0149] Exemplarily, assume that the execution condition A is {$count>0}. At this time, $count is a variable. Obtain the parameter field count, and pass the current field value of the parameter field count into the execution condition A to determine whether the execution condition is met.
[0150] Step S402: Search for the field values corresponding to the parameter fields in the execution condition of the target SQL statement in the request parameters and the result identifier of the previous target SQL statement.
[0151] In this step, when the parameter fields in the execution condition of the target SQL statement are obtained, the field values corresponding to the parameter fields can be searched in the request parameters and the result identifier of the previous target SQL statement, so as to pass the found field values into the execution condition.
[0152] Step S403: Determine whether the field value corresponding to the parameter field in the execution condition of the target SQL statement satisfies the execution condition of the target SQL statement.
[0153] Step S404: If it is satisfied, determine that the execution condition of the target SQL statement is established.
[0154] Step S405: If it is not satisfied, determine that the execution condition of the target SQL statement is not established.
[0155] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are sequentially shown according to the indications of the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same moment, but can be executed at different moments. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least a part of other steps or steps or stages in other steps.
[0156] The interface calling device provided by the embodiments of the present application will be described below. The interface calling device described below can be correspondingly referred to the interface calling method described above.
[0157] As Figure 5 shown, the present application provides an interface calling device 500, and the device includes:
[0158] An instruction receiving module 501, configured to receive an interface calling instruction, and obtain a request parameter and a request path in the interface calling instruction;
[0159] A model verification module 502, configured to, when the target interface model has been created and is in an enabled state, determine whether the target interface model passes verification according to the request parameter; wherein, the target interface model is an interface model corresponding to the request path;
[0160] An SQL statement determination module 503, configured to, if the target interface model passes verification, determine a target SQL statement to be currently executed in the SQL module in the target interface model;
[0161] An SQL statement execution module 504, configured to execute the target SQL statement to obtain an execution result when it is determined that the target SQL statement has an execution condition and its execution condition is established, or when it is determined that the target SQL statement has no execution condition;
[0162] An execution result update module 505 is configured to determine whether there is a corresponding Groovy script for a target SQL statement. If there is a corresponding Groovy script for the target SQL statement, the Groovy script corresponding to the target SQL statement is executed to update the execution result.
[0163] A result identifier determination module 506 is configured to determine the execution result corresponding to the current target SQL statement as its corresponding result identifier.
[0164] A judgment module 507 is configured to determine whether the target SQL statement is the last SQL statement in the SQL module. If not, the process returns to the step of determining the target SQL statement to be executed currently and continues to execute. If so, the result identifiers of each SQL statement in the SQL module are assembled to obtain a target execution result, and the target execution result is returned to the client.
[0165] In one embodiment, the model verification module includes:
[0166] A parameter acquisition sub-module is configured to receive a model creation instruction and acquire creation parameters in the model creation instruction.
[0167] A model determination sub-module is configured to determine an initial interface model.
[0168] A first configuration sub-module is configured to configure an interface name, an interface path, a request method, and input parameter fields for the initial interface model according to the creation parameters.
[0169] An SQL statement determination sub-module is configured to determine at least one initial SQL statement and the execution order of each initial SQL statement to generate a target SQL module.
[0170] A second configuration sub-module is configured to send the target SQL module to the client and configure a Groovy script and an execution condition for the initial SQL statement in the target SQL module according to the response data of the client.
[0171] A model update sub-module is configured to save the configured target SQL module into the configured initial interface model and determine the configured target SQL module as the SQL module of the configured initial interface model to obtain a new initial interface model.
[0172] An interface model determination sub-module is configured to determine the new initial interface model as a target interface model.
[0173] In one embodiment, the SQL statement determination sub-module includes:
[0174] A table model determination unit is configured to determine a table model corresponding to the creation parameters.
[0175] An SQL statement generation unit, configured to generate multiple SQL statements corresponding to the primary key of each table according to the relationships between the tables in the table model;
[0176] An SQL statement determination unit, configured to determine at least one initial SQL statement from the multiple SQL statements corresponding to the primary key of each table according to the creation parameters, and determine the execution order of each initial SQL statement;
[0177] An SQL module generation unit, configured to generate a target SQL module based on the execution order of each initial SQL statement.
[0178] In one embodiment, the model verification module includes:
[0179] A first field acquisition sub-module, configured to acquire each input parameter field of the target interface model;
[0180] A field comparison sub-module, configured to sequentially compare each input parameter field of the target interface model with the corresponding field in the request parameters;
[0181] A first judgment sub-module, configured to indicate that the verification of the target interface model fails if there is an input parameter field in the target interface model that is inconsistent with the corresponding field in the request parameters;
[0182] A second judgment sub-module, configured to judge whether the field values corresponding to the fields with preset conditions in the request parameters all meet the preset conditions corresponding to the fields if each input parameter field of the target interface model is consistent with the corresponding field in the request parameters;
[0183] A third judgment sub-module, configured to indicate that the verification of the target interface model passes if the field values corresponding to the fields with preset conditions in the request parameters all meet the preset conditions corresponding to the fields;
[0184] A fourth judgment sub-module, configured to indicate that the verification of the target interface model fails if there is a field value corresponding to a field in the request parameters that does not meet the preset condition corresponding to the field.
[0185] In one embodiment, the SQL statement execution module includes:
[0186] A second field acquisition sub-module, configured to acquire the parameter fields in the execution condition of the target SQL statement;
[0187] A search sub-module, configured to search for the field value corresponding to the parameter field in the execution condition of the target SQL statement in the request parameters and the result identifier of the previous target SQL statement;
[0188] A fifth judgment sub-module, configured to judge whether the field value corresponding to the parameter field in the execution condition of the target SQL statement meets the execution condition of the target SQL statement;
[0189] A sixth judgment sub-module, configured to determine that the execution condition of the target SQL statement is established if it is satisfied;
[0190] A seventh judgment sub-module, configured to determine that the execution condition of the target SQL statement is not established if it is not satisfied.
[0191] In one embodiment, the interface calling device further includes:
[0192] A first judgment module, configured to judge whether the target SQL statement is the last SQL statement in the SQL module when the target SQL statement has its corresponding execution condition and the corresponding execution condition is not established;
[0193] A second judgment module, configured to return to the step of determining the target SQL statement to be executed currently and continue to execute if it is not;
[0194] A third judgment module, configured to assemble the result identifiers of each SQL statement in the SQL module to obtain a target execution result and return the target execution result to the client if it is.
[0195] In one embodiment, the interface calling device further includes:
[0196] An alarm information generation module, configured to terminate the response to the interface calling instruction and generate alarm information if the target interface model verification fails;
[0197] An alarm information sending module, configured to return the alarm information to the client.
[0198] The division of each module in the above interface calling device is only for illustrative purposes. In other embodiments, the interface calling device can be divided into different modules as needed to complete all or part of the functions of the above interface calling device. Each module in the above interface calling device can be implemented in whole or in part by software, hardware, and their combination. Each of the above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0199] In one embodiment, the present application further provides a storage medium, in which computer-readable instructions are stored. When the computer-readable instructions are executed by one or more processors, one or more processors are caused to execute the steps of the interface calling method as described in any one of the above embodiments.
[0200] In one embodiment, the present application further provides a computer device. Computer-readable instructions are stored in the computer device. When the computer-readable instructions are executed by one or more processors, the one or more processors are caused to execute the steps of the interface calling method according to any one of the above embodiments.
[0201] Schematically, as Figure 6 shown, Figure 6 is a schematic internal structure diagram of a computer device provided by an embodiment of the present application. The computer device 600 can be provided as a server. Referring to Figure 6 , the computer device 600 includes a processing component 602, which further includes one or more processors, and memory resources represented by a memory 601 for storing instructions executable by the processing component 602, such as application programs. The application programs stored in the memory 601 may include one or more modules each corresponding to a set of instructions. In addition, the processing component 602 is configured to execute instructions to perform the interface calling method of any of the above embodiments.
[0202] The computer device 600 may further include a power supply component 603 configured to perform power management of the computer device 600, a wired or wireless network interface 604 configured to connect the computer device 600 to a network, and an input / output (I / O) interface 605. The computer device 600 can operate based on an operating system stored in the memory 601, such as Windows Server TM, Mac OS XTM, Unix TM, Linux TM, Free BSDTM or the like.
[0203] Those skilled in the art can understand that Figure 6 the structure shown in
[0204] Finally, it should also be noted that in this text, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements not only includes those elements but also includes other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising a..." does not exclude the presence of additional identical elements in the process, method, article or device comprising said element. In this text, the singular forms "a", "an" and "the" may also include the plural unless the context clearly dictates otherwise. It should also be understood that the terms "comprising / including" or "having" etc. specify the presence of the stated features, wholes, steps, operations, components, parts or combinations thereof, but do not preclude the possibility of the presence or addition of one or more other features, wholes, steps, operations, components, parts or combinations thereof. At the same time, the term "and / or" used in this specification includes any and all combinations of the related listed items.
[0205] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referred to each other.
[0206] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but rather will be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An interface call method, characterized in that, The method includes: Receiving an interface call instruction, and obtaining the request parameters and request path in the interface call instruction; When the target interface model has been created and is in an enabled state, determining whether the target interface model passes the verification according to the request parameters; wherein, the target interface model is the interface model corresponding to the request path; If the target interface model passes the verification, determining the target SQL statement to be currently executed in the SQL module of the target interface model; When it is determined that the target SQL statement has an execution condition and the execution condition is satisfied, or when it is determined that the target SQL statement has no execution condition, executing the target SQL statement to obtain an execution result; Judging whether there is a corresponding Groovy script for the target SQL statement, if there is a corresponding Groovy script for the target SQL statement, executing the Groovy script corresponding to the target SQL statement to update the execution result; Determining the execution result corresponding to the current target SQL statement as its corresponding result identifier; Judging whether the target SQL statement is the last SQL statement in the SQL module, if not, returning to the step of determining the target SQL statement to be currently executed to continue execution, if so, assembling the result identifiers of each SQL statement in the SQL module to obtain a target execution result, and returning the target execution result to the client.
2. The interface call method according to claim 1, wherein The creation step of the target interface model includes: Receiving a model creation instruction, and obtaining the creation parameters in the model creation instruction; Determining an initial interface model; Configuring an interface name, an interface path, a request method, and input parameter fields for the initial interface model according to the creation parameters; Determining at least one initial SQL statement and the execution order of each initial SQL statement to generate a target SQL module; Sending the target SQL module to the client, and configuring a Groovy script and an execution condition for the initial SQL statement in the target SQL module according to the response data of the client; Saving the configured target SQL module into the configured initial interface model, and determining the configured target SQL module as the SQL module of the configured initial interface model to obtain a new initial interface model; Determining the new initial interface model as the target interface model.
3. The interface calling method according to claim 2, wherein The determining at least one initial SQL statement and the execution order of each initial SQL statement includes: Determining a table model corresponding to the creation parameters; Generating multiple SQL statements corresponding to the primary key of each table according to the relationship between the tables in the table model; Determining at least one initial SQL statement from the multiple SQL statements corresponding to the primary key of each table according to the creation parameters, and determining the execution order of each initial SQL statement; Generating the target SQL module based on the execution order of each initial SQL statement.
4. The interface call method according to claim 1, wherein The judging whether the target interface model passes the verification according to the request parameters includes: Obtaining each input parameter field of the target interface model; Compare each input parameter field of the target interface model with the corresponding field in the request parameters in sequence; If there is an input parameter field in the target interface model that is inconsistent with the corresponding field in the request parameters, it indicates that the verification of the target interface model fails; If each input parameter field of the target interface model is consistent with the corresponding field in the request parameters, determine whether the field values corresponding to each field with a preset condition in the request parameters all meet the preset condition corresponding to the field; If the field values corresponding to each field with a preset condition in the request parameters all meet the preset condition corresponding to the field, it indicates that the verification of the target interface model passes; If there is a field value corresponding to a field in the request parameters that does not meet the preset condition corresponding to it, it indicates that the verification of the target interface model fails.
5. The interface calling method according to any one of claims 1 to 4, characterized in that, Determining whether the execution condition of the target SQL statement holds includes: Obtain the parameter fields in the execution condition of the target SQL statement; Search for the field value corresponding to the parameter field in the execution condition of the target SQL statement in the request parameters and the result identifier of the previous target SQL statement; Determine whether the field value corresponding to the parameter field in the execution condition of the target SQL statement meets the execution condition of the target SQL statement; If it meets, determine that the execution condition of the target SQL statement holds; If it does not meet, determine that the execution condition of the target SQL statement does not hold.
6. The interface call method according to claim 1, wherein The method further includes: When the target SQL statement has its corresponding execution condition and the corresponding execution condition does not hold, determine whether the target SQL statement is the last SQL statement in the SQL module; If not, return to the step of determining the target SQL statement to be executed currently and continue to execute; If so, assemble the result identifiers of each SQL statement in the SQL module to obtain a target execution result, and return the target execution result to the client.
7. The interface call method according to claim 1, wherein The method further includes: If the verification of the target interface model fails, terminate the response to the interface call instruction and generate an alarm message; Return the alarm message to the client.
8. An interface calling device, characterized in that, The device includes: An instruction receiving module, configured to receive an interface call instruction, and obtain the request parameters and request path in the interface call instruction; A model verification module, configured to, when the target interface model has been created and is in an enabled state, determine whether the target interface model passes verification according to the request parameters; wherein, the target interface model is the interface model corresponding to the request path; An SQL statement determination module, configured to, if the target interface model passes verification, determine the target SQL statement to be executed currently in the SQL module in the target interface model; An SQL statement execution module, configured to execute the target SQL statement to obtain an execution result when it is determined that the target SQL statement has an execution condition and the execution condition holds, or when it is determined that the target SQL statement has no execution condition; An execution result update module, configured to determine whether there is a corresponding Groovy script for the target SQL statement. If there is a corresponding Groovy script for the target SQL statement, execute the Groovy script corresponding to the target SQL statement to update the execution result; A result identifier determination module, configured to determine the execution result corresponding to the current target SQL statement as its corresponding result identifier; A judgment module, configured to judge whether the target SQL statement is the last SQL statement in the SQL module. If not, return to the step of determining the target SQL statement to be executed currently and continue to execute. If so, assemble the result identifiers of each SQL statement in the SQL module to obtain a target execution result, and return the target execution result to the client.
9. A storage medium, characterized in that: The storage medium stores computer-readable instructions, which when executed by one or more processors, cause the one or more processors to execute the steps of the interface calling method according to any one of claims 1 to 7.
10. A computer device, characterized in that, Including: One or more processors, and a memory; The memory stores computer-readable instructions, which when executed by the one or more processors, execute the steps of the interface calling method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Data synchronization processing method, device and apparatus and storage medium
CN112380180A
History preserving data pipeline system and method
US9229952B1