Implementation Method and Device for Open Interface

By introducing common logic and customized logic implementation modules into open interfaces, the problem of difficult to meet the changing needs of multiple external partners in the existing technology is solved, and the effect of reusing existing interfaces and reducing code redundancy is achieved.

CN116055463BActive Publication Date: 2025-06-20PINGAN YIQIANBAO E COMMERCE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310150455.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-09
Publication Date
2025-06-20
Estimated Expiration
2043-02-09

AI Technical Summary

Technical Problem

The prior art has difficulty meeting the ever-changing needs of multiple external partners through an open interface.

Method used

By introducing a general logic implementation module and a custom logic implementation module into the open interface, receiving the call request from the target custom customer, determining the initial field information based on the general logic, and executing the customized logic code through the custom logic implementation module, obtaining the final field information in response to the call.

Benefits of technology

When the business needs of customized customers of different targets overlap with the existing open interfaces, the existing open interfaces can be reused to reduce code redundancy and facilitate maintenance. There is no need to add new open interfaces to meet customized business needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116055463B_ABST
    Figure CN116055463B_ABST
Patent Text Reader

Abstract

The present invention relates to a method and apparatus for implementing an open interface. The method for implementing the open interface includes: receiving a call request for a target open interface from a target customized customer and obtaining the network address corresponding to the call request; determining corresponding first field information based on a general logic implementation module corresponding to the target open interface; determining and executing, based on the network address corresponding to the call request, the implementation code of the customized logic of the target customized customer for the target open interface through a customized logic implementation module corresponding to the target open interface to obtain second field information; and responding to the call request according to the first field information and the second field information. Based on this, an open interface is provided to enable it to meet the constantly changing requirements of multiple external partners in a timely manner.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and particularly to a method and apparatus for implementing an open interface. Background Art

[0002] In the Internet, an open platform can encapsulate the services it provides into a series of data interfaces and publish them to external partners. The external partners can use these open interfaces to utilize the resources of the open platform or expand the functions of the open platform to support their own businesses. Open interfaces are usually APIs (application programming interfaces) or functions.

[0003] However, in the prior art, since the requirements of external partners are constantly changing, in order to meet the needs of external partners, the open platform needs to modify the original open interfaces or add new open interfaces. Therefore, new interfaces usually need to be continuously developed to meet the requirements of external partners. For example, for a general order details query interface, currently there are originally 10 fields in the order details. However, Supplier A, in addition to these 10 fields, also needs to perform logical operations on some of the 10 fields through certain business logics to obtain another 3 values. That is to say, there are originally 10 fields in the order details, and then another 3 fields need to be dynamically calculated according to the business logic of Supplier A, and a total of 13 fields are provided to Supplier A. However, for Supplier B, in addition to these 10 fields, it also needs another 2 fields, and the other 2 fields can also be obtained through various business logics in the 10 fields. Therefore, in view of the above phenomenon, in the face of the constantly changing business demands of suppliers for order details, two new URL address interfaces need to be newly developed for Suppliers A and B for them to call.

[0004] Therefore, how to provide an open interface that can timely meet the constantly changing requirements of multiple external partners is a current research direction. Summary of the Invention

[0005] The present invention provides a method and apparatus for implementing an open interface, which are used to solve the problem in the prior art that it is difficult to meet the constantly changing requirements of multiple external partners through one open interface, and to realize providing an open interface that can timely meet the constantly changing requirements of multiple external partners.

[0006] A method for implementing an open interface, the method comprising: the open interface is implemented based on a general logic implementation module and a customized logic implementation module, the general logic implementation module is used to implement the general logic in the open interface, and the customized logic implementation module is used to implement the customized logic in the open interface, the method comprising: receiving a call request for a target open interface from a target customized customer, and obtaining the network address corresponding to the call request; determining corresponding first field information based on the general logic implementation module corresponding to the target open interface; based on the network address corresponding to the call request, determining and executing, through the customized logic implementation module corresponding to the target open interface, the implementation code of the customized logic of the target customized customer with respect to the target open interface to obtain second field information; and responding to the call request according to the first field information and the second field information.

[0007] In one embodiment, the customized logic implementation module corresponding to the target open interface is implemented based on a Java language programming compiler (javac). Correspondingly, the step of determining and executing, based on the network address corresponding to the call request, through the customized logic implementation module corresponding to the target open interface, the implementation code of the customized logic of the target customized customer with respect to the target open interface to obtain second field information includes: based on the network address corresponding to the call request, determining, through the customized logic implementation module corresponding to the target open interface, the implementation code of the customized logic of the target customized customer with respect to the target open interface from a storage medium; compiling, by javac, the implementation code of the customized logic of the target customized customer with respect to the target open interface into an entity class object, and executing the entity class object according to the input parameters of the entity class object to obtain second field information.

[0008] In one embodiment, before determining and executing, based on the network address corresponding to the call request, through the customized logic implementation module corresponding to the target open interface, the implementation code of the customized logic of the target customized customer with respect to the target open interface, the method further includes: displaying a configuration interface for the customized logic of the target open interface; and receiving, through the configuration interface for the customized logic of the target open interface, the implementation code of the customized logic of the target customized customer with respect to the target open interface and the network address corresponding to the call request, and saving them in a preset storage medium.

[0009] In one embodiment, after displaying the configuration interface for the customized logic of the target open interface, the method further includes: receiving, through the configuration interface for the customized logic of the target open interface, the version number of the software development kit for the Java language, and saving it in a preset storage medium.

[0010] In one embodiment, compiling the implementation code of the customization logic of the target customized customer for the target open interface into an entity class object by javac includes: compiling the implementation code of the customization logic of the target customized customer for the target open interface according to the software development kit version number of the Java language saved in the storage medium.

[0011] In one embodiment, compiling the implementation code of the customization logic of the target customized customer for the target open interface into an entity class object by javac includes: automatically adjusting the lambda expressions and do-while loops in the implementation code of the customization logic of the target customized customer for the target open interface.

[0012] In one embodiment, compiling the implementation code of the customization logic of the target customized customer for the target open interface into an entity class object by javac includes: loading the Java source file of the implementation code of the customization logic of the target customized customer for the target open interface; performing lexical analysis, syntax analysis, and filling the symbol table on the Java source file to construct an abstract syntax tree; generating a binary file based on the constructed abstract syntax tree according to the Java bytecode specification; loading the Class file through the ClassLoader class loader based on the binary file; and creating a new instance object through reflection of the Class object in the Class file.

[0013] An implementation device for an open interface, the device includes: a receiving module, configured to receive a call request for a target open interface from a target customized customer and obtain the network address corresponding to the call request; a determining module, configured to determine corresponding first field information based on the general logic implementation module corresponding to the target open interface; a processing module, configured to determine and execute the implementation code of the customization logic of the target customized customer for the target open interface based on the network address corresponding to the call request through the customization logic implementation module corresponding to the target open interface to obtain second field information; and a response module, configured to respond to the call request according to the first field information and the second field information.

[0014] A computer device includes a memory and a processor. When the computer-readable instructions stored in the memory are executed by the processor, the processor is caused to execute the steps of the above-mentioned implementation method of the open interface.

[0015] A storage medium storing computer-readable instructions, when the computer-readable instructions are executed by one or more processors, causing the one or more processors to execute the steps of the above-mentioned implementation method of the open interface.

[0016] The implementation method and device of the above open interface implement the common business logic of different target-customized customers regarding the target open interface through a general logic implementation module, and implement the customized logic unique to different target-customized customers through a customized logic implementation module. Thus, when the business requirements of different target-customized customers overlap with the existing open interfaces, the existing open interfaces can be reused, reducing code redundancy and facilitating subsequent maintenance. At the same time, without adding an additional new open interface according to the different business requirements of new target-customized customers, the customized business requirements of the target-customized customers can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 is a schematic block diagram of an open interface implementation method in the prior art;

[0018] Figure 2 is an implementation environment diagram of the open interface implementation method provided in an embodiment;

[0019] Figure 3 is one of the schematic flowcharts of the open interface implementation method in an embodiment;

[0020] Figure 4 is the other schematic flowchart of the open interface implementation method in an embodiment;

[0021] Figure 5 is one of the schematic block diagrams of the open interface implementation method in an embodiment;

[0022] Figure 6 is the other schematic block diagram of the open interface implementation method in an embodiment;

[0023] Figure 7 is the structural block diagram of the open interface implementation device in an embodiment;

[0024] Figure 8 is a schematic diagram of an electronic device in an embodiment. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0025] In order to make the objectives, technical solutions and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0026] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the present invention shall have the ordinary meanings understood by those of ordinary skill in the field to which the present invention pertains. The "first", "second" and similar terms used in the present invention do not denote any order, quantity or importance, but are only used to distinguish different components. Words such as "including" or "comprising" mean that the elements or objects appearing before this word cover the elements or objects listed after this word and their equivalents, without excluding other elements or objects. Words such as "connected" or "coupled" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Upper", "lower", "left", "right", etc. are only used to represent relative positional relationships, and when the absolute position of the object being described changes, the relative positional relationship may also change accordingly.

[0027] For ease of understanding, the technical terms related to the present invention will be explained first.

[0028] (1) Entity class objects (instances of entity classes) are used to store and update information related to some phenomena, such as events, personnel, or some objects in real life. Entity classes are usually permanent, and the attributes and relationships they possess are needed in the long term, and sometimes even throughout the entire lifetime of the system. An entity class object is usually not specific to the implementation of a certain use case; sometimes, an entity class object is not even dedicated to the system itself. The values of its attributes and relationships are usually specified by the protagonist. Entity class objects may also be used when performing internal tasks of the system.

[0029] For ease of understanding, the technical problems existing in the prior art will be described in combination with the business scenario of order processing. As Figure 1 shown, in the order processing system, since different suppliers have different business requirements for order details, it is necessary to develop corresponding interfaces separately to meet the business requirements of different suppliers. Figure 1The business requirements corresponding to three suppliers, A, B, and C, are shown. For example, there was originally a general order details query interface. Currently, there were originally 10 fields in the order details. However, in addition to these 10 fields, Supplier A also needed 3 other fields. That is to say, there were originally 10 fields in the order details, and then according to Supplier A's business requirements for the order details, another 3 fields needed to be calculated, and a total of 13 fields were provided to Supplier A. Then, for Supplier B, in addition to these 10 fields, it also needed another 2 fields, and these 2 fields could also be obtained through various business logic calculations on the 10 fields. For Supplier C, in addition to these 10 fields, it also needed another 4 fields, and these 4 fields could also be obtained through various business logic calculations on the 10 fields. Therefore, in view of the above phenomenon, in the face of the constantly changing business requirements of suppliers for order details, it was necessary to newly develop 3 interfaces for Supplier A, Supplier B, and Supplier C respectively, namely Order Details 1, Order Details 2, and Order Details 3. Then, according to the corresponding uniform resource locator (URL) addresses when Supplier A, Supplier B, and Supplier C sent requests, that is, URL1, URL2, and URL3, the processing results corresponding to Order Details 1, Order Details 2, and Order Details 3 were obtained respectively and provided to Supplier A, Supplier B, and Supplier C. However, since the logic of Order Details 1, Order Details 2, and Order Details 3 was basically the same, there was too much duplicate code and it was not easy to maintain. Moreover, due to the various demands of external suppliers, the order details interface could not be uniformly processed. In addition, every time a new supplier was added in the future, the order system needed to customize a set of order details interfaces for the external supplier. Therefore, in view of the above problems, the implementation method of the open interface of the present invention was proposed.

[0030] The following combines Figures 2 - 8 to describe the implementation method and device of the open interface of the present invention.

[0031] Figure 2 It is an implementation environment diagram of the implementation method of the open interface provided in an embodiment, including a computer device 210 and a terminal device 220.

[0032] The computer device 210 is a device for implementing an open interface. The computer device 210 includes a general logic implementation module and a custom logic implementation module. The general logic implementation module is used to implement the general logic in the target open interface, and the custom logic implementation module is used to implement the custom logic in the target open interface. The computer device 210 can receive a call request for the target open interface from the terminal device 220, obtain the network address corresponding to the call request, determine the corresponding first field information based on the general logic implementation module corresponding to the target open interface, determine and execute the implementation code of the corresponding custom logic through the custom logic implementation module corresponding to the target open interface based on the network address corresponding to the call request, obtain the second field information, and respond to the call request according to the first field information and the second field information. Among them, the target open interface can be, for example, an interface for implementing order detail query.

[0033] It should be noted that the terminal device 220 and the computer device 210 can be a smart phone, a tablet computer, a notebook computer, a desktop computer, etc., but are not limited thereto. The computer device 210 and the terminal device 220 can be connected through Bluetooth, Universal Serial Bus (USB), or other communication connection methods, and the present invention does not limit this.

[0034] As Figure 3 shown, in one embodiment, a method for implementing an open interface is proposed. The method for implementing the open interface can be executed by the above-mentioned computer device 210. Specifically, as Figure 3 shown, the method for implementing the open interface provided by the present invention can include the following steps:

[0035] Step 310, receive a call request for the target open interface from the target custom customer, and obtain the network address corresponding to the call request.

[0036] It can be understood that in the present invention, for call requests of different target custom customers for the target open interface, the target open interface can implement corresponding different functions.

[0037] In addition, since the network addresses corresponding to different call requests are unique, that is, the URLs corresponding to different call requests are unique, therefore, the implementation logic of the target open interface required by the corresponding target custom customer can be determined based on the network addresses corresponding to different call requests, that is, the URLs corresponding to different call requests, and then the corresponding functions of the target open interface can be implemented according to the implementation logic of the target open interface required by the target custom customer.

[0038] Among them, the implementation logic of the target open interface required by the target customized customer includes the general logic corresponding to the target open interface and the customized logic of the target open interface required by the target customized customer. Among them, the general logic corresponding to the target open interface is the business processing logic commonly required by multiple external partners; the customized logic of the target open interface required by the target customized customer is the unique business customization logic of the target open interface for the target customized customer.

[0039] Step 320: Determine the corresponding first field information based on the general logic implementation module corresponding to the target open interface.

[0040] It can be understood that the general logic implementation module corresponding to the target open interface is used to implement the general logic in the open interface. Therefore, the first field information can be understood as the field information calculated according to the general logic in the target open interface.

[0041] Step 330: Based on the network address corresponding to the call request, determine and execute the implementation code of the customized logic of the target open interface for the target customized customer through the customized logic implementation module corresponding to the target open interface, and obtain the second field information.

[0042] As mentioned above, since the network addresses corresponding to different call requests are unique, that is, the URLs corresponding to different call requests are unique, therefore, the implementation logic of the target open interface required by the target customized customer can be determined based on the network addresses corresponding to different call requests, that is, the URLs corresponding to different call requests, and then the implementation code of the customized logic of the target open interface for the target customized customer can be determined and executed according to the customized logic implementation module corresponding to the target open interface required by the target customized customer, so as to implement the corresponding functions of the customized logic of the target open interface.

[0043] It can be understood that the customized logic implementation module corresponding to the target open interface is used to implement the customized logic of the target open interface required by the target customized customer. Therefore, the second field information can be understood as the field information calculated according to the customized logic of the target open interface required by the target customized customer.

[0044] Step 340: Respond to the call request according to the first field information and the second field information.

[0045] The implementation method of the open interface provided by the present invention realizes the common business logic of different target customized customers regarding the target open interface through a general logic implementation module, and realizes the customized logic unique to different target customized customers through a customized logic implementation module. Thus, when the business requirements of different target customized customers overlap with the existing open interfaces, the existing open interfaces can be reused, reducing code redundancy and facilitating subsequent maintenance. At the same time, without adding an additional new open interface according to the different business requirements of new target customized customers, the customized business requirements of the target customized customers can be realized.

[0046] In one embodiment, as Figure 4 shown, the customized logic implementation module corresponding to the target open interface is implemented based on javac. Correspondingly, based on the network address corresponding to the call request, the implementation code of the customized logic of the target customized customer regarding the target open interface is determined and executed through the customized logic implementation module corresponding to the target open interface to obtain the second field information, including the following steps:

[0047] Step 410, display the configuration interface of the customized logic of the target open interface.

[0048] Among them, the configuration interface of the customized logic of the target open interface is used to configure the customized logic of the target customized customer regarding the target open interface and the network address corresponding to the call request of the target customized customer for the target open interface.

[0049] Step 420, through the configuration interface of the customized logic of the target open interface, receive the implementation code of the customized logic of the target customized customer regarding the target open interface and the network address corresponding to the call request, and save them in a preset storage medium.

[0050] It can be understood that the customized logics corresponding to different target customized customers are different. Therefore, when adding a new target customized customer each time, the implementation code of the customized logic of the target customized customer regarding the target open interface and the network address corresponding to its call request can be saved in a preset storage medium first, so as to determine the implementation code of the customized logic of the target customized customer regarding the target open interface when receiving the network address corresponding to the call request of the target customized customer for the target open interface subsequently. Thus, the customized logic function of the target open interface can be realized according to the implementation code of the customized logic of the target customized customer regarding the target open interface, and there is no need to separately encapsulate a new interface for the newly added target customized customer. Specifically, reference can be made to the relevant description in the following text Figure 6 and details will not be elaborated here.

[0051] Step 430: Based on the network address corresponding to the call request, the customization logic implementation module corresponding to the target open interface determines the implementation code of the customization logic of the target customization customer for the target open interface from the storage medium.

[0052] Among them, the customization logic implementation module corresponding to the target open interface can be a plug-in.

[0053] Step 440: Compile the implementation code of the customization logic of the target customization customer for the target open interface into an entity class object through javac, and execute the entity class object according to the input parameters of the entity class object to obtain the second field information.

[0054] It can be understood that in one embodiment, the input parameters of the entity class object can be the information of some fields in the above-mentioned first field processing information.

[0055] Specifically, compiling the implementation code of the customization logic of the target customization customer for the target open interface into an entity class object through javac can be achieved through the following steps: loading the Java source file of the implementation code of the customization logic of the target customization customer for the target open interface; performing lexical analysis, syntax analysis, and filling the symbol table on the java source file to construct an abstract syntax tree; generating a binary file based on the constructed abstract syntax tree according to the java bytecode specification; loading the Class class file based on the binary file through the ClassLoader class loader; creating a new instance object through reflection of the Class object in the Class class file.

[0056] In one embodiment, before determining and executing the implementation code of the customization logic of the target customization customer for the target open interface based on the network address corresponding to the call request through the customization logic implementation module corresponding to the target open interface, the method further includes: in response to the operation of the user, saving the software development kit version number (jdk version number) of the Java language in a preset storage medium.

[0057] It can be understood that this step can be executed simultaneously with the above-mentioned step 410. And if this step is executed, compiling the implementation code of the customization logic of the target customization customer for the target open interface into an entity class object through javac includes:

[0058] Compiling the implementation code of the customization logic of the target customization customer for the target open interface according to the software development kit version number of the Java language saved in the storage medium.

[0059] It can be understood that by setting the corresponding JDK version, the implementation code of the customization logic of the target customized customer for the target open interface can be compiled according to the corresponding JDK version, which is convenient for compatibility testing.

[0060] In one embodiment, the implementation code of the customization logic of the target customized customer for the target open interface is compiled into an entity class object by javac, including:

[0061] Automatically adjust the lambda expressions and do-while loops in the implementation code of the customization logic of the target customized customer for the target open interface.

[0062] It can be understood that by automatically adjusting the lambda expressions and do-while loops in the implementation code of the customization logic of the target customized customer for the target open interface, the situation where compilation fails due to the lambda expressions and do-while loops in the code can be avoided, which is beneficial to the smooth compilation of the code.

[0063] It can also be understood that before this step, the implementation code of the customization logic of the target customized customer for the target open interface is compiled into an entity class object by javac, and the Chinese fonts in the implementation code can also be processed through the base64 module to avoid garbled characters during the transmission of Chinese in the implementation code.

[0064] Figure 5 Another schematic flowchart of the implementation method of the open interface provided by the present invention. As Figure 5 shown, based on the implementation method of the open interface provided by the present invention, the corresponding Figure 1 processing flow in can be:

[0065] In the order processing system, when receiving call requests for the target open interface from three suppliers A, B, and C, the URL addresses URL1, URL2, and URL3 corresponding to the call requests of the three suppliers A, B, and C for the order details target open interface are respectively obtained. According to URL1, URL2, and URL3, the customization logic codes of the order details target open interface corresponding to the three suppliers A, B, and C are determined according to the customization logic implementation module in the order details target open interface. According to the general processing logic of the general logic implementation module in the order details target open interface and the customization logic codes of the order details target open interface corresponding to the three suppliers A, B, and C respectively, the order details service results corresponding to the three suppliers A, B, and C are respectively processed.

[0066] Figure 6 Another schematic flowchart of the implementation method of the open interface provided by the present invention. As Figure 6As shown in the figure, developers can configure the URL address "url" corresponding to the target open interface call request sent by the target customized customer, the implementation code "code" of the customized logic of the target open interface by the target customized customer, and the jdk version "jdkVersion" on the page of the computer device, and save them to a preset storage medium. The storage medium can be, for example, a Mysql or Oracle database. In this way, it is convenient to obtain the corresponding information from the preset storage medium when needed later to implement the customized logic.

[0067] The implementation device of the open interface provided by the present invention will be described below. The implementation device of the open interface described below corresponds to and refers to the implementation method of the open interface described above.

[0068] Figure 7 It is a schematic block diagram of the implementation device of the open interface provided by the present invention. As Figure 7 shown, the implementation device of the open interface provided by the present invention includes:

[0069] A receiving module 710, configured to receive a call request for a target open interface from a target customized customer and obtain the network address corresponding to the call request;

[0070] A determining module 720, configured to determine corresponding first field information based on a general logic implementation module corresponding to the target open interface;

[0071] A processing module 730, configured to determine and execute the implementation code of the customized logic of the target open interface by the target customized customer based on the network address corresponding to the call request through a customized logic implementation module corresponding to the target open interface to obtain second field information;

[0072] A response module 740, configured to respond to the call request according to the first field information and the second field information.

[0073] The implementation device of the open interface provided by the present invention realizes the common business logic of different target customized customers regarding the target open interface based on the general logic implementation module, and realizes the unique customized logic of different target customized customers through the customized logic implementation module, so that when the business requirements of different target customized customers overlap with the existing open interfaces, the existing open interfaces can be reused, reducing code redundancy and facilitating subsequent maintenance. At the same time, it is not necessary to add a new open interface according to the different business requirements of new target customized customers, and the customized business requirements of target customized customers can be realized.

[0074] In one embodiment, the processing module 730 includes:

[0075] A determination unit, configured to determine, based on the network address corresponding to the call request, an implementation code of the customization logic of the target customization customer for the target open interface from a storage medium through a customization logic implementation module corresponding to the target open interface;

[0076] A processing unit, configured to compile the implementation code of the customization logic of the target customization customer for the target open interface into an entity class object by using javac, and execute the entity class object according to the input parameters of the entity class object to obtain second field information.

[0077] In one embodiment, the apparatus further includes:

[0078] A display module, configured to display a configuration interface of the customization logic of the target open interface;

[0079] A first receiving module and a first saving module, configured to receive, through the configuration interface of the customization logic of the target open interface, the implementation code of the customization logic of the target customization customer for the target open interface and the network address corresponding to the call request, and save them in a preset storage medium.

[0080] In one embodiment, the apparatus further includes:

[0081] A second receiving module and a second saving module, configured to receive, through the configuration interface of the customization logic of the target open interface, the version number of the software development kit in Java language, and save it in a preset storage medium.

[0082] In one embodiment, the processing unit includes:

[0083] A compilation unit, configured to compile the implementation code of the customization logic of the target customization customer for the target open interface according to the version number of the software development kit in Java language saved in the storage medium.

[0084] In one embodiment, the processing unit includes:

[0085] An adjustment unit, configured to automatically adjust lambda expressions and do-while loops in the implementation code of the customization logic of the target customization customer for the target open interface.

[0086] In one embodiment, the processing unit includes:

[0087] A first loading unit, configured to load a Java source file of the implementation code of the customization logic of the target customization customer for the target open interface;

[0088] A construction unit, configured to perform lexical analysis, syntax analysis, fill a symbol table on the java source file, and construct an abstract syntax tree;

[0089] A generating unit, configured to generate a binary file based on the constructed abstract syntax tree according to the Java bytecode specification;

[0090] A second loading unit, configured to load a Class file based on the binary file through a ClassLoader class loader;

[0091] A creating unit, configured to create a new instance object through reflection using the Class object in the Class file.

[0092] In one embodiment, a computer device is provided. The computer device includes a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented: receiving a call request for a target open interface from a target custom customer, and obtaining a network address corresponding to the call request; determining corresponding first field information based on a general logic implementation module corresponding to the target open interface; determining and executing, based on the network address corresponding to the call request, an implementation code of the custom logic of the target custom customer for the target open interface through a custom logic implementation module corresponding to the target open interface to obtain second field information; and responding to the call request according to the first field information and the second field information.

[0093] Figure 8 An entity structure diagram of an electronic device is exemplified, as Figure 8 shown. The electronic device may include: a processor 810, a communications interface 820, a memory 830, and a communication bus 840. Among them, the processor 810, the communications interface 820, and the memory 830 complete communication with each other through the communication bus 840. The processor 810 may call logic instructions in the memory 830 to execute the implementation method of the open interface provided by the present invention. The implementation method of the open interface includes: receiving a call request for a target open interface from a target custom customer, and obtaining a network address corresponding to the call request; determining corresponding first field information based on a general logic implementation module corresponding to the target open interface; determining and executing, based on the network address corresponding to the call request, an implementation code of the custom logic of the target custom customer for the target open interface through a custom logic implementation module corresponding to the target open interface to obtain second field information; and responding to the call request according to the first field information and the second field information.

[0094] In addition, when the logic instructions in the above-mentioned memory 830 can be implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs that can store program codes.

[0095] On the other hand, the present invention also provides a computer program product. The computer program product includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the method for implementing the open interface provided by the present invention. Among them, the method for implementing the open interface includes: receiving a call request for a target open interface from a target customizing customer and obtaining the network address corresponding to the call request; determining corresponding first field information based on the general logic implementation module corresponding to the target open interface; based on the network address corresponding to the call request, determining and executing the implementation code of the custom logic of the target customizing customer for the target open interface through the custom logic implementation module corresponding to the target open interface to obtain second field information; and responding to the call request according to the first field information and the second field information.

[0096] In yet another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it is configured to execute the method for implementing the open interface provided by the present invention. Among them, the method for implementing the open interface includes: receiving a call request for a target open interface from a target customizing customer and obtaining the network address corresponding to the call request; determining corresponding first field information based on the general logic implementation module corresponding to the target open interface; based on the network address corresponding to the call request, determining and executing the implementation code of the custom logic of the target customizing customer for the target open interface through the custom logic implementation module corresponding to the target open interface to obtain second field information; and responding to the call request according to the first field information and the second field information.

[0097] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement it without creative work.

[0098] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the essence of the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0099] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments or perform equivalent replacements for some of the technical features. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of each embodiment of the present invention.

Claims

1. A method for implementing an open interface, characterized in that, The open interface is implemented based on a general logic implementation module and a customized logic implementation module. The general logic implementation module is used to implement the general logic in the open interface, and the customized logic implementation module is used to implement the customized logic in the open interface. The method includes: Receiving a call request for a target open interface from a target customized customer, and obtaining the network address corresponding to the call request; Determining corresponding first field information based on the general logic implementation module corresponding to the target open interface; Based on the network address corresponding to the call request, determining and executing, through the customized logic implementation module corresponding to the target open interface, the implementation code of the customized logic of the target customized customer for the target open interface, to obtain second field information; Responding to the call request according to the first field information and the second field information; The step of, based on the network address corresponding to the call request, determining and executing, through the customized logic implementation module corresponding to the target open interface, the implementation code of the customized logic of the target customized customer for the target open interface, to obtain second field information, includes: displaying the configuration interface of the customized logic of the target open interface; through the configuration interface of the customized logic of the target open interface, receiving the implementation code of the customized logic of the target customized customer for the target open interface and the network address corresponding to the call request, and saving them in a preset storage medium; based on the network address corresponding to the call request, determining, through the customized logic implementation module corresponding to the target open interface, the implementation code of the customized logic of the target customized customer for the target open interface from the storage medium; compiling the implementation code of the customized logic of the target customized customer for the target open interface into an entity class object by javac, and executing the entity class object according to the input parameters of the entity class object, to obtain second field information.

2. The method for implementing an open interface according to claim 1, characterized in that, The customized logic implementation module corresponding to the target open interface is implemented based on javac. Correspondingly, the step of, based on the network address corresponding to the call request, determining and executing, through the customized logic implementation module corresponding to the target open interface, the implementation code of the customized logic of the target customized customer for the target open interface, to obtain second field information, includes: Based on the network address corresponding to the call request, determining, through the customized logic implementation module corresponding to the target open interface, the implementation code of the customized logic of the target customized customer for the target open interface from the storage medium; Compiling the implementation code into an entity class object by javac, and executing the entity class object according to the input parameters of the entity class object, to obtain second field information.

3. The method for implementing an open interface according to claim 2, characterized in that, Before, based on the network address corresponding to the call request, determining and executing, through the customized logic implementation module corresponding to the target open interface, the implementation code of the customized logic of the target customized customer for the target open interface, the method further includes: Displaying the configuration interface of the customized logic of the target open interface; Through the configuration interface of the customized logic of the target open interface, receiving the implementation code of the customized logic of the target customized customer for the target open interface and the network address corresponding to the call request, and saving them in a preset storage medium.

4. The method for implementing an open interface according to claim 3, characterized in that, After displaying a configuration interface for customizing the logic of a target open interface, the method further includes: Receiving, through the configuration interface for customizing the logic of the target open interface, the version number of the software development kit in the Java language and saving it in a preset storage medium.

5. The method for implementing an open interface according to claim 4, characterized in that, The compiling, by javac, the implementation code of the custom logic of the target open interface of the target custom client into an entity class object includes: Compiling the implementation code of the custom logic of the target open interface of the target custom client according to the version number of the software development kit in the Java language saved in the storage medium.

6. The method for implementing an open interface according to claim 2, characterized in that, The compiling, by javac, the implementation code of the custom logic of the target open interface of the target custom client into an entity class object includes: Automatically adjusting the lambda expressions and do-while loops in the implementation code of the custom logic of the target open interface of the target custom client.

7. The method for implementing an open interface according to claim 2, characterized in that, The compiling, by javac, the implementation code of the custom logic of the target open interface of the target custom client into an entity class object includes: Loading the Java source file of the implementation code of the custom logic of the target open interface of the target custom client; Performing lexical analysis, syntax analysis, filling the symbol table on the Java source file, and constructing an abstract syntax tree; Generating a binary file based on the constructed abstract syntax tree according to the bytecode specification of Java; Based on the binary file, loading and obtaining a Class class file through a ClassLoader class loader; Creating a new instance object through reflection of the Class object in the Class class file.

8. An apparatus for implementing an open interface, characterized in that, The device includes: A receiving module, configured to receive a call request for a target open interface from a target custom client and obtain the network address corresponding to the call request; A determining module, configured to determine corresponding first field information based on a general logic implementation module corresponding to the target open interface; A processing module, configured to determine and execute the implementation code of the customization logic of the target customized customer for the target open interface through the customization logic implementation module corresponding to the target open interface based on the network address corresponding to the call request, so as to obtain the second field information; the determining and executing the implementation code of the customization logic of the target customized customer for the target open interface through the customization logic implementation module corresponding to the target open interface based on the network address corresponding to the call request to obtain the second field information includes: displaying a configuration interface for the customization logic of the target open interface; receiving, through the configuration interface for the customization logic of the target open interface, the implementation code of the customization logic of the target customized customer for the target open interface and the network address corresponding to the call request, and storing them in a preset storage medium; determining, based on the network address corresponding to the call request, the implementation code of the customization logic of the target customized customer for the target open interface from the storage medium through the customization logic implementation module corresponding to the target open interface; compiling the implementation code of the customization logic of the target customized customer for the target open interface into an entity class object by using javac, and executing the entity class object according to the input parameters of the entity class object to obtain the second field information; A response module, configured to respond to the call request according to the first field information and the second field information.

9. A computer device, comprising a memory and a processor, wherein computer-readable instructions are stored in the memory, characterized in that,When the computer-readable instructions are executed by the processor, the processor is caused to execute the steps of the implementation method of the open interface according to any one of claims 1 to 7.

10. A storage medium storing computer-readable instructions, characterized in that, When the computer-readable instructions are executed by one or more processors, one or more processors are caused to execute the steps of the implementation method of the open interface according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data conversion method and device

    CN114911750A