Interface calling method, device, server and storage medium

By monitoring the triggering events of interface calls in the server and using the mapping relationship to determine the interface to be called, the difficulty of implementing interface calls in the financial services field is solved, and a simpler, unified and efficient interface calling process is achieved.

CN112181535BActive Publication Date: 2024-10-18CHINA CONSTRUCTION BANK
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010994608.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-21
Publication Date
2024-10-18
Estimated Expiration
2040-09-21

AI Technical Summary

Technical Problem

In the field of financial services, the implementation process of interface calling in scenarios such as financial transactions is cumbersome, and the interface calling methods in different scenarios are not uniform, which increases the difficulty of implementation.

Method used

By monitoring the triggering events of the interface call in the server, the interface call parameters are obtained, and the pre-built mapping relationship is used to determine the interface to be called in the scene to be called through annotation dynamic mapping, and the interface call is implemented. The method includes obtaining interface calling parameters, determining the scenario and interface to be called, and calling the interface to be called to implement the corresponding function.

Benefits of technology

It provides a simpler, more flexible, unified and standardized interface calling method, unifies the interface calling process in various scenarios, reduces the work intensity of developers and improves the efficiency of interface calling.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112181535B_ABST
    Figure CN112181535B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses an interface calling method, device, server and storage medium. The method is applied to the server and may include: when a triggering event of an interface call is monitored, obtaining the interface calling parameters corresponding to the triggering event; determining the interface to be called in the scene to be called corresponding to the interface calling parameters in the mapping relationship, wherein the mapping relationship is pre-constructed by annotating dynamic mapping; calling the interface to be called to implement the function corresponding to the interface to be called. The technical solution of the embodiment of the present invention, by providing a simpler, more flexible, more unified and standardized interface calling method, the calling process of each interface in various scenarios can be unified in a unique entry to implement, thereby solving the problem of difficulty in implementing interface calls, reducing the workload of developers, and improving the efficiency of subsequent interface calls.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to an interface calling method, device, server and storage medium. Background Art

[0002] In the process of software application development, back-end interface calls are the basis for front-end and back-end interactions and interactions between systems, and are basic functions in software applications.

[0003] In the financial services sector, there are time-consuming monitoring, synchronization, filtering, adding logs, and other requirements for various financial transactions, which makes the implementation process of calling corresponding interfaces in different scenarios to meet their respective requirements very cumbersome. In particular, due to the large number of actual scenarios, the implementation methods of interface calls for the same requirement in various scenarios are not uniform, which also increases the difficulty of implementing interface calls. Summary of the invention

[0004] The embodiments of the present invention provide an interface calling method, device, server and storage medium, which solve the problem that the interface calling is difficult to implement.

[0005] In a first aspect, an embodiment of the present invention provides an interface calling method, which is applied to a server and includes:

[0006] When a triggering event of an interface call is detected, the interface call parameters corresponding to the triggering event are obtained;

[0007] Determine the interface to be called in the scenario to be called corresponding to the interface call parameter in the mapping relationship, wherein the mapping relationship is pre-built by way of annotation dynamic mapping;

[0008] Call the interface to be called to implement the function corresponding to the interface to be called.

[0009] Optionally, the mapping relationship can be pre-built by following the steps below:

[0010] Obtain the class annotations and method annotations of the custom runtime, and the entity classes corresponding to the class annotations and method annotations, write the class annotations and method annotations into the entity class based on the preset annotation scanning class, and build a mapping relationship based on the written entity class.

[0011] Optionally, the entity class is provided with a transaction code, a class name, a class object and a method.

[0012] Optionally, write class annotations and method annotations to entity classes based on pre-set annotation scanning classes, which can include:

[0013] The constructed annotation writing function is called with the obtained class object and class name as input parameters to write the class annotations and method annotations into the entity class, wherein the annotation writing function is set in a pre-set annotation processing class, and a mapping variable is set in the annotation processing class. The annotation writing function writes the class annotations and method annotations into the entity class through the mapping variables, and the mapping variables are static Map type member variables.

[0014] Optionally, the annotation writing function can implement the annotation writing function through the following steps:

[0015] Determine the class annotation corresponding to the class object, and when the class annotation is not empty, obtain a method array consisting of various methods associated with the class object, and determine whether the method array is empty;

[0016] If not, then obtain each method object in the method array and the method annotation of each method object in turn, and if the method annotation is not empty, obtain the transaction code of the method annotation;

[0017] When the transaction code is not empty, the entity object corresponding to the class name and the class object is obtained from the mapping variable according to the transaction code, and the class annotation and the method annotation are written into the entity class based on the entity object, wherein the entity object is an object in the entity class.

[0018] Optionally, the above interface calling method may further include: annotating the interface to be called through method annotations, and annotating the scenario to be called through class annotations.

[0019] Optionally, determining the interface to be called in the scenario to be called corresponding to the interface calling parameter in the mapping relationship may include:

[0020] The constructed interface determination function is called with the interface call parameters as input parameters to determine the interface to be called in the scene to be called corresponding to the interface call parameters in the mapping relationship, wherein the interface determination function is set in the interface service class, and the interface service class includes the FacadeService class.

[0021] Optionally, the interface determination function can implement the interface determination function through the following steps:

[0022] Get the entity object corresponding to the interface call parameter, and if the entity object is not empty, get the class object and method object from the entity object;

[0023] The scenario to be called is determined in the mapping relationship according to the class object, and the interface to be called is determined in the scenario to be called according to the method object.

[0024] Optionally, obtain the interface call parameters corresponding to the trigger event, which may include:

[0025] The interface call parameters corresponding to the trigger event are obtained based on the entry class, and the interface service object of the interface service class is injected into the entry class through annotation.

[0026] On this basis, optionally, determining the interface to be called in the scenario to be called corresponding to the interface call parameters in the mapping relationship may include: determining the interface to be called in the scenario to be called corresponding to the interface call parameters in the mapping relationship through the interface service object in the entry class.

[0027] Optionally, calling the interface to be called to implement the function corresponding to the interface to be called may include:

[0028] Call the interface to be called to record the execution time of the preset reflection algorithm to monitor the time consumption; or,

[0029] Calling the interface to be called to control the synchronous and asynchronous execution of the preset reflection algorithm according to the synchronous and asynchronous parameters in the variable-length parameters in the interface calling parameters; or,

[0030] Call the interface to be called to judge the variable-length parameters to filter the data; or,

[0031] Call the interface to be called to classify the transaction code in the interface call parameters to realize the operation flow record under the corresponding requirements.

[0032] Optionally, the mapping relationship stores the correspondence between the interface calling parameters, the scenario to be called, and the interface to be called.

[0033] In a second aspect, an embodiment of the present invention further provides an interface calling device, which is configured on a server and may include:

[0034] The parameter acquisition module is used to acquire the interface call parameters corresponding to the trigger event when the trigger event of the interface call is detected;

[0035] The interface determination module is used to determine the interface to be called in the to-be-called scenario corresponding to the interface call parameters in the mapping relationship. The mapping relationship is pre-built by means of annotation dynamic mapping.

[0036] The interface calling module is used to call the interface to be called to implement the function corresponding to the interface to be called.

[0037] In a third aspect, an embodiment of the present invention further provides a server, which may include:

[0038] one or more processors;

[0039] A memory for storing one or more programs;

[0040] When one or more programs are executed by one or more processors, the one or more processors implement the interface calling method provided by any embodiment of the present invention.

[0041] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the interface calling method provided by any embodiment of the present invention is implemented.

[0042] The technical solution of the embodiment of the present invention is that when the unique entry in the server receives the interface call parameters transmitted via the front end, it can obtain the interface to be called in the corresponding to-be-called scenario in the mapping relationship according to the interface call parameters; thus, the corresponding function is realized by calling the interface to be called. The above technical solution, by providing a simpler, more flexible, more unified and standardized interface calling method, the calling process of each interface in various scenarios can be unified in the unique entry, thereby solving the problem of the difficulty of implementing interface calls, reducing the workload of developers, and improving the efficiency of subsequent interface calls. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 This is a flow chart of an interface calling method in Embodiment 1 of the present invention;

[0044] Figure 2 This is a flow chart of an interface calling method in Embodiment 2 of the present invention;

[0045] Figure 3 This is a flow chart of an interface calling method in Embodiment 3 of the present invention;

[0046] Figure 4 It is a structural block diagram of an interface calling device in Embodiment 4 of the present invention;

[0047] Figure 5 It is a structural diagram of a server in Embodiment 5 of the present invention. DETAILED DESCRIPTION

[0048] The present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It is also necessary to explain that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0049] Embodiment 1

[0050] Figure 1This is a flow chart of an interface calling method provided in the first embodiment of the present invention. This embodiment is applicable to the case where interfaces corresponding to various requirements in various scenarios are called through a unique entry. The method can be executed by the interface calling device provided in the embodiment of the present invention, which can be implemented by software and / or hardware, and the device can be integrated on a server.

[0051] See also Figure 1 The method of the embodiment of the present invention specifically includes the following steps:

[0052] S110. When a triggering event of an interface call is detected, an interface call parameter corresponding to the triggering event is obtained.

[0053] Among them, the trigger event can be an event triggered by the front end (i.e., the client) for calling the interface in the back end (i.e., the server). The interface can be an interface to be called corresponding to a certain requirement in a certain scenario. The scenario can be a scenario related to financial transactions. The requirement can be time-consuming monitoring, synchronization and asynchrony, filtering, adding transaction logs, etc., which are not specifically limited here.

[0054] When a triggering event of an interface call is monitored, the interface call parameters corresponding to the triggering event passed by the front end are obtained. The interface call parameters may include a transaction code, a variable-length parameter, etc. The obtaining process may be executed by the unique entry of the Java back-end service set in each embodiment of the present invention. The unique entry can unify various interfaces in different scenarios. The advantage of such a setting is that, by providing a simpler, more flexible, unified and standardized interface calling method, various requirements in various scenarios can be unified in a unique entry to be implemented, thereby solving the problem of needing to repeatedly write code in each scenario because the same requirement is applied in different scenarios. Only various codes related to the requirements need to be written in the unique entry, thereby reducing the workload of developers and improving the efficiency of subsequent interface calls.

[0055] S120. Determine the interface to be called in the to-be-called scenario corresponding to the interface call parameter in the mapping relationship, wherein the mapping relationship is pre-constructed by way of annotation dynamic mapping.

[0056] Among them, the scene to be called is the scene to be called corresponding to the interface calling parameters in each scene, and the interface to be called is the interface to be called corresponding to the parameters to be called in each interface under the scene to be called. The mapping relationship stores the correspondence between the interface calling parameters, the scene and the interface. Therefore, the scene to be called corresponding to the interface calling parameters and the interface to be called under the scene to be called can be obtained in the mapping relationship. In other words, according to the interface calling parameters, it can be determined which interface in the unique entrance to call to realize the corresponding function, that is, the corresponding interface can be called through the unique entrance to realize the corresponding function, and there is no need to find the corresponding interface in the entrance corresponding to each scene, thereby improving the efficiency of the interface call.

[0057] It should be noted that the above-mentioned mapping relationship can be pre-constructed by means of annotation dynamic mapping, such as annotating the scenes and interfaces that need to be unified into a unique entry, and mapping the scenes and interfaces according to the annotation results. Since each interface has its own transaction code, which is one of the interface call parameters, the mapping relationship constructed by means of annotation dynamic mapping may include the mapping relationship between scenes, interfaces and interface call parameters.

[0058] On this basis, optionally, obtaining the interface call parameters corresponding to the trigger event may specifically include: obtaining the interface call parameters corresponding to the trigger event based on the entry class, injecting the interface service object of the interface service class into the entry class by annotation, wherein the entry class may be represented as WebController, and the interface service class may be represented as FacadeService class, and this technical solution implements the calling process of the only entry; thereby, determining the interface to be called in the scene to be called corresponding to the interface call parameters in the mapping relationship, which may specifically include: determining the interface to be called in the scene to be called corresponding to the interface call parameters in the mapping relationship through the interface service object in the entry class.

[0059] S130: Call the interface to be called to implement the function corresponding to the interface to be called.

[0060] Among them, each interface to be called corresponds to a function, method, etc. Therefore, by calling the interface to be called, the function corresponding to the interface to be called can be realized. Exemplarily, the interface to be called is called to record the execution time of the preset reflection algorithm to monitor the time consumption; or, the interface to be called is called to control the synchronous and asynchronous execution of the preset reflection algorithm according to the synchronous and asynchronous parameters in the variable-length parameters in the interface call parameters; or, the interface to be called is called to judge the variable-length parameters to filter data; or, the interface to be called is called to classify the transaction code in the interface call parameters to realize the operation flow record under the corresponding requirements; etc., which are not specifically limited here.

[0061] The technical solution of the embodiment of the present invention is that when the unique entry in the server receives the interface call parameters transmitted via the front end, it can obtain the interface to be called in the corresponding to-be-called scenario in the mapping relationship according to the interface call parameters; thus, the corresponding function is realized by calling the interface to be called. The above technical solution, by providing a simpler, more flexible, more unified and standardized interface calling method, the calling process of each interface in various scenarios can be unified in the unique entry, thereby solving the problem of the difficulty of implementing interface calls, reducing the workload of developers, and improving the efficiency of subsequent interface calls.

[0062] Embodiment 2

[0063] Figure 2 It is a flowchart of an interface calling method provided in the second embodiment of the present invention. This embodiment is optimized based on the above-mentioned technical solutions. In this embodiment, optionally, the mapping relationship can be pre-built through the following steps: obtain the class annotations and method annotations of the custom runtime, and the entity class corresponding to the class annotations and method annotations, in which the transaction code, class name, class object and method are set; based on the preset annotation scanning class, the class annotations and method annotations are written into the entity class, and a mapping relationship is built based on the written entity class. Among them, the explanations of the terms that are the same or corresponding to the above-mentioned embodiments are not repeated here. See Figure 2 The method of this embodiment may specifically include the following steps:

[0064] S210. Obtain class annotations and method annotations of the custom runtime, and entity classes corresponding to the class annotations and method annotations, wherein the entity class is provided with a transaction code, a class name, a class object, and a method.

[0065] Among them, class annotations and method annotations can be understood as labels, and the entity class is the class corresponding to each label. The transaction code, class name, class object and method corresponding to each label can be set in the entity class, and the entity class can be represented by DealAction. In actual applications, it is optional to annotate each interface to be called through method annotations, and to annotate each scenario to be called through class annotations, that is, to label the scenarios and interfaces that need to be unified into a unique entry. It should be noted that there is a corresponding relationship between classes and scenarios, and there is a corresponding relationship between methods in classes and interfaces in scenarios.

[0066] S220, writing the class annotation and the method annotation into the entity class based on the preset annotation scanning class, and constructing a mapping relationship based on the written entity class.

[0067] Among them, by scanning various interfaces in various scenarios based on the annotation scanning class, scenes with class annotations and interfaces with method annotations can be obtained. Therefore, the scanned class annotations and method annotations can be written into the entity class, thereby constructing a mapping relationship.

[0068] On this basis, optionally, based on a preset annotation scanning class, class annotations and method annotations are written into the entity class, which may specifically include: taking the obtained class object and class name as input parameters, calling the constructed annotation writing function to write the class annotations and method annotations into the entity class; wherein, the annotation writing function is set in a preset annotation processing class, a mapping variable is set in the annotation processing class, and the annotation writing function writes the class annotations and method annotations into the entity class through the mapping variable, and the mapping variable is a static Map type member variable. On this basis, optionally, the annotation writing function can implement the annotation writing function through the following steps: determine the class annotation corresponding to the class object, and when the class annotation is not empty, obtain the method array consisting of the methods associated with the class object, and determine whether the method array is empty; if not, obtain each method object in the method array and the method annotation of each method object in turn, and when the method annotation is not empty, obtain the transaction code of the method annotation; when the transaction code is not empty, the entity object corresponding to the class name and class object can be obtained from the mapping variable according to the transaction code, and the class annotation and method annotation are written into the entity class based on the entity object, wherein the entity object is an object in the entity class.

[0069] S230: When a triggering event of an interface call is detected, obtain an interface call parameter corresponding to the triggering event.

[0070] S240. Determine the interface to be called in the to-be-called scenario corresponding to the interface call parameter in the mapping relationship, wherein the mapping relationship is pre-constructed by way of annotation dynamic mapping.

[0071] S250: Call the interface to be called to implement the function corresponding to the interface to be called.

[0072] The technical solution of the embodiment of the present invention obtains the class annotations and method annotations at a custom runtime, and the entity classes corresponding to the class annotations and method annotations, so that the class annotations and method annotations can be written into the entity class based on the annotation scanning class, and a mapping relationship is constructed based on the written entity class, thereby achieving the effect of constructing the mapping relationship.

[0073] Embodiment 3

[0074] Figure 3It is a flow chart of an interface calling method provided in the third embodiment of the present invention. This embodiment is optimized based on the above-mentioned technical solutions. In this embodiment, optionally, determining the interface to be called in the scene to be called corresponding to the interface calling parameters in the mapping relationship may specifically include: taking the interface calling parameters as input parameters, calling the constructed interface determination function, so as to determine the interface to be called in the scene to be called corresponding to the interface calling parameters in the mapping relationship, wherein the interface determination function is set in the interface service class, and the interface service class includes the FacadeService class. Among them, the explanations of the terms that are the same or corresponding to the above-mentioned embodiments are not repeated here.

[0075] See also Figure 3 The method of this embodiment may specifically include the following steps:

[0076] S310: When a triggering event of an interface call is detected, obtain an interface call parameter corresponding to the triggering event.

[0077] S320. Call the constructed interface determination function with the interface call parameters as input parameters to determine the interface to be called in the scene to be called corresponding to the interface call parameters in the mapping relationship. The mapping relationship is pre-constructed by means of annotation dynamic mapping. The interface determination function is set in the interface service class, and the interface service class includes the FacadeService class.

[0078] Among them, the interface service class can be set in the entry class, and the interface call parameters can be obtained based on the entry class. The interface determination function is set in the interface service class. Therefore, after obtaining the interface call parameters based on the entry class, the interface determination function in the entry class can determine the interface to be called in the corresponding scene to be called according to the interface call parameters. On this basis, optionally, the interface determination function can implement the interface determination function through the following steps: obtain the entity object corresponding to the interface call parameters, and the entity object is an object in the entity class; when the entity object is not empty, obtain the class object and the method object from the entity object; because the class and the scene have a corresponding relationship and the method and the interface have a corresponding relationship, the scene to be called can be determined in the mapping relationship according to the class object, and the interface to be called can be determined in the scene to be called according to the method object, thereby achieving the effect of accurately determining the interface to be called.

[0079] S330: Call the interface to be called to implement the function corresponding to the interface to be called.

[0080] The technical solution of the embodiment of the present invention calls the constructed interface determination function with the interface call parameters as input parameters, so as to determine the interface to be called in the scene to be called corresponding to the interface call parameters in the mapping relationship, thereby achieving the effect of accurate determination of the interface to be called.

[0081] In order to better understand the specific implementation process of the above steps, the interface calling method of this embodiment is exemplarily described below with reference to specific examples.

[0082] 1) Add the runtime class annotation @Deal and method annotation @Action. At this time, the class annotation and method annotation can be understood as labels, and each label is given to the corresponding class and method, wherein the class and the scene have a correspondence, and the method in the class and the interface in the scene have a correspondence, so that the labeled class and method can be called at the only entrance set in each embodiment of the present invention.

[0083] 2) Add the entity class DealAction with class annotations and method annotations, in which the following fields can be added: code (transaction code defined in the method annotation), beanName (class name), bean (class object) and method (method), and the corresponding get (value) method and set (value setting) method. In other words, DealAction stores the code, beanName, bean and method of the class / method, so that various tagged classes / methods can be stored in DealAction. At this time, DealAction can be understood as a mapping relationship, key-value pair, list, collection, etc. The mapping relationship can be stored in the memory, and the subsequent only entry is to determine which classes / methods are tagged and can be called through DealAction.

[0084] 3) Add the annotation processing class DealActionHolder, define the method postProcess in DealActionHolder, and store the tagged class / method in DealAction based on DealActionHolder. This is the definition process, and step 4) stores the tagged class / method in DealAction by calling postProcess during the initialization scan. This is the execution process. Specifically,

[0085] Ⅰ. Add a static Map type member variable findDealAtionCache to DealActionHolder and initialize it. FindDealAtionCache is equivalent to a key-value pair.

[0086] Ⅱ. Add the static method postProcess(Object bean,String beanName) to initialize and assign findDealAtionCache. Its input parameters are bean and beanName. The Deal annotation is a class annotation and the Action annotation is a method annotation. It first puts the relevant content of the Deal annotation into dealBean, and then puts the relevant content of the Action annotation in the content into dealBean (that is, reads all methods in the Action annotation in a loop). For the specific implementation process, please refer to the following 5 steps:

[0087] ① Get the Deal annotation of the class through the bean in the input parameter. If the Deal annotation is empty, return directly; otherwise, continue to execute downward;

[0088] ② Get the method array methods of all methods through bean. If the method array is not empty, loop to get the method object method in the method array;

[0089] ③ Get the Action annotation of the method during the loop. If the Action annotation is not empty, get the transaction code of the Action annotation. If the code is empty, throw an exception; otherwise, continue to execute downward;

[0090] ④According to the code, get the DealAction object from findDealAtionCache. If it already exists, throw an exception prompt, otherwise continue to execute;

[0091] ⑤Create a new DealAction object, set the corresponding bean, beanName, method and code, and add it to the method array;

[0092] III. Add the static method findDealAction(String code) to query the annotation object according to the code. This method obtains the corresponding DealAction object from the Map findDealAtionCache according to the passed parameter code and returns it.

[0093] 4) Add the annotation scanning class DealActionScannerConfigurer and implement the spring post-processor interface BeanPostProcessor, specifically:

[0094] Ⅰ. Rewrite postProcessBeforeInitialization and postProcessAfterInitialization. It should be noted that the rewriting process of postProcessBeforeInitialization is executed after instantiation, dependency injection, and before initialization. The rewriting process of postProcessBeforeInitialization is executed after instantiation, dependency injection, and initialization.

[0095] Ⅱ. Return the passed bean directly in the postProcessBeforeInitialization method;

[0096] III. In the postProcessAfterInitialization method, call postProcess in DealActionHolder to scan and add Deal and Action objects and write them into findDealAtionCache.

[0097] 5) Add the FacadeService class (interface service class) to execute the annotated method excute. This step defines a unique entry to unify various interfaces to this unique entry so that the front end can call the interface through this unique entry without having to call it through different interfaces. Specifically,

[0098] Ⅰ. Add the execution annotation method excute (in excute, you can add time-consuming monitoring, synchronization and asynchronization, filtering, adding transaction logs and other functions), pass in the transaction code code and variable-length parameter args, and throw the method exception Exception - excute includes parameters and parameters passed from the front end to the back end

[0099] Ⅱ. Get the DealAction object dealAction through findDealAction(code) in DealActionHolder. If dealAction is not empty, it means that the current transaction code has been defined, and continue to execute;

[0100] III. Get the class object (bean) and method object (method) from dealAction;

[0101] IV. Reflectively execute the method and return the content returned by the method, that is, excute can find the corresponding bean and the method in the bean according to the input parameters, and execute the method.

[0102] 6) The method of annotating the Service object with @Deal and the Services object with @Action. It should be noted that the previous steps are equivalent to the process of defining tags, and this step is equivalent to the process of labeling.

[0103] 7) Add the entry class WebController to implement the calling process of the only entry, and 5) is to call the corresponding method according to the corresponding input parameters when the only entry is called. Specifically,

[0104] Ⅰ. Annotate @Autowired to inject FacadeService object fs;

[0105] Ⅱ. Add the mapping method test of the request test.do, and the input parameter is paramJson;

[0106] III. Obtain the transaction code tranId and parameter object data through Json conversion;

[0107] IV. Define the returned Man resultMap and the returned transaction status bkStatus (e.g., 00 means the transaction is normal) and the returned description bkDesc;

[0108] Ⅴ. Use ternary operation to determine whether data is empty. If so, execute the execute method of FacadeService without passing variable parameters. Otherwise, pass data as variable parameters, execute execute to obtain the return object resultObj, and write it into respObj in resultMap of Controller return object.

[0109] VI. Capture exceptions during the execution of execute, change the transaction status bkStatus to 01, and put the acquired exception information into bkDesc;

[0110] Ⅶ. Write the transaction status bkStatus and return description bkDesc into the returned object resultMap.

[0111] In the above example, by unifying the only entry point of the Java background service, a series of operations can be added to the execute method in the FacadeService class, such as:

[0112] 1. Time-consuming monitoring is achieved by recording the execution time of the reflection method;

[0113] 2. Control the synchronous and asynchronous execution of the reflection method through the synchronous and asynchronous parameters in the passed args;

[0114] 3. Transaction filtering is achieved by judging the data of the incoming args;

[0115] 4. By classifying the codes (such as adding, deleting, modifying and checking), the operation flow records for different needs can be realized.

[0116] Embodiment 4

[0117] Figure 4 This is a structural block diagram of an interface calling device provided in Embodiment 4 of the present invention. The device is used to execute the interface calling method provided in any of the above embodiments. The device and the interface calling method of each of the above embodiments belong to the same inventive concept. For details not described in detail in the embodiment of the interface calling device, please refer to the embodiment of the above interface calling method. Figure 4 The device is configured on a server and may specifically include: a parameter acquisition module 410, an interface determination module 420 and an interface calling module 430.

[0118] The parameter acquisition module 410 is used to acquire the interface call parameters corresponding to the triggering event when the triggering event of the interface call is detected;

[0119] The interface determination module 420 is used to determine the interface to be called in the to-be-called scenario corresponding to the interface call parameter in the mapping relationship, wherein the mapping relationship is pre-constructed by annotating dynamic mapping;

[0120] The interface calling module 430 is used to call the interface to be called to implement the function corresponding to the interface to be called.

[0121] Optionally, on this basis, the interface calling device may further include:

[0122] The entity class acquisition module is used to obtain the class annotations and method annotations of the custom runtime, and the entity classes corresponding to the class annotations and method annotations;

[0123] The mapping relationship building module is used to write class annotations and method annotations into entity classes based on a preset annotation scanning class, and to build a mapping relationship based on the written entity classes.

[0124] Optionally, the entity class is provided with a transaction code, a class name, a class object and a method.

[0125] Optionally, the mapping relationship building module may specifically include:

[0126] The annotation writing unit is used to obtain the class object and class name as input parameters, call the constructed annotation writing function, and write the class annotation and method annotation into the entity class;

[0127] The annotation writing function is set in a preset annotation processing class, in which a mapping variable is set. The annotation writing function writes the class annotation and the method annotation into the entity class through the mapping variable, and the mapping variable is a static Map type member variable.

[0128] Optionally, the annotation writing function implements the annotation writing function through the following subunits:

[0129] The method array judgment subunit is used to determine the class annotation corresponding to the class object, and when the class annotation is not empty, obtain the method array composed of the methods associated with the class object, and judge whether the method array is empty;

[0130] The transaction code acquisition subunit is used to, if not, sequentially acquire each method object in the method array and the method annotation of each method object, and acquire the transaction code of the method annotation when the method annotation is not empty;

[0131] The annotation writing subunit is used to obtain the entity object corresponding to the class name and class object from the mapping variable according to the transaction code when the transaction code is not empty, and write the class annotation and method annotation into the entity class based on the entity object, wherein the entity object is an object in the entity class.

[0132] Optionally, based on the above device, the device may further include: an annotation module, used to annotate the interface to be called through method annotations, and to annotate the scenario to be called through class annotations.

[0133] Optionally, the interface determination module 420 may specifically include:

[0134] The first interface determination unit is used to call the constructed interface determination function with the interface call parameters as input parameters to determine the interface to be called in the to-be-called scenario corresponding to the interface call parameters in the mapping relationship, wherein the interface determination function is set in the interface service class, and the interface service class includes the FacadeService class.

[0135] Optionally, the interface determination function implements the interface determination function through the following subunits:

[0136] The object acquisition subunit is used to acquire the entity object corresponding to the interface call parameter, and when the entity object is not empty, acquire the class object and method object from the entity object;

[0137] The interface determination subunit is used to determine the to-be-called scenario in the mapping relationship according to the class object, and to determine the to-be-called interface in the to-be-called scenario according to the method object.

[0138] Optionally, the parameter acquisition module 410 may specifically include:

[0139] A parameter acquisition unit, used to acquire interface call parameters corresponding to the trigger event based on the entry class, wherein the interface service object of the interface service class is injected into the entry class by annotation;

[0140] On this basis, optionally, the interface determination module 420 may specifically include:

[0141] The second interface determination unit is used to determine the interface to be called in the to-be-called scenario corresponding to the interface call parameter in the mapping relationship through the interface service object in the entry class.

[0142] Optionally, the interface calling module 430 may be specifically used for:

[0143] Call the interface to be called to record the execution time of the preset reflection algorithm to monitor the time consumption; or,

[0144] Calling the interface to be called to control the synchronous and asynchronous execution of the preset reflection algorithm according to the synchronous and asynchronous parameters in the variable-length parameters in the interface calling parameters; or,

[0145] Call the interface to be called to judge the variable-length parameters to filter the data; or,

[0146] Call the interface to be called to classify the transaction code in the interface call parameters to realize the operation flow record under the corresponding requirements.

[0147] Optionally, the mapping relationship stores the correspondence between the interface calling parameters, the scenario to be called, and the interface to be called.

[0148] The interface calling device provided in the fourth embodiment of the present invention cooperates with the parameter acquisition module and the interface determination module. When the unique entry in the server receives the interface calling parameters transmitted via the front end, it can obtain the interface to be called in the corresponding scene to be called in the mapping relationship according to the interface calling parameters; thus, the interface calling module can implement the corresponding function by calling the interface to be called. The above device provides a simpler, more flexible, more unified and standardized interface calling method. The calling process of each interface in various scenarios can be unified in the unique entry, thereby solving the problem of the difficulty of implementing interface calling, reducing the workload of developers, and improving the efficiency of subsequent interface calling.

[0149] The interface calling device provided in the embodiment of the present invention can execute the interface calling method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0150] It is worth noting that in the embodiment of the above-mentioned interface calling device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.

[0151] Embodiment 5

[0152] Figure 5 A schematic diagram of the structure of a server provided in Embodiment 5 of the present invention is shown in FIG. Figure 5 As shown, the server includes a memory 510, a processor 520, an input device 530, and an output device 540. The number of processors 520 in the server can be one or more. Figure 5 A processor 520 is used as an example; the memory 510, the processor 520, the input device 530 and the output device 540 in the server can be connected via a bus or other means. Figure 5 The connection via bus 550 is taken as an example.

[0153] The memory 510, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the interface calling method in the embodiment of the present invention (for example, the parameter acquisition module 410, the interface determination module 420 and the interface calling module 430 in the interface calling device). The processor 520 executes various functional applications and data processing of the server by running the software programs, instructions and modules stored in the memory 510, that is, implements the above-mentioned interface calling method.

[0154] The memory 510 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the server, etc. In addition, the memory 510 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 510 may further include a memory remotely arranged relative to the processor 520, and these remote memories may be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0155] The input device 530 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the device. The output device 540 may include a display device such as a display screen.

[0156] Embodiment 6

[0157] Embodiment 6 of the present invention provides a storage medium containing computer executable instructions, wherein the computer executable instructions are used to execute an interface calling method when executed by a computer processor. The method is applied to a server and may include:

[0158] When a triggering event of an interface call is detected, the interface call parameters corresponding to the triggering event are obtained;

[0159] Determine the interface to be called in the scenario to be called corresponding to the interface call parameter in the mapping relationship, wherein the mapping relationship is pre-built by way of annotation dynamic mapping;

[0160] Call the interface to be called to implement the function corresponding to the interface to be called.

[0161] Of course, the computer executable instructions of a storage medium including computer executable instructions provided by an embodiment of the present invention are not limited to the method operations described above, and can also execute related operations in the interface calling method provided by any embodiment of the present invention.

[0162] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0163] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. An interface calling method, characterized in that: Applied to a server, and suitable for calling interfaces corresponding to various requirements in various scenarios through a unique entrance, the method includes: When a triggering event of an interface call is detected, obtaining an interface call parameter corresponding to the triggering event; Determine the interface to be called in the scenario to be called corresponding to the interface call parameter in the mapping relationship, wherein the mapping relationship is pre-built by annotating dynamic mapping; wherein the mapping relationship stores the corresponding relationship between the interface call parameter, the scenario to be called and the interface to be called; the scenario to be called refers to the scenario to be called corresponding to the interface call parameter in each scenario, including a scenario associated with a financial transaction; the interface call parameter includes at least a transaction code and a variable-length parameter; Calling the interface to be called to implement the function corresponding to the interface to be called; The calling of the to-be-called interface to implement the function corresponding to the to-be-called interface includes: Calling the interface to be called to record the execution time of the preset reflection algorithm to monitor the time consumption; or, Calling the interface to be called to control the synchronous and asynchronous execution of the preset reflection algorithm according to the synchronous and asynchronous parameters in the variable-length parameters in the interface calling parameters; or, Calling the interface to be called to judge the variable-length parameter to filter data; or, Calling the interface to be called to classify the transaction code in the interface calling parameter to realize the operation flow record under the corresponding requirements; The mapping relationship is pre-built through the following steps: Obtaining the class annotation and method annotation of the custom runtime, and the entity class corresponding to the class annotation and the method annotation, and writing the class annotation and the method annotation into the entity class based on a preset annotation scanning class, and constructing the mapping relationship based on the written entity class; wherein the entity class is provided with a transaction code, a class name, a class object and a method; The method further includes: annotating the interface to be called by the method annotation, and annotating the scenario to be called by the class annotation.

2. The method according to claim 1, characterized in that The step of writing the class annotation and the method annotation into the entity class based on a preset annotation scanning class includes: Using the obtained class object and the class name as input parameters, calling the constructed annotation writing function to write the class annotation and the method annotation into the entity class; The annotation writing function is set in a preset annotation processing class, a mapping variable is set in the annotation processing class, and the annotation writing function writes the class annotation and the method annotation into the entity class through the mapping variable, and the mapping variable is a static Map type member variable.

3. The method according to claim 2, characterized in that The annotation writing function implements the annotation writing function through the following steps: Determine the class annotation corresponding to the class object, and when the class annotation is not empty, obtain a method array consisting of the methods associated with the class object, and determine whether the method array is empty; If not, then sequentially obtain each method object in the method array and the method annotation of each method object, and when the method annotation is not empty, obtain the transaction code of the method annotation; When the transaction code is not empty, an entity object corresponding to the class name and the class object is obtained from the mapping variable according to the transaction code, and the class annotation and the method annotation are written into the entity class based on the entity object, wherein the entity object is an object in the entity class.

4. The method according to claim 1, characterized in that The determining, in the mapping relationship, the interface to be called in the scenario to be called corresponding to the interface calling parameter includes: The interface determination function that has been constructed is called with the interface call parameters as input parameters to determine the interface to be called in the to-be-called scenario corresponding to the interface call parameters in the mapping relationship, wherein the interface determination function is set in the interface service class, and the interface service class includes the FacadeService class.

5. The method according to claim 4, characterized in that The interface determination function implements the interface determination function through the following steps: Acquire an entity object corresponding to the interface call parameter, and when the entity object is not empty, acquire a class object and a method object from the entity object; The scenario to be called is determined in the mapping relationship according to the class object, and the interface to be called is determined in the scenario to be called according to the method object.

6. The method according to claim 1, characterized in that The obtaining of the interface call parameters corresponding to the trigger event includes: obtaining the interface call parameters corresponding to the trigger event based on an entry class, wherein the interface service object of the interface service class is injected into the entry class by annotation.

7. The method according to claim 6, characterized in that The determining, in the mapping relationship, the interface to be called in the scenario to be called corresponding to the interface calling parameter includes: The interface to be called in the to-be-called scenario corresponding to the interface calling parameters is determined in the mapping relationship through the interface service object in the entry class.

8. An interface calling device, characterized in that: The device is configured on a server and is suitable for calling interfaces corresponding to various requirements in various scenarios through a unique entrance. The device includes: A parameter acquisition module, used to acquire the interface call parameters corresponding to the trigger event when a trigger event of the interface call is detected; An interface determination module, used for determining the interface to be called in the to-be-called scenario corresponding to the interface call parameter in a mapping relationship, wherein the mapping relationship is pre-constructed by annotating dynamic mapping; wherein the mapping relationship stores the corresponding relationship between the interface call parameter, the to-be-called scenario and the to-be-called interface; the to-be-called scenario refers to the to-be-called scenario corresponding to the interface call parameter in each scenario, including a scenario associated with a financial transaction; the interface call parameter includes at least a transaction code and a variable-length parameter; An interface calling module, used to call the interface to be called to implement the function corresponding to the interface to be called; The calling of the to-be-called interface to implement the function corresponding to the to-be-called interface includes: Calling the interface to be called to record the execution time of the preset reflection algorithm to monitor the time consumption; or, Calling the interface to be called to control the synchronous and asynchronous execution of the preset reflection algorithm according to the synchronous and asynchronous parameters in the variable-length parameters in the interface calling parameters; or, Calling the interface to be called to judge the variable-length parameter to filter data; or, Calling the interface to be called to classify the transaction code in the interface calling parameter to realize the operation flow record under the corresponding requirements; The mapping relationship is pre-built through the following steps: Obtaining the class annotation and method annotation of the custom runtime, and the entity class corresponding to the class annotation and the method annotation, and writing the class annotation and the method annotation into the entity class based on a preset annotation scanning class, and constructing the mapping relationship based on the written entity class; wherein the entity class is provided with a transaction code, a class name, a class object and a method; Wherein, the device further comprises: The annotation module is used to annotate the interface to be called through the method annotation, and to annotate the scenario to be called through the class annotation.

9. A server, characterized in that: include: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the interface calling method as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the interface calling method as described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Interface call data processing method and apparatus, and computer device

    CN108255905A

  • Data processing method and device, computer equipment and storage medium

    CN111027295A