Interface implementation method, electronic equipment, storage medium and program product

By automatically determining the server-side function and processing parameters through the interface implementation method, the problem of low development efficiency of web-side and server-side interfaces is solved, and efficient and reliable cross-language interface calls are achieved.

CN120909575AActive Publication Date: 2025-11-07INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202511446101.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-10
Publication Date
2025-11-07
Estimated Expiration
2045-10-10

AI Technical Summary

Technical Problem

In existing technologies, the development efficiency of interfaces between web pages and servers is low, requiring manual writing of corresponding interface code and handling of type compatibility issues in cross-language calls.

Method used

This provides an interface implementation method that receives the target request object, determines the target server function based on the classpath identifier and function identifier, obtains the parameter object, executes the function and encapsulates the response object, and automatically completes the request parsing and result return using standardized specifications, reducing the amount of repetitive development work.

Benefits of technology

It improves the efficiency of interface development, avoids repetitive work of manually writing interface code, reduces the risk of spelling errors and format incompatibility, and enhances the reliability and consistency of cross-language interface calls.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120909575A_ABST
    Figure CN120909575A_ABST
Patent Text Reader

Abstract

The invention discloses an interface implementation method, electronic equipment, a storage medium and a program product, and relates to the technical field of computers, a target request object sent by a target webpage end is received, and the target request object comprises a target class path identifier, a target function identifier and target parameter information; according to the target class path identifier and the target function identifier, determining a target function corresponding to the target server, the target function being used for realizing a business logic corresponding to the target server; obtaining a target parameter object according to the target parameter information; based on the target parameter object and the target function, determining an execution result corresponding to the target function; and packaging the execution result into a response object, and returning the response object to the target webpage end. The interface development efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, and particularly relates to an interface implementation method, an electronic device, a storage medium and a program product. BACKGROUND

[0002] The communication interface between the webpage end and the server end is interacted to complete storage resource allocation, fault diagnosis, performance optimization and the like.

[0003] In the related art, the developer needs to manually write the interface code of the corresponding webpage end for each Java interface of the server end, pass the parameters through the request and parse the response result. And the data format of the webpage end and the server end needs to be strictly matched, and the type compatibility problem in cross-language calling needs to be handled. Therefore, the efficiency of interface development is low. SUMMARY

[0004] The present application provides an interface implementation method, an electronic device, a storage medium and a program product to at least solve the problem of low efficiency of interface development in the related art.

[0005] In a first aspect, the present application provides an interface implementation method, comprising:

[0006] receiving a target request object sent by a target webpage end, the target request object comprising a target class path identifier, a target function identifier and target parameter information;

[0007] determining a target function corresponding to a target server according to the target class path identifier and the target function identifier, the target function being used to implement the business logic corresponding to the target server;

[0008] obtaining a target parameter object according to the target parameter information;

[0009] obtaining an execution result corresponding to the target function based on the target parameter object and the target function;

[0010] encapsulating the execution result into a response object, and returning the response object to the target webpage end.

[0011] In a second aspect, the present application further provides an interface implementation device, comprising a receiving module, a first determining module, an obtaining module, a second determining module, an encapsulating module and a sending module, wherein,

[0012] The receiving module is configured to receive a target request object sent by a target webpage end, the target request object comprising a target class path identifier, a target function identifier and target parameter information;

[0013] The first determining module is configured to determine a target function corresponding to a target service end according to the target class path identifier and the target function identifier, the target function being used to implement business logic corresponding to the target service end.

[0014] The obtaining module is configured to obtain a target parameter object according to the target parameter information.

[0015] The second determining module is configured to determine an execution result corresponding to the target function based on the target parameter object and the target function.

[0016] The packaging module is configured to package the execution result into a response object.

[0017] The sending module is configured to return the response object to the target web end.

[0018] In a third aspect, the present application further provides an electronic device, including a memory configured to store a computer program, and a processor configured to execute the computer program to implement the steps of the interface implementation method.

[0019] In a fourth aspect, the present application further provides a computer readable storage medium, and the computer readable storage medium stores a computer program, wherein the computer program is executed by a processor to implement the steps of the interface implementation method.

[0020] In a fifth aspect, the present application further provides a computer program product, including a computer program, and the computer program is executed by a processor to implement the steps of the interface implementation method.

[0021] By the interface implementation method, the electronic device, the storage medium and the program product provided in the present application, the request object sent by the target web end can be received, the request object including the target class path identifier, the target function identifier and the target parameter information; the target function corresponding to the target service end is determined according to the request object; the target parameter object is obtained according to the target parameter information; the target function is executed based on the target parameter object to obtain an execution result; the execution result is packaged into a response object, and the response object is returned to the target web end. Without manually repeatedly writing the docking code between the web end and the service end for each interface, the request analysis to the result return can be automatically completed only by relying on the standardized specification defined in advance, the repeated development workload is reduced, and the interface development efficiency is effectively improved. BRIEF DESCRIPTION OF DRAWINGS

[0022] In order to more clearly illustrate the embodiments of the present application, the drawings needed in the embodiments will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0023] Figure 1 A schematic diagram of an application scenario provided for an embodiment of the present application is shown in

[0024] Figure 2 A flowchart of an interface implementation method provided for an embodiment of the present application is shown in

[0025] Figure 3 A flowchart of another interface implementation method provided for an embodiment of the present application is shown in

[0026] Figure 4 A flowchart of a target request function generation method provided for an embodiment of the present application is shown in

[0027] Figure 5 A structural diagram of an interface implementation apparatus provided for an embodiment of the present application is shown in

[0028] Figure 6 A structural diagram of an electronic device provided for an embodiment of the present application is shown in DETAILED DESCRIPTION

[0029] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, any other embodiments obtained by those skilled in the art without creative work fall within the protection scope of the present application.

[0030] It should be noted that, in the description of the present application, the terms “include”, “contain” or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. The terms “first”, “second” and the like in the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence.

[0031] Figure 1 A schematic diagram of an application scenario provided for an embodiment of the present application is shown in Figure 1 , including a webpage end 101 and a server end 102. The webpage end 101 can run in a user browser. The server end 102 is deployed on an application server node, and is used to run interface processing logic and connect to a storage array system through an internal interface to call underlying storage resources. The interface processing logic can include receiving a webpage end request, executing a Java function, etc.

[0032] The development languages between the webpage end 101 and the server end 102 are different, and the running environments are different. For example, the development language of the webpage end 101 can be JavaScript, and the development language of the server end 102 can be Java. The webpage end 101 and the server end 102 need to interact through a communication interface to complete operations such as storage resource allocation, fault diagnosis, and performance optimization. The communication interface can be a WEB interface.

[0033] In the related art, the developer needs to manually write the interface code of the webpage end corresponding to the Java interface of each server end, pass parameters through an HTTP request, and parse the response result. The data formats of the webpage end and the server end (for example, the conversion between JSON and Java objects) need to be strictly matched, and the type compatibility problem in cross-language calling needs to be handled, which leads to low efficiency of interface development.

[0034] The interface implementation method provided by the embodiment of the application can receive a request object sent by a target webpage end, the request object including a target class path identifier, a target function identifier, and target parameter information; determine a target function corresponding to a target server end according to the request object; obtain a target parameter object according to the target parameter information; execute the target function based on the target parameter object to obtain an execution result; encapsulate the execution result into a response object, and return the response object to the target webpage end.

[0035] The above execution process does not need to manually write the docking code between the webpage end and the server end for each interface repeatedly, but can automatically complete the request analysis to the result return only by relying on the standardized specification defined in advance, reduces the repeated development workload, and effectively improves the interface development efficiency.

[0036] Figure 2 A flowchart of an interface implementation method provided by the embodiment of the application is shown. Please refer to Figure 2 The method can include the following steps.

[0037] S201, receiving a target request object sent by a target webpage end.

[0038] The target webpage end and the target server end can communicate through a unified public interaction specification (that is, a public interface). The public interaction specification can define the request format, field meaning, and communication protocol. The target webpage end and the target server end can implement the specification through specific functions respectively.

[0039] The target webpage end can encapsulate and send the target request object through a jsCommonWebAPI function, and the target server end can receive and parse the request through a javaCommonWebAPI function.

[0040] The target webpage end can call a jsCommonWebAPI function to send a target request object. The target request object can include three key fields: a target class path identifier, a target function identifier, and target parameter information.

[0041] The target class path identifier can be denoted as javaClass and is of a string type, used to indicate the complete path of a target Java class. The target Java class can include a business processing class of a target function, and the target class path identifier locates the target Java class through the complete path, providing a basis for subsequent matching of the target function.

[0042] The target function identifier can be denoted as apiName and is of a string type, used to indicate the function name of the target function to be called in the target Java class.

[0043] The target parameter information can be denoted as apiParams and is of a JSON array type, and can include a parameter list of all parameter values required for calling the target function, wherein the number and order of the parameters need to be consistent with the parameter definition of the target function to be called in the target Java class.

[0044] S202, determine a target function corresponding to the target service end according to the target class path identifier and the target function identifier.

[0045] The target function can be used to implement the business logic of the target service end, for example, the business logic can be storage resource allocation, fault diagnosis, etc.

[0046] In some possible embodiments, the target function can be determined in the following manner: at least one execution function can be determined according to the target class path identifier and the target function identifier; if the at least one execution function is one, the execution function is determined as the target function; if the at least one execution function is multiple, the target function is determined from the multiple execution functions according to the target parameter information.

[0047] The target class path identifier is the complete path of a Java class, including the package name and the class name, and has uniqueness; the target function identifier is a specific function name.

[0048] Specifically, the target class corresponding to the target class path identifier can be determined, and the target class includes multiple functions; the target function identifier is used to perform matching processing on the multiple functions, to obtain at least one execution function.

[0049] The target class path identifier can be used to accurately find the corresponding target class. All functions consistent with the target function identifier can be scanned out in the target class, that is, at least one execution function.

[0050] When there are overloaded functions in the Java function, the overloaded functions can be selected according to the target class path identifier and the target function identifier, to form multiple execution functions. The overloaded functions refer to multiple functions with the same name in the same class, but with different numbers or types of parameters.

[0051] In the present application, when the target function cannot be uniquely determined according to the target class path identifier and the target function identifier, the target function can be further accurately matched in the multiple execution functions through the target parameter information, which can improve the uniqueness and accuracy of function matching, and can also avoid the ambiguity of function call caused by function overloading.

[0052] The target parameter information can include parameter values of multiple parameters.

[0053] In some possible embodiments, the target function can also be determined by the following method: according to the target class path identifier, the target function identifier and the target parameter information, the target function is obtained from the multiple historical functions in the cache; wherein the cache further includes the heat values corresponding to the historical functions, and the heat values corresponding to the historical functions are greater than or equal to a preset threshold.

[0054] Specifically, the cache further includes the historical class path identifiers, the historical function identifiers and the historical parameter information corresponding to the historical functions, the target class path identifier, the target function identifier and the target parameter information can be matched with the historical class path identifiers, the historical function identifiers and the historical parameter information corresponding to the historical functions, and the matched historical function is determined as the target function.

[0055] If there is no target function corresponding to the target class path identifier, the target function identifier and the target parameter information in the multiple historical functions, another method for determining the target function mentioned above can be used.

[0056] When the heat value is less than the preset threshold, the historical function can be deleted from the cache.

[0057] When the target function not stored in the cache appears, after the target function is determined, the target function and the target class path identifier, the target function identifier and the target parameter information corresponding to the target function can be directly stored in the cache, and the heat value thereof can be set to an initial threshold value greater than the preset threshold value.

[0058] After the target function is determined each time, the heat values of the historical functions can be updated: if there is a historical function determined as the target function, the heat value of the historical function can be increased; for other historical functions not selected, the heat value thereof can be reduced if the historical function has not been selected for a preset period.

[0059] The setting of the initial threshold value needs to be combined with the preset threshold value and the service scenario (for example, the initial threshold value of the high-frequency service scenario can be 1.5 times the preset threshold value, and the initial threshold value of the low-frequency scenario can be 1.1 times the preset threshold value), which can balance the cache utilization rate and the high-frequency function retention rate.

[0060] In the present application, the historical function can be stored in the cache, and the target function does not need to be determined according to the target class path identifier and the target function identifier, which can improve the efficiency of obtaining the target function, and further improve the efficiency of obtaining the response object.

[0061] S203, obtaining a target parameter object according to the target parameter information.

[0062] The target parameter object is a Java object collection that can be directly used when the target function is executed on the target server, and the target parameter object includes at least one parameter required by the target function, wherein the type and value of each parameter need to meet the parameter definition of the target function.

[0063] In some possible embodiments, the target parameter format and the parameter type corresponding to the target function can be obtained; the parameters in the target parameter information are converted and processed according to the target parameter format and the parameter type, to obtain the target parameter object.

[0064] The target parameter format can indicate the parameter structure requirement of the target function, including the number and order of parameters. For example, the parameter format of the target function createVolume(String name, int capacity) is "2 parameters, in order, string type and integer type.

[0065] The parameter type can be used to indicate the specific Java type of each parameter of the target function, which is usually obtained by reflecting the getType() method of the target function Parameter array. For example, the Java type can be java.lang.String, int, and a custom class com.web.api.CreateVolumeParam.

[0066] The target parameter information is the original parameter data (usually in JSON format, which can include strings, numbers, object references, etc.) transmitted by the target web page, which needs to be converted according to the target parameter format and the parameter type.

[0067] If the target parameter information is basic type data, type conversion is performed. For example, if the string 100 transmitted by the target web page corresponds to the int type parameter of the target function, the JSON string 100 is converted to the Java int type 100.

[0068] If the target parameter information is object type data, object mapping is performed. For example, if a JSON object containing name and capacity fields is passed by the target web page, and the object corresponds to the custom CreateVolumeParam type parameter of the target function, an instance of the class specified by the parameter type is created according to the Java class path, and the field values of the JSON object are assigned to the corresponding properties of the instance.

[0069] If the target parameter information does not match the format, a parameter verification exception is triggered, the conversion process is interrupted, and an error prompt is returned. The format mismatch can be missing parameter number or incorrect field name.

[0070] All converted parameters can be assembled according to the parameter order of the target function to form a target parameter object that can be directly passed into the target function for execution. The target parameter object can usually be an Object[] array, and the array element type corresponds to the target function parameter type one by one.

[0071] In this application, the target parameter information can be converted and processed according to the parameter format and parameter type of the target function, which can ensure that the converted target parameter object fully meets the execution requirements of the target function, avoid parameter incompatibility problems caused by cross-language data format differences, and improve the accuracy of parameter transmission and the stability of target function execution.

[0072] S204, based on the target parameter object and the target function, the execution result corresponding to the target function is obtained.

[0073] The target function can be executed based on the target parameter object by the target service side to obtain the execution result.

[0074] Before executing the target function, the target service side can perform secondary verification on the target parameter object through the reflection mechanism: check whether the parameter array length is consistent with the parameter number of the target function; check whether the actual type of each parameter is compatible with the parameter type declared by the target function; if the verification fails, directly throw an IllegalArgumentException (parameter mismatch exception) to terminate the execution.

[0075] The target service side can call the target function through reflection: if the target function is a static method (static), the target service side calls Method.invoke (null, target parameter object) through reflection, where null indicates that no instance object is needed; if the target function is an instance method, the target service side uses an instance object of the class as a calling carrier to execute Method.invoke (instance object, target parameter object); if a business exception (such as insufficient resources) is thrown during function execution, the target service side captures and retains the exception information as part of the execution result.

[0076] After the target function is executed, the target server obtains the return value as the final execution result.

[0077] S205, encapsulate the execution result as a response object, and return the response object to the target web page.

[0078] In some possible embodiments, error codes, error descriptions, and return data in the execution result are extracted; the error codes, error descriptions, and return data are encapsulated to obtain a response object.

[0079] If the target function is executed normally, the return value is extracted, the error code is set to a success identifier by default, and the error description is empty; if there is an exception in the execution process, the error description is extracted from the exception object, and a corresponding error code is matched according to the exception type, and the return data is empty.

[0080] The response object can be in a preset format, for example, the response object is in a preset format of a JSON format, and includes three fixed fields: errorCode (a numerical type): 0 indicates successful execution, and a non-0 value indicates an exception (different numerical values correspond to different exception types, for example, 1001 indicates a parameter error, and 2001 indicates a business logic error); message (a string type): null or an empty string when successful, and a specific error description (for example, “parameter number mismatch” or “insufficient storage space”) when an exception occurs; and data (an arbitrary type): the return value of the target function (for example, a string or a JSON object converted from a Java object) when successful, and null when an exception occurs.

[0081] The error code and the error description are related to specific applications, and therefore, the embodiments of the present application only provide an example, without limiting the specific error code and the error description.

[0082] After the target web page obtains the response object, the target web page can parse the object through a jsCommonWebAPI function, and determine the execution result according to the errorCode. For example, if the execution is successful, the data is processed, and if the execution fails, the message is displayed.

[0083] In the present application, the standardized response object format enables the web page to uniformly parse the server return result, without separately processing the success / exception scenarios for different interfaces, reduces the analysis logic development of the web page, and further improves the efficiency and consistency of interface interaction.

[0084] The interface implementation method provided by the embodiments of the present application can determine the target function corresponding to the target server according to the target class path identifier, the target function identifier and the target parameter information in the target request object, obtain a target parameter object according to the target parameter information, execute the target function based on the target parameter object, obtain an execution result, encapsulate the execution result into a response object, and return the response object to the target web page end. The interface development efficiency is improved, and the repeated development workload is reduced, without manually repeatedly writing the docking code between the web page end and the server for each interface.

[0085] Figure 3 The flowchart of another interface implementation method provided by the embodiments of the present application is shown in FIG. 3. Figure 3 The method can include the following steps.

[0086] S301, receiving a target request object sent by a target web page end.

[0087] The execution process of S301 can refer to the execution process of S201, which is not described here again.

[0088] S302, determining at least one execution function according to the target class path identifier and the target function identifier.

[0089] The execution process of S302 can refer to the execution process of S202, which is not described here again.

[0090] S303, if the at least one execution function is one, determining the execution function as the target function.

[0091] For example, it is assumed that there are three execution functions, which are execution function A, execution function B and execution function C, the number of parameters of the execution function A and the execution function B is 2, and the number of parameters of the execution function C is 3; it is assumed that the target parameter information includes three parameters, so that the execution function C can be determined as an intermediate function and can be directly used as the target function through parameter quantity screening.

[0092] S304, if the at least one execution function is multiple, determining the target function in the multiple execution functions according to the target parameter information.

[0093] Specifically, the number of parameter values of the multiple parameters in the target parameter information and the parameter types corresponding to the parameters can be determined; at least one intermediate function can be determined in the multiple execution functions according to the number of parameter values; if the at least one intermediate function is one, the intermediate function is determined as the target function; if the at least one intermediate function is multiple, the multiple parameter types corresponding to the intermediate functions are matched according to the parameter types corresponding to the parameters, a matching result is obtained, and the target function is determined based on the matching result.

[0094] For example, the parameter type can be int or String.

[0095] When the number of parameters is the same, the parameter types of each parameter will also be different. Therefore, by determining the number of parameters and the parameter types of each parameter, the corresponding objective function can be uniquely matched.

[0096] Specifically, based on the parameter types corresponding to each parameter, the first type sequence corresponding to each parameter can be determined; the second type sequence corresponding to multiple parameter types of each intermediate function can be determined; and the first type sequence can be matched with the second type sequence corresponding to each intermediate function to obtain the matching result.

[0097] The second type sequence of each intermediate function is matched with the first type sequence of the target parameter information, and the intermediate function that matches completely (i.e., the matching result) is determined as the target function.

[0098] For example, suppose there are three execution functions: function A, function B, and function C. Functions A and B have two parameters each, while function C has three parameters. If the target parameter information includes two parameters, then by filtering based on the number of parameters, functions A and B are determined to be intermediate functions. Further, suppose the first type sequence corresponding to each parameter in the target parameter information is {int, String}, and the second type sequence of function A is {int, String}, while the second type sequence of function B is {String, int}. Then, function A is matched as the target function.

[0099] In this application, when there are multiple intermediate functions, the target function can be further determined by the parameter type, which can achieve precise matching of overloaded functions, avoid call failures caused by parameter type mismatch, and improve the reliability of cross-language interface calls.

[0100] S305. Obtain the target parameter format and parameter type corresponding to the target function.

[0101] S306. Based on the target parameter format and parameter type, perform conversion processing on the parameters in the target parameter information to obtain the target parameter object.

[0102] The execution process of S305-S306 can be found in the execution process of S203, and will not be repeated here.

[0103] S307. Based on the target parameter object and the target function, obtain the execution result corresponding to the target function.

[0104] The execution process of S307 can be found in the execution process of S204, and will not be repeated here.

[0105] S308, extract the error code, error description and return data in the execution result.

[0106] S309, encapsulate the error code, error description and return data to obtain a response object, and the response object is in a preset format.

[0107] S310, return the response object to the target web page end.

[0108] The execution process of S308-S310 can refer to the execution process of S205, which will not be described here.

[0109] The interface implementation method provided by the embodiment of the application can ensure that the target function can be uniquely located through preliminary screening of the number of parameters and accurate matching of the parameter type sequence, effectively avoids the call failure caused by parameter mismatch, and significantly improves the reliability of cross-language interface call. Moreover, the standardized rules are executed, and there is no need to repeatedly develop the interface code for each interface, which greatly reduces the manual workload of the developer and reduces the risk of spelling errors, format incompatibility and other problems caused by manual coding.

[0110] The server can provide multiple interfaces for the web page end, and each interface has its corresponding function to be called to perform business logic. For any one interface, a corresponding request function can be generated, and when the web page end makes a request, the request object can be encapsulated through the request function and sent to the target server, and the function corresponding to the business logic can be triggered through the request function. On the basis of the above embodiment, the following will be described in combination with Figure 4 The execution process of generating the target request function provided by the embodiment of the application is described.

[0111] Figure 4 A flowchart for generating a target request function is provided for the embodiment of the application. Please refer to Figure 4 The method can include:

[0112] S401, obtaining interface information corresponding to the target server.

[0113] The interface information is the interface metadata provided by the server for the web page end, which is used for the web page end to automatically generate the calling code, including: the target class path identifier of the class where the interface is located, the target function identifier (function name) of the interface function, and the target parameter information (parameter number, type and other definition information) of the function.

[0114] Determining the target class path identifier can be divided into the following three cases:

[0115] Case 1: The interface class is concentrated in a single package (for example, the web.api package).

[0116] Locate all Java classes in the directory corresponding to the package name (convert the package name to a directory separator, such as web.api to web / api directory), extract the class name by combining the "class name and file name are the same" feature, and then connect the package name and class name with a "." (such as web.api.VolumeService), which is the target class path identifier.

[0117] Case two: interface classes are scattered in multiple known packages.

[0118] Perform the process of case one for each package to extract the target class path identifier one by one.

[0119] Case three: interface classes are stored irregularly (unknown package path).

[0120] By reading the server's preset configuration file (which records the complete class path of all interface classes), the target class path identifier is directly obtained.

[0121] Further, the target function identifier and target parameter information can be obtained in the instance object corresponding to the target function.

[0122] For each target class path identifier corresponding Java class, create an instance object of the class through the reflection mechanism (or directly parse the class metadata, as the interface function is mostly public static, no need to instantiate), filter out all public static functions (preset as external interface functions), and extract the target function identifier and target parameter information.

[0123] Among them, the target function identifier is the name of the function (such as createVolume); the target parameter information is the number of parameters, parameter types (such as [String, int]), and class path of object type parameters (such as the class path of the custom parameter CreateVolumeParam).

[0124] In this application, through automatic parsing of package path and configuration file backup, interface information can be obtained without manual sorting of class path and function definition, which not only adapts to interface classes with different storage methods, but also ensures the completeness and accuracy of information extraction, improves the automation and efficiency of interface information acquisition, and provides a reliable data source for subsequent web page code generation.

[0125] S402, according to the interface information, generate a target request function corresponding to the target request object.

[0126] The target request function is a JavaScript function on the webpage side, which encapsulates a target request object (including class path, function name, and parameters) and sends a request to the server, thereby triggering the business logic corresponding to the server target function (such as storage resource allocation).

[0127] In some possible embodiments, the interface information can be standardized to obtain preset structure data, and the preset structure data includes interface data and object data; and the target request function is generated according to the interface data and the object data.

[0128] The interface information extracted from the server can be formatted to generate preset structure data including interface data and object data.

[0129] The object data can be an objs array, which records the class name and class path of all object type parameters. For example, {"objName":"CreateVolumeParam","javaClass":"com.web.api.CreateVolume Param"}.

[0130] The interface data can be an APIs array, which records the class name, class path, and included function name according to the Java class dimension. For example, {"className":"VolumeService","classPath":"com.web.api.Volume Service","funs":["createVolume","deleteVolume"]}.

[0131] Further, the preset object template and the preset interface template can be obtained; the object data is format-converted according to the preset object template to generate a webpage-side object corresponding to the target function; the interface data is format-converted according to the preset interface template to generate a webpage-side interface corresponding to the target function; and the webpage-side object and the webpage-side interface are spliced to obtain the target request function.

[0132] The webpage-side object can be generated according to the preset object template (defining the basic structure of a JavaScript class), and the object data is parsed to generate a corresponding JavaScript class for each object type parameter. The class name is consistent with the objName, and includes the javaClass attribute (value is the corresponding Java class path), which ensures that the server can correctly convert the parameter type.

[0133] Generating a web page interface: according to a preset interface template (defining a uniform format of function encapsulation), the APIs array is parsed, and a corresponding JavaScript object (mounted under the global variable javaAPI) is generated for each Java class. The object contains a method with the same name as the Java function, and the method internally encapsulates the request information (class path, function name, and parameters) through the jsCommonWebAPI function.

[0134] Assembling a target request function: the generated web page object (such as the CreateVolumeParam class) and the web page interface (such as the javaAPI.VolumeService.createVolume method) are integrated to form a complete target request function. The web page can directly create a parameter object through new CreateVolumeParam() and call javaAPI.VolumeService.createVolume(param) to send a request.

[0135] In this application, the target request function can be automatically generated through standardized data formats, preset object templates, and preset interface templates, without the need for developers to manually write web page and server-side interface code. This not only avoids problems such as function name spelling errors and parameter format mismatches that may occur during manual coding, but also enables quick synchronization of new web page code when the server-side interface is updated, significantly improving interface development efficiency and consistency.

[0136] The interface implementation method provided by the embodiments of the present application can automatically generate request functions of the web page according to the interface information corresponding to the server, not only reducing the repetitive workload of cross-language interface development, but also reducing the risk of interface incompatibility caused by manual intervention through standardized processes, ultimately achieving the development efficiency improvement and stability guarantee of the storage resource management system (or similar cross-language interaction system).

[0137] Figure 5 A structural diagram of an interface implementation device provided by an embodiment of the present application is provided. Please refer to Figure 5 The interface implementation device 500 can include a receiving module 501, a first determining module 502, a first obtaining module 503, a second determining module 504, an encapsulating module 505, and a sending module 506, wherein

[0138] The receiving module 501 is configured to receive a target request object sent by a target web page, the target request object including a target class path identifier, a target function identifier, and target parameter information.

[0139] The first determining module 502 is configured to determine a target function corresponding to a target server according to the target class path identifier and the target function identifier, the target function being used to implement a business logic corresponding to the target server.

[0140] The first obtaining module 503 is configured to obtain a target parameter object according to target parameter information.

[0141] The second determining module 504 is configured to determine an execution result corresponding to the target function based on the target parameter object and the target function.

[0142] The packaging module 505 is configured to package the execution result into a response object.

[0143] The sending module 506 is configured to return the response object to the target web page end.

[0144] In some possible embodiments, the first determining module 502 is specifically configured to:

[0145] determine at least one execution function according to the target class path identifier and the target function identifier;

[0146] if the at least one execution function is one, determine the execution function as the target function;

[0147] if the at least one execution function is a plurality of execution functions, determine the target function from the plurality of execution functions according to the target parameter information.

[0148] In some possible embodiments, the first determining module 502 is specifically configured to:

[0149] determine a parameter quantity of a plurality of parameter values in the target parameter information, and a parameter type corresponding to each parameter;

[0150] determine at least one intermediate function from the plurality of execution functions according to the parameter quantity;

[0151] if the at least one intermediate function is one, determine the intermediate function as the target function;

[0152] if the at least one intermediate function is a plurality of intermediate functions, perform matching processing on a plurality of parameter types corresponding to each intermediate function according to the parameter type corresponding to each parameter, obtain a matching processing result, and determine the target function based on the matching processing result.

[0153] In some possible embodiments, the first determining module 502 is specifically configured to:

[0154] determine a first type sequence corresponding to each parameter according to the parameter type corresponding to each parameter;

[0155] determine a second type sequence of a plurality of parameter types corresponding to each intermediate function;

[0156] perform matching processing on the first type sequence and the second type sequence corresponding to each intermediate function, and obtain a matching processing result.

[0157] In some possible embodiments, the first determining module 502 is specifically configured to:

[0158] determine a target class corresponding to the target class path identifier, the target class including a plurality of functions;

[0159] perform matching processing on the plurality of functions through the target function identifier, to obtain at least one execution function.

[0160] In some possible embodiments, the first obtaining module 503 is specifically configured to:

[0161] obtain a target parameter format and a parameter type corresponding to the target function;

[0162] perform conversion processing on a parameter in the target parameter information according to the target parameter format and the parameter type, to obtain a target parameter object.

[0163] In some possible embodiments, the encapsulating module 505 is specifically configured to:

[0164] extract an error code, an error description, and return data in the execution result;

[0165] perform encapsulation processing on the error code, the error description, and the return data, to obtain a response object, the response object being in a preset format.

[0166] In some possible embodiments, the apparatus further includes a second obtaining module and a generating module:

[0167] the second obtaining module is configured to obtain interface information corresponding to a target server;

[0168] the generating module is configured to generate a target request function corresponding to a target request object according to the interface information, the target request function being used for encapsulating the target request object and sending the target request object to the target server, to trigger a business logic corresponding to the target function.

[0169] In some possible embodiments, the generating module is specifically configured to:

[0170] perform standardization processing on the interface information, to obtain preset structure data, the preset structure data including interface data and object data;

[0171] generate the target request function according to the interface data and the object data.

[0172] In some possible embodiments, the generating module is specifically configured to:

[0173] obtain a preset object template and a preset interface template;

[0174] perform format conversion processing on the object data according to the preset object template, to generate a web page end object corresponding to the target function;

[0175] According to the preset interface template, the interface data is processed for format conversion, and a webpage interface corresponding to the target function is generated.

[0176] The webpage end object and the webpage end interface are spliced to obtain the target request function.

[0177] In some possible embodiments, the second obtaining module is specifically configured to:

[0178] Determine the target class path identifier based on the storage data packet corresponding to the target service end;

[0179] Obtain the target function identifier and the target parameter information in the instance object corresponding to the target function.

[0180] In some possible embodiments, the second obtaining module is specifically configured to:

[0181] If the storage data packet is one or more, the target class path identifier is extracted from the storage data packet;

[0182] If the storage data packet is an unknown package path, a configuration file corresponding to the target service end is obtained, and the target class path identifier is obtained in the configuration file.

[0183] The description of the features in the embodiments of the interface implementation device can be referred to the related description of the embodiments of the interface implementation method, which will not be repeated here.

[0184] Figure 6 A structural schematic diagram of an electronic device is provided in the present application. As shown in Figure 6 The electronic device 600 provided in the present embodiment includes at least one processor 601 and a memory 602. Optionally, the electronic device 600 further includes a communication component 603. The processor 601, the memory 602 and the communication component 603 are connected through a bus.

[0185] In the specific implementation process, the at least one processor 601 executes the computer execution instructions stored in the memory 602, so that the at least one processor 601 executes the interface implementation method embodiments described above.

[0186] The specific implementation process of the processor 601 can be referred to the above method embodiments, which has similar implementation principles and technical effects, and will not be repeated here.

[0187] In the above embodiments, it should be understood that the processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), etc. The general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the application can be directly embodied as hardware processor execution, or executed by a combination of hardware and software modules in the processor.

[0188] The memory can include a random access memory (RAM), and can also include a non-volatile memory (NVM), such as at least one disk memory.

[0189] The bus can be an industry standard architecture (ISA) bus, a peripheral component (PCI) bus, an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application does not limit to only one bus or one type of bus.

[0190] The embodiments of the present application also provide a computer readable storage medium, which stores a computer program, and the computer program is configured to execute the steps in any of the above interface implementation method embodiments when running.

[0191] In an example embodiment, the above computer readable storage medium can include, but is not limited to: a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store computer programs.

[0192] The embodiments of the present application also provide a computer program product, which includes a computer program, and the computer program is executed by a processor to implement the steps in any of the above interface implementation method embodiments.

[0193] The embodiment of the present application further provides another computer program product, comprising a nonvolatile computer readable storage medium, the nonvolatile computer readable storage medium stores a computer program, the computer program is executed by a processor to implement the steps in any of the interface implementation method embodiments.

[0194] Those skilled in the art will further appreciate that the units and algorithm steps of the examples described in connection with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the elements of the examples have been described in general terms in the above description. Whether such functionality is implemented in hardware or software depends on the particular application and design constraints imposed on the overall system. Those skilled in the art can implement the described functionality in varying ways for each particular application, but such implementation should not be interpreted as a departure from the scope of the present application.

[0195] The above has introduced in detail the interface implementation method provided by the present application. The principles and implementation manners of the present application are described by applying specific examples in the present text, and the above description of the examples is only for helping to understand the method of the present application and its core idea. It should be pointed out that, for those skilled in the art, some improvements and modifications can be made to the present application without departing from the principles of the present application, and these improvements and modifications also fall within the protection scope of the claims of the present application.

Claims

1. An interface implementation method, characterized by, The method comprises the following steps: receiving a target request object sent by a target webpage end, wherein the target request object comprises a target class path identifier, a target function identifier and target parameter information; determining a target function corresponding to a target server according to the target class path identifier and the target function identifier, wherein the target function is used to realize a business logic corresponding to the target server; obtaining a target parameter object according to the target parameter information; determining an execution result corresponding to the target function based on the target parameter object and the target function; encapsulating the execution result into a response object, and returning the response object to the target webpage end.

2. The method of claim 1, wherein, The method comprises the following steps: determining at least one execution function according to the target class path identifier and the target function identifier; if the at least one execution function is one, determining the execution function as the target function; if the at least one execution function is multiple, determining the target function from the multiple execution functions according to the target parameter information.

3. The method of claim 2, wherein, The method comprises the following steps: determining a parameter quantity of multiple parameter values in the target parameter information and a parameter type corresponding to each parameter; determining at least one intermediate function from the multiple execution functions according to the parameter quantity; if the at least one intermediate function is one, determining the intermediate function as the target function; if the at least one intermediate function is multiple, performing matching processing on multiple parameter types corresponding to each intermediate function according to the parameter type corresponding to each parameter, obtaining a matching processing result, and determining the target function based on the matching processing result.

4. The method of claim 3, wherein, The method comprises the following steps: determining a first type sequence corresponding to the parameters according to the parameter type corresponding to each parameter; determining a second type sequence of multiple parameter types corresponding to the intermediate functions; performing matching processing on the first type sequence and the second type sequence corresponding to the intermediate functions, and obtaining the matching processing result.

5. The method of claim 2, wherein, The method comprises the following steps: determining a target class corresponding to the target class path identifier, wherein the target class comprises multiple functions; performing matching processing on the multiple functions through the target function identifier, and obtaining the at least one execution function.

6. The method of claim 1, wherein, The method comprises the following steps: obtaining a target parameter format and a parameter type corresponding to the target function; performing conversion processing on the parameters in the target parameter information according to the target parameter format and the parameter type, and obtaining the target parameter object; The method comprises the following steps: extracting an error code, an error description and return data in the execution result; The error code, the error description and the return data are encapsulated to obtain the response object, and the response object is in a preset format.

7. The method of claim 1, wherein, Further comprising: Obtaining interface information corresponding to the target service end; According to the interface information, a target request function corresponding to the target request object is generated, the target request function is used for encapsulating the target request object and sending to the target service end, and is used for triggering the target function corresponding to the business logic.

8. The method of claim 7, wherein, According to the interface information, a target request function corresponding to the target request object is generated, including: The interface information is standardized to obtain preset structure data, the preset structure data includes interface data and object data; According to the interface data and the object data, the target request function is generated.

9. The method of claim 8, wherein, According to the interface data and the object data, the target request function is generated, including: Obtaining a preset object template and a preset interface template; According to the preset object template, the object data is format converted to generate a web end object corresponding to the target function; According to the preset interface template, the interface data is format converted to generate a web end interface corresponding to the target function; The web end object and the web end interface are spliced to obtain the target request function.

10. The method of claim 7, wherein, The interface information includes a target class path identifier, a target function identifier and target parameter information; obtaining the interface information corresponding to the target service end, including: Based on the storage data packet corresponding to the target service end, the target class path identifier is determined; In the instance object corresponding to the target function, the target function identifier and the target parameter information are obtained.

11. The method of claim 10, wherein, Based on the storage data packet corresponding to the target service end, the target class path identifier is determined, including: If the storage data packet is one or more, the target class path identifier is extracted from the storage data packet; If the storage data packet is an unknown package path, a configuration file corresponding to the target service end is obtained, and the target class path identifier is obtained in the configuration file.

12. A computer program product, characterised in that, The computer program is executed by the processor to realize the steps of the interface implementation method in any one of claims 1 to 11.

Citation Information

Patent Citations

  • Method, apparatus and device for responding to webpage access request, and storage medium

    CN110674427A

  • Function information adding method and device, equipment and storage medium

    CN116302218A

  • Interface calling method and device, storage medium and processor

    CN117806852A

  • Service calling method and device, electronic equipment, system and readable storage medium

    CN117931323A

  • File processing method, apparatus, device and computer readable storage medium

    WO2021027592A1