Interface calling method and device, computer storage medium and electronic equipment
By registering and uniformly processing called interfaces in the service registration center, the problem of large number of interfaces and high difficulty in expansion in the existing technology is solved, and flexible configuration interfaces and permission verification are realized, reducing the difficulty of business maintenance and expansion costs.
Patent Information
- Application Number
- CN202310862987.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-13
- Publication Date
- 2025-01-14
AI Technical Summary
In the prior art, backend developers need to provide multiple interfaces for each module, which makes it difficult to expand business, and the workbench interface is fixed, lacks flexible configuration, and there are problems such as risk of overreach of authority and difficulty in development.
By registering the called interface in the service registration center and using the center to uniformly process the front-end call requests, data interaction between multiple called interfaces is realized, the number of interfaces and maintenance difficulty is reduced, and flexible configuration interfaces and permission verification is supported.
It realizes data interaction with multiple called interfaces through a common interface, reducing the difficulty of business maintenance and expansion costs, supporting flexible configuration interfaces and permission verification, and avoiding overprivileged operations.
Smart Images

Figure CN119311336A_ABST
Abstract
Description
Background Art
[0002] The workbench is used to display summary information related to the user. It helps the user quickly understand the previous work status, current task progress, and future work arrangements through various summary information. These summary information are unified on one page and displayed in multiple modules. Figure 1A , Figure 1A A schematic diagram of the page of the above workbench is shown, such as Figure 1A As shown, a user's workbench page can be divided into five modules. These five modules are: workflow, batch operation (that is, the user can operate on multiple objects at the same time), my tasks, work item notifications, and waiting for my approval. Each module contains different types of work information related to the user, so that the user can quickly obtain the required information and improve his work efficiency.
[0003] Currently, backend developers need to provide each module with its own interface so that it can interact with external business interfaces through the interface. However, this solution requires the maintenance of multiple interfaces, making business expansion difficult.
[0004] In view of this, there is an urgent need in the art to develop a new interface calling method and device.
[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure. Summary of the invention
[0006] The purpose of the present disclosure is to provide an interface calling method, an interface calling device, a computer storage medium and an electronic device, thereby overcoming the technical problem of difficulty in business expansion caused by the limitations of related technologies at least to a certain extent.
[0007] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.
[0008] According to the first aspect of the present disclosure, there is provided an interface calling method, comprising: upon receiving an interface calling instruction input through a preset operation page, obtaining interface configuration information of the called interface; the interface calling instruction includes calling parameters of the called interface, and the called interface is a business interface pre-registered in a service registration center; based on the interface configuration information and the calling parameters, creating a calling request for the called interface; and sending the calling request to the called interface through the service registration center to implement the calling of the called interface.
[0009] In an exemplary embodiment of the present disclosure, the interface calling instruction also includes an indication identifier of the called interface, and when the interface calling instruction input through a preset operation page is received, the interface configuration information of the called interface is obtained, including: according to the indication identifier of the called interface, searching for the correspondence between the preset indication identifier and the interface configuration information, and obtaining the interface configuration information of the called interface.
[0010] In an exemplary embodiment of the present disclosure, the interface configuration information includes input parameter description information of the called interface; creating a call request message for the called interface based on the interface configuration information and the call parameters includes: performing structural conversion on the call parameters based on the input parameter description information to obtain interface input parameters; encapsulating and packaging the interface input parameters to obtain a call request for the called interface.
[0011] In an exemplary embodiment of the present disclosure, sending the call request to the called interface through the service registration center includes: obtaining a call instance corresponding to the called interface; running the call instance to control the registration service center to send the call request to the called interface.
[0012] In an exemplary embodiment of the present disclosure, obtaining the calling instance corresponding to the called interface includes: based on the interface configuration information, querying whether there is a historical calling instance corresponding to the called interface in a preset storage location; if the historical calling instance exists, determining the historical calling instance as the acquired calling instance; if the historical calling instance does not exist, determining the calling instance created according to the interface configuration information as the acquired calling instance.
[0013] In an exemplary embodiment of the present disclosure, after sending the calling request to the called interface through the service registration center, the method also includes: in response to not receiving response data for the calling request returned by the called interface within a preset time period, interrupting the calling of the called interface by the service registration center.
[0014] In an exemplary embodiment of the present disclosure, the method further includes: in response to monitoring that the called interface is in an abnormal state, returning pre-configured abnormal prompt information to the front end, so that the front end displays the abnormal prompt information.
[0015] In an exemplary embodiment of the present disclosure, before receiving an interface call instruction input through a preset operation page, the method also includes: when receiving login verification information input by a user, obtaining a target resource to which the user has access rights based on the login verification information; after the login verification information is verified, returning the target resource to the front end; so that the front end renders the target resource to generate the preset operation page, and displays the preset operation page to the user.
[0016] In an exemplary embodiment of the present disclosure, the login verification information includes the identity of the user; obtaining the target resource to which the user has access rights based on the login verification information includes: searching for a correspondence between a pre-configured identity and a resource identifier based on the identity to obtain the target resource identifier to which the user has access rights; and filtering a pre-acquired basic resource set based on the target resource identifier to obtain the target resource to which the user has access rights.
[0017] In an exemplary embodiment of the present disclosure, the basic resource set includes at least one resource block; each of the resource blocks includes at least one resource unit; and each of the resource units includes at least one basic resource.
[0018] According to the second aspect of the present disclosure, an interface calling device is provided, comprising: an information acquisition module, used to obtain interface configuration information of the called interface when receiving an interface calling instruction input through a preset operation page; the interface calling instruction includes calling parameters of the called interface, and the called interface is a business interface pre-registered in a service registration center; a request creation module, used to create a calling request for the called interface based on the interface configuration information and the calling parameters; and an interface calling module, used to send the calling request to the called interface through the service registration center to implement the calling of the called interface.
[0019] According to a third aspect of the present disclosure, a computer storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the interface calling method described in the first aspect is implemented.
[0020] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the interface calling method described in the first aspect above by executing the executable instructions.
[0021] It can be seen from the above technical solutions that the interface calling method, interface calling device, computer storage medium and electronic device in the exemplary embodiments of the present disclosure have at least the following advantages and positive effects:
[0022] In the technical solutions provided in some embodiments of the present disclosure, on the one hand, by using the service registration center as a universal interface to process the call request issued by any module of the front end, it is possible to implement data interaction with multiple called interfaces through a universal interface, thereby avoiding the technical problems of too many interfaces and difficulty in business maintenance caused by the need to configure interfaces for each module in related technologies, thereby reducing the difficulty and cost of business maintenance; on the other hand, when it is necessary to connect to a new called interface, it is only necessary for the new called interface to be pre-registered in the service registration center, and then, the interface configuration information corresponding to the new called interface is pre-configured, so that the call to the new called interface can be conveniently implemented without making changes to the code level, thereby reducing the difficulty and cost of business expansion.
[0023] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0025] Figure 1A A schematic diagram of a workbench page is shown;
[0026] Figure 1B A schematic diagram showing a flow chart of an interface calling method in an embodiment of the present disclosure;
[0027] Figure 2 A schematic diagram showing how to hierarchically divide a basic resource set in an embodiment of the present disclosure;
[0028] Figure 3 A flowchart showing how to configure the corresponding relationship between the identity identifier of a user and the resource identifier to which the user has access rights in an embodiment of the present disclosure;
[0029] Figure 4 A schematic diagram showing a flow chart of how to generate a preset operation page in an embodiment of the present disclosure;
[0030] Figure 5 A schematic diagram showing a flow chart of how to obtain a target resource for which a user has access rights in an embodiment of the present disclosure;
[0031] Figure 6A schematic diagram showing how to set the corresponding relationship between the identity identifier of a user and the identifier of a resource to which the user has access rights in an embodiment of the present disclosure;
[0032] Figure 7 A schematic diagram showing a flow chart of how to obtain a calling instance corresponding to a called interface in an embodiment of the present disclosure;
[0033] Figure 8 The overall flow diagram of the interface calling method in the embodiment of the present disclosure is shown;
[0034] Fig. 9 An overall schematic diagram of an interface calling method in an embodiment of the present disclosure is shown;
[0035] Fig.10 A schematic diagram showing the structure of an interface calling device in an exemplary embodiment of the present disclosure is shown;
[0036] Fig.11 A schematic structural diagram of an electronic device in an exemplary embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0037] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0038] The terms "a", "an", "the" and "said" are used in this specification to indicate the presence of one or more elements / components / etc.; the terms "including" and "having" are used to express an open-ended inclusion and mean that additional elements / components / etc. may exist in addition to the listed elements / components / etc.; the terms "first" and "second" etc. are used only as labels and are not intended to limit the quantity of their objects.
[0039] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings represent the same or similar parts, and their repeated descriptions will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities.
[0040] The operation workbench should help users get an overview and quickly grasp the work progress, provide action guidance, and support quick business operations. The workbench involves scenarios such as menu navigation and business data display, in which the displayed data generally relies on multi-party data services.
[0041] At present, the operation-side workbench generally displays data through the following solutions:
[0042] For menu navigation, the front end sets a fixed menu jump path; for business data display, the back end independently provides corresponding data interfaces for different business modules, and the front end writes a fixed page call interface for data display.
[0043] However, the above solution has the following defects:
[0044] First, the workbench interface is fixed. To adjust the module order, menu navigation, and text display, the front end needs to modify the code and re-launch, which does not have flexible configuration.
[0045] Second, the backend needs to provide an interface for each module, which is not only troublesome to maintain, but also not scalable. Every time a new data module is added, new interface logic needs to be developed accordingly.
[0046] Third, operators can operate modules beyond their authority, which poses a risk of exceeding their authority.
[0047] In the embodiments of the present disclosure, firstly, an interface calling method is provided, which at least to some extent overcomes the defect of great difficulty in business expansion in the related art.
[0048] Figure 1B A flow chart of an interface calling method in an embodiment of the present disclosure is shown. The execution subject of the interface calling method may be a server that calls a service.
[0049] refer to Figure 1B According to an embodiment of the present disclosure, the interface calling method includes the following steps:
[0050] Step S110, when receiving the interface calling instruction input through the preset operation page, obtaining the interface configuration information of the called interface; the interface calling instruction includes the calling parameters of the called interface, and the called interface is a business interface pre-registered in the service registration center;
[0051] Step S120, creating a call request for the called interface based on the interface configuration information and the call parameters;
[0052] Step S130, sending a call request to the called interface through the service registration center to implement the call of the called interface.
[0053] exist Figure 1B In the technical solution provided by the illustrated embodiment, on the one hand, by using the service registration center as a universal interface to process the call request issued by any module of the front end, it is possible to implement data interaction with multiple called interfaces through a universal interface, thereby avoiding the technical problems of too many interfaces and difficulty in business maintenance caused by the need to configure interfaces for each module in related technologies, thereby reducing the difficulty and cost of business maintenance; on the other hand, when it is necessary to connect to a new called interface, it is only necessary for the new called interface to be pre-registered in the service registration center, and then, the interface configuration information corresponding to the new called interface is pre-configured, so that the call to the new called interface can be conveniently implemented without making changes to the code level, thereby reducing the difficulty and cost of business expansion.
[0054] The following Figure 1B The specific implementation process of each step is described in detail:
[0055] First of all, it should be noted that the present disclosure can be applied to business platforms involving menu navigation and data display. Exemplarily, taking the business platform as an operation workbench as an example, the operation workbench may include multiple display modules, such as: a to-do module (used to remind users of the current work or tasks that need to be processed. Depending on the business and role, the content of the to-do list will also be different), a data display module (used to display recent key data, so that users can quickly obtain relevant data without having to go to the statistics page for screening and viewing), an announcement module (used for notifications of daily personnel and administrative matters), a toolbar module (for example, some commonly used functions can be placed, such as: speed dial, calculator, etc.), and a quick entry module (the user's frequently used pages can be displayed by default according to different roles).
[0056] Given that the users who log in to the above-mentioned operation workbench may include multiple roles, such as: financial role, management role, project development role, personnel role, etc., and different roles need to view different modules, data, etc., therefore, the present disclosure can display different preset operation pages for different users, so as to display resources that match their permissions for different users and prevent users from exceeding their authority.
[0057] In order to achieve the above-mentioned purpose, the present invention first divides the basic resource set involved in building the above-mentioned operation workbench (the basic resource set contains multiple basic resources) into levels, and assigns a unique identifier to each basic resource according to the level at which each basic resource is located, so as to realize the clear record of a large number of fine-grained resources and realize the transformation of resources from disorder to order.
[0058] Since each basic resource corresponds to a unique identifier, it is convenient to quickly and easily set the correspondence between each user and the resource identifier to which he or she has access rights. It is also convenient to display different basic resources to different roles based on the identifier of the basic resource. This avoids the technical problems of high development difficulty and high business costs caused by the need to develop interfaces that are compatible with different roles in related technologies. When a new role is added, an interface that is compatible with the new role's permissions can be quickly displayed without modifying the code.
[0059] Specifically, refer to Figure 2 , Figure 2 A schematic diagram showing how to hierarchically divide a basic resource set in an embodiment of the present disclosure is shown in FIG. Figure 2 As shown:
[0060] The resource hierarchy may include three layers (it may also be divided into finer granularity according to actual conditions, for example: five layers, which is not specifically limited in this disclosure), the first layer is the resource block, the second layer is the resource unit, and the third layer is the basic resource, and the resource granularity gradually decreases from the first layer to the third layer. There is a parent-child relationship between the first layer and the second layer, and there is a parent-child relationship between the second layer and the third layer, that is, a resource block may contain at least one resource unit, and a resource unit may contain at least one basic resource.
[0061] Exemplarily, the resource block in the present disclosure may be a business module, the resource unit may be an element contained in each business module, and the basic resource may be specific data contained in each element (e.g., display style data). For example, take the case where two resource units (X1 and X2) are contained in the X resource block, and the basic resources A and B belong to X1, and the basic resource C belongs to X2 as an example, then the basic resource A may be assigned an identifier X11, the basic resource B may be assigned an identifier X12, and the basic resource C may be assigned an identifier X21. Thus, assuming that user UserX has access rights to basic resource A, user UserY has access rights to basic resource B, and user UserZ has access rights to basic resource C, the identity of user UserX may be bound to identifier X11, the identity of user UserY may be bound to identifier X12, and the identity of user UserZ may be bound to identifier X21. Similarly, a corresponding relationship between the identity of a user and the resource identifier to which he has access rights is established, so that the target resource to which each user has access rights is obtained based on the corresponding relationship, thereby generating a preset operation page corresponding to each user based on the target resource.
[0062] It should be noted that after the resources are divided into levels and the correspondence between the user's identity and the resource identifier to which he has access rights is set, the division results and the correspondence can be synchronized to the cache in real time to alleviate the pressure on the database and improve the efficiency of subsequent information queries.
[0063] By effectively distinguishing the basic resources to which different users have access rights, it is possible to quickly and conveniently display resources that match their permissions to different users, preventing users from exceeding their authority.
[0064] refer to Figure 3 , Figure 3 A flow chart showing how to configure the correspondence between the user's identity identifier and the resource identifier to which the user has access rights in the embodiment of the present disclosure includes steps S301 to S305:
[0065] In step S301, start;
[0066] In step S302, hierarchical division is performed to set a correspondence between the user's identity identifier and the resource identifier to which the user has access rights;
[0067] In step S303, the hierarchical division result and the above correspondence are saved in a database;
[0068] In step S304, the hierarchical division result and the above correspondence are saved in a cache;
[0069] In step S305, end.
[0070] After configuring the correspondence between the user's identity and the resource identifiers to which the user has access rights, the specific implementation method of how to generate the preset operation page in step S110 is explained next.
[0071] refer to Figure 4 , Figure 4 A flowchart showing how to generate a preset operation page in an embodiment of the present disclosure includes steps S401 to S403:
[0072] In step S401, when the login verification information input by the user is received, the target resource to which the user has access rights is obtained according to the login verification information.
[0073] In this step, when the backend of the operation workbench receives the user's login verification information, it can query the target resources to which the user has access permissions based on the login verification information.
[0074] Exemplarily, the above login verification information may include the user's identity, such as: the user's name, ERP account (Enterprise Resource Planning) or ID number, etc., so that the correspondence between the above pre-configured identity and resource identifier can be queried to obtain the target resource identifier to which the user has access rights.
[0075] After determining the target resource identifier, the basic resource set of the operation workbench can be obtained from the cache. The basic resource set is all the basic resources of the operation workbench. Since each resource has a corresponding identifier, the basic resource set can be filtered according to the target resource identifier to filter out the target resources to which the user has access rights.
[0076] refer to Figure 5 , Figure 5 A flowchart showing how to obtain a target resource to which a user has access rights in an embodiment of the present disclosure includes steps S501 to S505:
[0077] In step S501, start;
[0078] In step S502, a basic resource set of the operation workbench is obtained from the cache;
[0079] In step S503, the target resource identifier to which the user has access rights is queried;
[0080] In step S504, the basic resource set is filtered according to the target resource identifier to obtain the target resource to which the user has access rights;
[0081] In step S505, end.
[0082] refer to Figure 6 , Figure 6 A schematic diagram showing how to set the correspondence between the user's identity identifier and the resource identifier to which the user has access rights in an embodiment of the present disclosure includes steps S601 to S605:
[0083] In step S601, the operator divides the resources into different levels;
[0084] In step S602, the hierarchical division result is stored in a database;
[0085] In step S603, the hierarchical division result is stored in a cache;
[0086] In step S604, the hierarchical division result in the cache is queried;
[0087] In step S605, the operator performs permission filtering for each user and sets a corresponding relationship between the user's identity identifier and the resource identifier to which the user has access permission.
[0088] Next reference Figure 4 In step S402, after the login verification information is verified, the target resource is returned to the front end.
[0089] In this step, after filtering out the target resources corresponding to the user, the target resources can be returned to the front end after the user's login information is verified.
[0090] In step S403, the front end renders the target resource to generate a preset operation page, and displays the preset operation page to the user.
[0091] In this step, after receiving the above-mentioned target resources, the front end can render the above-mentioned target resources to generate a preset operation page, and then, can display the above-mentioned preset operation page to the above-mentioned user, so as to display the pages corresponding to their resource access rights for different users or roles, and avoid users from exceeding their authority.
[0092] After the above-mentioned preset operation page is generated, the user can operate through the above-mentioned preset operation page to input the interface calling instruction, so that the back end can receive the above-mentioned receiving calling instruction.
[0093] Next reference Figure 1B In step S110, when an interface calling instruction input through a preset operation page is received, interface configuration information of the called interface is obtained.
[0094] In this step, the called interface is a business interface that has been pre-registered in the service registration center.
[0095] Among them, the above-mentioned service registration center is a unified interface pre-configured by the present disclosure to interact with external called interfaces. Each called interface needs to be registered in the service registration center to declare the services it provides, so that the subsequent service registration center can quickly call the corresponding called interface. After having a service registration center, when you need to call other called interfaces, you only need to know the indication identifier of other called interfaces (such as service name, etc.), and you can make interface calls in the service registration center through the indication identifier.
[0096] The above interface calling instruction may include an indication mark of the called interface and calling parameters of the called interface.
[0097] Therefore, after receiving the above-mentioned interface call instruction, the back end can search the correspondence between the pre-set indication identifier and the interface configuration information in the generalized configuration database according to the interface identifier of the above-mentioned called interface (used to distinguish each called interface) to obtain the interface configuration information of the called interface.
[0098] The interface configuration information may include the interface name, method name, input parameter description information, and timeout time (used to determine whether the response time of the called interface has timed out), etc., which may be set according to actual conditions, and the present disclosure does not make any special restrictions on this. The input parameter description information may include the input parameter type and the input parameter order.
[0099] After obtaining the interface configuration information of the called interface, the process may proceed to step S120 to create a call request for the called interface based on the interface configuration information and the call parameters.
[0100] In this step, the call parameters can be structurally converted based on the input parameter description information to obtain interface input parameters. Exemplarily, the call parameters can be data type converted according to the input parameter type included in the input parameter description information, and then the parameters after the data type conversion can be sequentially adjusted according to the input parameter sequence in the input parameter description information to obtain interface input parameters. Then, the interface input parameters can be encapsulated and packaged to obtain a call request for the called interface.
[0101] In step S130, a calling request is sent to the called interface through the service registration center to implement the calling of the called interface.
[0102] In this step, the calling instance corresponding to the called interface can be obtained, the calling instance can be run, and the registration service center can be controlled to send a calling request to the called interface to implement the calling of the called interface.
[0103] For example, please refer to Figure 7 , Figure 7 A flow chart showing how to obtain a calling instance corresponding to a called interface in an embodiment of the present disclosure includes steps S701 to S703:
[0104] In step S701, based on the interface configuration information, it is queried whether a preset storage location has a historical call instance corresponding to the called interface.
[0105] In this step, since the interface configuration information contains the interface name of the called interface, it is possible to query whether there is a historical call instance corresponding to the above-mentioned called interface in the preset storage location (which can be a cache) based on the interface name of the called interface, that is, to determine whether the above-mentioned called interface has been called before.
[0106] The historical call instance is the calling program used when calling the above-mentioned called interface during the historical period. The historical call instance is assembled according to the interface configuration information of the above-mentioned called interface. By running the calling program, the service registration center can be controlled to call the called interface indicated by the above-mentioned interface configuration information.
[0107] In step S702, if there is a historical call instance, the historical call instance is determined as the acquired call instance.
[0108] In this step, if the historical call instance exists in the preset storage location, the historical call instance can be directly determined as the acquired call instance.
[0109] In step S703, if there is no historical call instance, the call instance created according to the interface configuration information is determined as the acquired call instance.
[0110] In this step, if the historical call instance does not exist in the preset storage location, a call instance corresponding to the called interface may be created according to the interface configuration information obtained in step S110, and the created call instance may be determined as the obtained call instance.
[0111] It should be noted that the process of creating a call instance corresponding to the called interface can be placed in the cache in a lazy loading manner to avoid long-term occupation of system memory when the creation process is time-consuming, thereby affecting the data processing speed of the system. In addition, after the above call instance is created, the above call instance can be placed in the cache so that the subsequent call process can quickly load the call instance, thereby improving the interface call speed.
[0112] It should be noted that after sending a call request to the above-mentioned called interface through the service registration center, if the service registration center receives the response data returned by the above-mentioned called interface within the preset time, since the response data returned by different called interfaces are different, there is a problem of being unable to read. Therefore, the back-end can perform format conversion processing on the above-mentioned response data to convert it into a unified format that the back-end can recognize. Then, the back-end can return the target data obtained after the format conversion processing to the front-end, so that the front-end can display the above-mentioned target data to the user.
[0113] After sending a call request to the above-mentioned called interface through the service registration center, if no response data for the call request returned by the called interface is received within a preset time (corresponding to the timeout time in the interface configuration information of the called interface), the service registration center's call to the called interface is interrupted to avoid the service registration center being occupied for a long time and affecting the processing of other call requests.
[0114] At the same time, after sending a call request to the above-mentioned called interface through the service registration center, if the above-mentioned called interface is monitored to be in an abnormal state, the pre-configured abnormal prompt information (for example: the system is absent) will be returned to the front end, so that the front end can display the abnormal prompt information and provide friendly prompts to the user to avoid long waiting time and improve the user experience.
[0115] Based on the interface calling method disclosed in the present invention, when the operation workbench needs to connect to a new called interface, the system administrator only needs to pre-assign an indication identifier to the new called interface in the generalized configuration database and store the interface configuration information corresponding to the indication identifier. At the same time, the new called interface is pre-registered in the service registration center, and the call to the new called interface can be realized. There is no need for developers to develop new calling logic and calling code, etc., which can realize business expansion more conveniently and reduce business expansion costs.
[0116] refer to Figure 8 , Figure 8 The overall flow diagram of the interface calling method in the embodiment of the present disclosure is shown, including steps S801 to S811:
[0117] In step S801, start;
[0118] In step S802, a unified API (Application Programming Interface) interface, namely, a service registration center, is configured;
[0119] In step S803, the interface configuration information pre-configured by the system administrator is queried from the generalized configuration database according to the indication mark in the interface calling instruction;
[0120] In step S804, query whether there is a historical call instance in the cache;
[0121] If there is a historical call instance, then go to step S805 to retrieve the historical call instance from the cache, and then jump to step S808;
[0122] If the above historical call instance does not exist, proceed to step S806 to create a call instance;
[0123] In step S807, the created call instance is put into the cache;
[0124] In step S808, assemble the call request;
[0125] In step S809, the service registration center sends a call request to the called interface (e.g., inquiry and quotation system, functional system, big data center, data service system, procurement system) to obtain response data returned by the called interface;
[0126] When connecting to the called interface, if the called interface responds to a timeout, the circuit breaker will be automatically disconnected; if an exception occurs in the service registration center, a fallback exception prompt message will be returned to the front end;
[0127] In step S810, the acquired response data is format converted;
[0128] In step S811, end.
[0129] refer to Fig. 9 , Fig. 9 The overall schematic diagram of the interface calling method in the embodiment of the present disclosure is shown, including steps S901 to S905:
[0130] In step S901, an interface call instruction sent by an operator is received;
[0131] In step S902, the interface configuration information is queried from a generalized configuration database (the system administrator stores the correspondence between the indicator of each called interface and its interface configuration information in the generalized configuration database);
[0132] In step S903, the calling parameters in the interface calling instruction and the queried interface configuration information are merged to create a calling request;
[0133] In step S904, the control service registration center sends a call request to the called interface;
[0134] In step S905, generalized calling is implemented.
[0135] Based on the above technical solutions, the present disclosure can at least achieve the following technical effects:
[0136] First, realize flexible configuration of the workbench interface to reduce the amount of code modification.
[0137] Second, improve the scalability of the backend data interface, provide a unified interface (i.e., service registration center), and connect to the corresponding called interface according to the indication identifier.
[0138] Third, check the permissions of operators to avoid unauthorized operations.
[0139] The present disclosure also provides an interface calling device, Fig.10 A schematic diagram showing the structure of an interface calling device in an exemplary embodiment of the present disclosure is shown; Fig.10 As shown, the interface calling device 1000 may include an information acquisition module 1010, a request creation module 1020 and an interface calling module 1030. Among them:
[0140] The information acquisition module 1010 is used to acquire the interface configuration information of the called interface when receiving the interface calling instruction input through the preset operation page; the interface calling instruction includes the calling parameters of the called interface, and the called interface is a business interface pre-registered in the service registration center;
[0141] A request creation module 1020, configured to create a call request for the called interface based on the interface configuration information and the call parameters;
[0142] The interface calling module 1030 is used to send the calling request to the called interface through the service registration center to implement the calling of the called interface.
[0143] In an exemplary embodiment of the present disclosure, the interface calling instruction also includes an indication identifier of the called interface. When the information acquisition module 1010 receives the interface calling instruction input through a preset operation page, it obtains the interface configuration information of the called interface, including: according to the indication identifier of the called interface, searching for the correspondence between the pre-set indication identifier and the interface configuration information, and obtaining the interface configuration information of the called interface.
[0144] In an exemplary embodiment of the present disclosure, the interface configuration information includes input parameter description information of the called interface; the request creation module 1020 creates a call request message for the called interface based on the interface configuration information and the call parameters, including: performing structural conversion on the call parameters based on the input parameter description information to obtain interface input parameters; encapsulating and packaging the interface input parameters to obtain a call request for the called interface.
[0145] In an exemplary embodiment of the present disclosure, the interface calling module 1030 sends the calling request to the called interface through the service registration center, including: obtaining the calling instance corresponding to the called interface; running the calling instance to control the registration service center to send the calling request to the called interface.
[0146] In an exemplary embodiment of the present disclosure, the interface calling module 1030 obtains the calling instance corresponding to the called interface, including: based on the interface configuration information, querying whether there is a historical calling instance corresponding to the called interface in a preset storage location; if the historical calling instance exists, determining the historical calling instance as the acquired calling instance; if the historical calling instance does not exist, determining the calling instance created according to the interface configuration information as the acquired calling instance.
[0147] In an exemplary embodiment of the present disclosure, after sending the calling request to the called interface through the service registration center, the interface calling module 1030 is configured to:
[0148] In response to not receiving response data for the calling request returned by the called interface within a preset time period, interrupting the calling of the called interface by the service registration center.
[0149] In an exemplary embodiment of the present disclosure, the interface calling module 1030 is configured to:
[0150] In response to monitoring that the called interface is in an abnormal state, pre-configured abnormal prompt information is returned to the front end, so that the front end displays the abnormal prompt information.
[0151] In an exemplary embodiment of the present disclosure, before receiving the interface call instruction input through the preset operation page, the information acquisition module 1010 is configured to:
[0152] When receiving the login verification information input by the user, the target resource to which the user has access rights is obtained according to the login verification information; after the login verification information is verified, the target resource is returned to the front end; so that the front end renders the target resource to generate the preset operation page, and displays the preset operation page to the user.
[0153] In an exemplary embodiment of the present disclosure, the login verification information includes the identity of the user; the information acquisition module 1010 acquires the target resources to which the user has access rights based on the login verification information, including: searching for the correspondence between a pre-configured identity and a resource identifier based on the identity to obtain the target resource identifier to which the user has access rights; filtering the pre-acquired basic resource set based on the target resource identifier to obtain the target resource to which the user has access rights.
[0154] In an exemplary embodiment of the present disclosure, the basic resource set includes at least one resource block; each of the resource blocks includes at least one resource unit; and each of the resource units includes at least one basic resource.
[0155] The specific details of each module in the above-mentioned interface calling device have been described in detail in the corresponding interface calling method, so they will not be repeated here.
[0156] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0157] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0158] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0159] The present application also provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device.
[0160] The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0161] Computer-readable storage media can send, propagate or transmit programs for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable storage medium can be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0162] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by an electronic device, the electronic device implements the method described in the above embodiments.
[0163] In addition, an electronic device capable of implementing the above method is also provided in an embodiment of the present disclosure.
[0164] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".
[0165] Refer to the following Fig.11 1100 according to this embodiment of the present disclosure is described. Fig.11 The electronic device 1100 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0166] like Fig.11 As shown, the electronic device 1100 is in the form of a general computing device. The components of the electronic device 1100 may include, but are not limited to: the at least one processing unit 1110, the at least one storage unit 1120, a bus 1130 connecting different system components (including the storage unit 1120 and the processing unit 1110), and a display unit 1140.
[0167] The storage unit stores a program code, which can be executed by the processing unit 1110, so that the processing unit 1110 performs the steps described in the "Exemplary Method" section of the present specification according to various exemplary embodiments of the present disclosure. For example, the processing unit 1110 can perform the following steps: Figure 1BAs shown in: Step S110, upon receiving an interface calling instruction input through a preset operation page, obtaining interface configuration information of the called interface; the interface calling instruction includes calling parameters of the called interface, and the called interface is a business interface pre-registered in a service registration center; Step S120, based on the interface configuration information and the calling parameters, creating a calling request for the called interface; Step S130, sending a calling request to the called interface through the service registration center to implement the calling of the called interface.
[0168] The storage unit 1120 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 11201 and / or a cache storage unit 11202 , and may further include a read-only storage unit (ROM) 11203 .
[0169] The storage unit 1120 may also include a program / utility 11204 having a set (at least one) of program modules 11205, such program modules 11205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0170] Bus 1130 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0171] The electronic device 1100 may also communicate with one or more external devices 1200 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 1100, and / or communicate with any device that enables the electronic device 1100 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 1150. Furthermore, the electronic device 1100 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 1160. As shown, the network adapter 1160 communicates with other modules of the electronic device 1100 via a bus 1130. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 1100, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0172] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.
Claims
1. An interface calling method, characterized in that: include: When receiving an interface calling instruction input through a preset operation page, obtaining interface configuration information of the called interface; The interface calling instruction includes calling parameters of the called interface, and the called interface is a business interface pre-registered in the service registration center; Based on the interface configuration information and the calling parameters, creating a calling request for the called interface; The calling request is sent to the called interface through the service registration center to implement the calling of the called interface.
2. The method according to claim 1, characterized in that The interface calling instruction also includes an indication mark of the called interface. When receiving an interface calling instruction input through a preset operation page, obtaining interface configuration information of the called interface includes: According to the indication identifier of the called interface, the correspondence between the preset indication identifier and the interface configuration information is searched to obtain the interface configuration information of the called interface.
3. The method according to claim 1, characterized in that The interface configuration information includes input parameter description information of the called interface; The step of creating a call request message for the called interface based on the interface configuration information and the call parameters includes: Performing structural conversion on the call parameters based on the input parameter description information to obtain interface input parameters; The interface input parameters are encapsulated and packaged to obtain a call request for the called interface.
4. The method according to claim 1, characterized in that: The sending the calling request to the called interface through the service registration center includes: Obtaining a calling instance corresponding to the called interface; The calling instance is run to control the registration service center to send the calling request to the called interface.
5. The method according to claim 4, characterized in that The obtaining the calling instance corresponding to the called interface includes: Based on the interface configuration information, querying a preset storage location to see whether there is a historical call instance corresponding to the called interface; If the historical call instance exists, determining the historical call instance as the acquired call instance; If the historical call instance does not exist, the call instance created according to the interface configuration information is determined as the acquired call instance.
6. The method according to any one of claims 1 to 5, characterized in that: After sending the call request to the called interface through the service registration center, the method further includes: In response to not receiving response data for the calling request returned by the called interface within a preset time period, interrupting the calling of the called interface by the service registration center.
7. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: In response to monitoring that the called interface is in an abnormal state, pre-configured abnormal prompt information is returned to the front end, so that the front end displays the abnormal prompt information.
8. The method according to claim 1, characterized in that Before receiving the interface calling instruction input through the preset operation page, the method further includes: Upon receiving login verification information input by the user, obtaining target resources to which the user has access rights according to the login verification information; After the login verification information is verified, the target resource is returned to the front end; The front end renders the target resource to generate the preset operation page, and displays the preset operation page to the user.
9. The method according to claim 8, characterized in that The login verification information includes the identity of the user; The step of obtaining the target resource to which the user has access rights according to the login verification information includes: According to the identity identifier, searching for a correspondence between a pre-configured identity identifier and a resource identifier to obtain a target resource identifier to which the user has access rights; The pre-acquired basic resource set is filtered according to the target resource identifier to obtain the target resource to which the user has access rights.
10. The method according to claim 9, characterized in that The basic resource set includes at least one resource block; Each of the resource blocks includes at least one resource unit; Each of the resource units includes at least one basic resource.
11. An interface calling device, characterized in that: include: The information acquisition module is used to acquire the interface configuration information of the called interface when receiving the interface calling instruction input through the preset operation page; The interface calling instruction includes calling parameters of the called interface, and the called interface is a business interface pre-registered in the service registration center; A request creation module, used for creating a call request for the called interface based on the interface configuration information and the call parameters; The interface calling module is used to send the calling request to the called interface through the service registration center to realize the calling of the called interface.
12. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the interface calling method according to any one of claims 1 to 10 is implemented.
13. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the interface calling method according to any one of claims 1 to 10 by executing the executable instructions.