WEB interaction method, device, equipment and medium based on interface extension
By building batch processing and functional processing interfaces in the RESTful interface, the limitations and scalability problems of the RESTful interface in complex business logic operations are solved, and flexible expansion of the interface and complex business logic support are realized, reducing the difficulty of development and maintenance , adapt to dynamically changing business needs.
Patent Information
- Application Number
- CN202411276278.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2025-01-17
- Estimated Expiration
- 2044-09-12
AI Technical Summary
When handling complex business logic operations, the RESTful interface has limitations in operating methods, complexity of business logic operations and lacks flexible expansion mechanisms, making it difficult to quickly implement complex business logic and quickly respond to dynamically changing business needs.
Based on the interface specification of the RESTful interface, batch processing interface and functional processing interface are built, target interfaces are selected to respond through routing analysis, parameter transfer forms and paths are expanded, and batch processing and functional processing modules are used to support complex business logic operations.
While maintaining the standardization and stability of the RESTful interface, flexible expansion of the interface is achieved, reducing development and maintenance difficulties, supporting complex business logic operations, and being able to respond and adjust quickly to adapt to dynamically changing business needs.
Smart Images

Figure CN118779274B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a WEB interaction method, device, equipment and medium based on interface extension. Background Art
[0002] RESTful (Representational State Transfer) is an interface specification for client-server interaction. It is widely used in the design and implementation of Internet service interfaces for its standardization, stability and versatility. Among them, REST (Representational State Transfer) is an architectural style whose core principle is to use standard methods (such as GET, POST, PUT, DELETE) of the HTTP (Hypertext Transfer Protocol) protocol to operate resources. Each resource is identified by a unique URL (uniform resource locator), and these standard HTTP actions are used to operate the resources, realizing efficient interaction with WEB (World Wide Web) services.
[0003] However, RESTful interfaces have certain limitations when processing complex business logic operations, such as limitations in operation methods and lack of flexible expansion mechanisms. Only a single resource can be operated at the same time, multiple pieces of data cannot be processed at the same time, and multiple identical or different methods cannot be used for combined operations, which makes it difficult to implement many complex business logics conveniently. Specifically, RESTful interfaces have the following main shortcomings when processing complex business logic operations:
[0004] (1) Limitations of operation methods: The RESTful interface specification strictly relies on HTTP actions (such as GET, POST, PUT, and DELETE). These actions have clear semantics in resource operations, but are not flexible enough in business logic operations. For example, complex business logic operations may require multiple steps and multiple conditional judgments, which are difficult to express intuitively using standard HTTP actions;
[0005] (2) Complexity of business logic operations: RESTful interfaces are mainly used for data acquisition and basic addition, deletion and modification operations. However, in actual business scenarios, complex business logic operations often exceed the original design intention of RESTful interfaces. For example, when processing complex business logic such as order payment and user permission verification, additional interface design and implementation are often required, which increases the difficulty of development and maintenance.
[0006] (3) Lack of flexible extension mechanism: Although the RESTful interface achieves a certain degree of flexibility through the combination of resources and actions, it still lacks a flexible extension mechanism when facing dynamically changing business needs, making it difficult to respond and adjust quickly.
[0007] In view of the above problems, how to flexibly expand the interface to cope with complex business logic and achieve more friendly WEB interaction has become an urgent problem to be solved. Summary of the invention
[0008] In view of the above, it is necessary to provide a WEB interaction method, device, equipment and medium based on interface extension, aiming to solve the problem that the interface cannot handle complex business logic and is difficult to expand during the WEB interaction process.
[0009] A WEB interaction method based on interface extension, the WEB interaction method based on interface extension comprising:
[0010] Build batch processing interface and function processing interface based on RESTful interface specification;
[0011] In response to the interaction request sent by the client, performing routing analysis on the interaction request to obtain a analysis result;
[0012] Select a target interface from the RESTful interface, the batch processing interface, and the functional processing interface according to the analysis result;
[0013] Calling the target interface to respond to the interaction request and obtaining a response result;
[0014] Feedback the response result to the client.
[0015] According to a preferred embodiment of the present invention, the batch processing interface and the function processing interface constructed based on the interface specification of the RESTful interface include:
[0016] The parameter transmission form and path are expanded on the basis of the HTTP action of the RESTful interface to obtain the batch processing interface; wherein the parameter transmission form and path of the batch processing interface include transmitting an array of multiple data records through the path of the RESTful interface, and transmitting corresponding parameters through the path obtained after adding a specified suffix to the RESTful interface;
[0017] A specified prefix and a function path are added to the path of the RESTful interface to obtain the function processing interface; wherein the function processing interface adopts a POST request method, and the function path includes a function processing module identifier and a function operation identifier.
[0018] According to a preferred embodiment of the present invention, the calling of the target interface to respond to the interaction request to obtain a response result includes:
[0019] When the target interface is the batch processing interface, and the parameter transmission format and path of the batch processing interface is an array of multiple data records transmitted through the path of the RESTful interface, each array element carried in the request body of the interaction request is used as a piece of data to be processed to perform the operation corresponding to the interaction request, and obtain the response result; or
[0020] When the target interface is the batch processing interface, and the parameter transmission format and path of the batch processing interface are to transmit corresponding parameters by a path obtained by adding a specified suffix to the RESTful interface, a unique identifier set is obtained from the path of the interaction request, and it is detected whether the interaction request has a request body to obtain a detection result; the interaction request is responded to according to the detection result to obtain the response result.
[0021] According to a preferred embodiment of the present invention, responding to the interaction request according to the detection result to obtain the response result includes:
[0022] When the detection result is that the interaction request has a request body, obtaining multiple target objects carried in the request body of the interaction request, and obtaining a first operation corresponding to the interaction request, and processing the target object corresponding to each identifier in the unique identifier set by the first operation to obtain the response result; or
[0023] When the detection result is that the interaction request has no request body, a second operation corresponding to the interaction request is obtained, and the data corresponding to each identifier in the unique identifier set is processed by the second operation to obtain the response result.
[0024] According to a preferred embodiment of the present invention, the calling of the target interface to respond to the interaction request and obtaining a response result further comprises:
[0025] When the target interface is the function processing interface, obtaining a target function processing module identifier and a target function operation identifier corresponding to the function path in the path of the interaction request;
[0026] The target function processing module is connected to according to the target function processing module identifier, and the logic processing function in the target function processing module is called based on the target function operation identifier to perform the logic operation to obtain the response result.
[0027] According to a preferred embodiment of the present invention, the RESTful interface and the batch processing interface respond to the interaction request based on a standard HTTP method.
[0028] According to a preferred embodiment of the present invention, feeding back the response result to the client includes:
[0029] Obtaining the interface identifier and current timestamp of the target interface;
[0030] Generate a target password according to the interface identifier and the current timestamp;
[0031] Encrypting the response result according to the target password to obtain an encrypted response;
[0032] The encrypted response is sent to the client.
[0033] A WEB interactive device based on interface extension, the WEB interactive device based on interface extension comprising:
[0034] A construction unit is used to build batch processing interfaces and functional processing interfaces based on the interface specifications of RESTful interfaces;
[0035] A parsing unit, configured to perform routing parsing on the interaction request sent by the client to obtain a parsing result;
[0036] A selection unit, configured to select a target interface from among the RESTful interface, the batch processing interface and the functional processing interface according to the parsing result;
[0037] A response unit, used for calling the target interface to respond to the interaction request and obtain a response result;
[0038] A feedback unit is used to feed back the response result to the client.
[0039] A computer device, comprising:
[0040] a memory storing at least one instruction; and
[0041] The processor executes the instructions stored in the memory to implement the WEB interaction method based on interface extension.
[0042] A computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor in a computer device to implement the WEB interaction method based on interface extension.
[0043] It can be seen from the above technical solutions that, on the one hand, the present invention builds batch processing interfaces and functional processing interfaces based on the interface specifications of the RESTful interface, which can realize flexible expansion of the interface while ensuring the standardization, normativeness and stability of the RESTful interface; on the other hand, the interaction request is routed and parsed, and the target interface is selected from the RESTful interface, batch processing interface and functional processing interface according to the parsing result to respond to the interaction request, which can not only maintain the advantages of the RESTful interface, but also flexibly support complex business logic operations, which not only reduces the difficulty of development and maintenance, but also can quickly respond to and adjust to dynamically changing business needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 It is a flow chart of a preferred embodiment of the WEB interaction method based on interface extension of the present invention;
[0045] Figure 2 It is a functional module diagram of a preferred embodiment of the WEB interactive device based on interface expansion of the present invention;
[0046] Figure 3 It is a structural schematic diagram of a computer device of a preferred embodiment of the present invention for realizing a WEB interaction method based on interface extension. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0048] like Figure 1 FIG. 1 is a flowchart of a preferred embodiment of the WEB interaction method based on interface expansion of the present invention. According to different requirements, the order of the steps in the flowchart can be changed, and some steps can be omitted.
[0049] The WEB interaction method based on interface extension is applied to one or more computer devices, and the computer device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0050] The computer device may be any electronic product that can perform human-computer interaction with a user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive network television (IPTV), a smart wearable device, etc.
[0051] The computer device may also include a network device and / or a user device, wherein the network device includes, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud consisting of a large number of hosts or network servers based on cloud computing.
[0052] The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.
[0053] Among them, Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0054] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0055] The network where the computer device is located includes but is not limited to the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), etc.
[0056] S10, builds batch processing interface and functional processing interface based on the interface specification of RESTful (Representational State Transfer) interface.
[0057] In this embodiment, the path of the RESTful interface may be https: / / api.example.com / park / api / model_name. The RESTful interface can process basic standard HTTP (Hypertext Transfer Protocol) operations, such as GET, POST, PUT, DELETE, and the like.
[0058] In this embodiment, the batch processing interface and the function processing interface are constructed based on the interface specification of the RESTful interface, including:
[0059] (1) Expanding the parameter transmission form and path based on the HTTP action of the RESTful interface to obtain the batch processing interface; wherein the parameter transmission form and path of the batch processing interface include transmitting an array of multiple data records through the path of the RESTful interface and transmitting corresponding parameters through the path obtained by adding a specified suffix to the RESTful interface.
[0060] For example, the batch processing interface may be represented as a Multi batch operation interface, and the corresponding path may be https: / / api.example.com / park / api / model_name / __multi__?q_oids__in=oids. Specifically, the following example may be referred to:
[0061] 1. Batch addition (POST method) path: / api / model_name
[0062] Request body: pass an array containing multiple data records, each array element corresponds to a piece of data content to be added;
[0063] 2. Batch modification (PUT method) path: / api / model_name / __multi__?q_oid__in=oids
[0064] Request body: pass an object to represent the data content to be modified;
[0065] 3. Batch modification (DELETE method) path: / api / model_name / __multi__?q_oid__in=oids
[0066] Request body: Usually no request body is required, as the information for the delete operation is already provided via the path and query parameters.
[0067] In the above example, __multi__ represents the designated suffix, and the designated suffix is used to identify batch operations, thereby improving the readability and manageability of the URL.
[0068] Through the above embodiments, a batch processing interface can be built on the basis of the interface specification of the RESTful interface, thereby realizing batch operations on data. Based on the interface specification of the RESTful interface, a clear HTTP method distinction (such as POST, PUT, DELETE) is provided for batch addition, modification, deletion and other operations, making the interface more intuitive to use. At the same time, the request body or query parameters of the batch operation directly transmit multiple data or data IDs, thereby reducing the number of network requests and improving data transmission efficiency.
[0069] (2) Adding a specified prefix and a function path to the path of the RESTful interface to obtain the function processing interface; wherein the function processing interface adopts a POST request method, and the function path includes a function processing module identifier and a function operation identifier.
[0070] For example, the function processing interface can be represented as Plus custom interface, and the corresponding path can be https: / / api.example.com / park / plus / model_name / action_name. Specifically, you can refer to the following example:
[0071] 1. Plus interface path / plus / users / reset_password: used for custom business operations such as user password reset and mobile phone number duplication check;
[0072] 2. Request path: / plus / orders / process_payment
[0073] Request method: POST
[0074] Request body: Contains the business parameters required to process the payment.
[0075] The / plus / is the specified prefix. The function processing interface and the traditional RESTful interface are distinguished by a specific URL path prefix, which can make the API (Application Programming Interface) structure clearer.
[0076] Among them, the function processing interface adopts the POST request method, which has the following advantages:
[0077] 1) Improved security:
[0078] Data protection: The POST method transmits data in the BODY of the HTTP request, rather than exposing the data in the URL (uniform resource locator) like the GET method, which reduces the risk of data being cached, saved in server logs or browser history, thereby improving data security;
[0079] 2) Enhanced data transmission capability:
[0080] Support for large amounts of data: Since the GET method is limited by the length of the URL, it cannot transmit large amounts of data. The POST method does not have this limitation and can support the transmission of larger amounts of data, making it suitable for scenarios where large amounts of data need to be sent;
[0081] Diverse data types: The POST method supports a variety of data types, including text, images, videos, binary files, etc., making the interface more flexible and able to handle various types of requests;
[0082] 3) Simplify interface design:
[0083] Unified request method: Using the POST method uniformly in custom interfaces can simplify interface design and implementation. Developers do not need to consider which HTTP method should be used for different operation types (such as create, update, delete, etc.), thereby reducing development difficulty and error rate;
[0084] Reduce understanding cost: For developers who are not familiar with the RESTful specification, the unified use of the POST method can reduce the cost of understanding the semantics of the HTTP method, making the use of the interface more intuitive and simple;
[0085] Compatibility with old systems: In some old systems, only the POST method may be supported or the support for other HTTP methods may be incomplete. In this case, the unified use of the POST method can ensure the compatibility of the interface with these systems.
[0086] Through the above-mentioned embodiments, it is possible to build a function processing interface based on the interface specification of the RESTful interface, and dynamically specify business operations using the function processing module identifier and the function operation identifier in the path, so that the function processing interface can support a wider range of business logic requirements, enhance the flexibility and scalability of the interface, and support flexible definition and implementation of different business operations according to specific business needs to meet the needs of complex business scenarios. In addition, the function processing interface uses a unified request method, and developers only need to pay attention to the action in the URL and the business parameters of the request body, avoiding the complexity of processing multiple request methods, making the interface design more concise and clear, and reducing the difficulty of development and maintenance. In addition, new batch operations and business logic can be easily implemented through simple path and parameter extensions, which reduces the difficulty of API upgrades, can support more business scenarios, and is suitable for various management platforms and function platforms in more business types.
[0087] This embodiment retains the RESTful interface and obtains a batch processing interface and a functional processing interface through expansion, so that the interface functions are more complete and comprehensive, sufficient to meet the business needs of technical personnel in development and operation and maintenance. In addition, when expanding the interface, consistency with the RESTful interface is maintained to avoid introducing too much customization and non-standardized implementation, making interface expansion simpler and easier to implement.
[0088] S11, in response to the interaction request sent by the client, performing routing resolution on the interaction request to obtain a resolution result.
[0089] In this embodiment, by performing routing analysis on the interaction request, relevant data such as the path, the transmitted parameters and the operation carried in the interaction request can be obtained as the analysis result, so as to be used as the basis for selecting the interface later.
[0090] S12: Select a target interface from the RESTful interface, the batch processing interface, and the functional processing interface according to the analysis result.
[0091] In this embodiment, the target interface can be selected from the RESTful interface, the batch processing interface and the functional processing interface according to the parameter transmission methods and paths (such as path format, prefix and suffix in the path, etc.) corresponding to the RESTful interface, the batch processing interface and the functional processing interface.
[0092] In the above embodiment, a suitable interface can be automatically selected from a variety of interfaces according to the parameter transmission characteristics and path characteristics of each interface, so as to facilitate subsequent targeted calls.
[0093] S13, calling the target interface to respond to the interaction request and obtaining a response result.
[0094] In this embodiment, the calling of the target interface to respond to the interaction request to obtain a response result includes:
[0095] (1) When the target interface is the batch processing interface, and the parameter transmission format and path of the batch processing interface are an array of multiple data records transmitted through the path of the RESTful interface, each array element carried in the request body of the interaction request is used as a piece of data to be processed to execute the operation corresponding to the interaction request, and obtain the response result.
[0096] For example, when batch addition is required (the corresponding operation method is POST), the corresponding path is: / api / model_name, and the request body is an array containing multiple data records, and each array element corresponds to a piece of data content to be added. Specifically, when batch creation of new users is required, the corresponding path can be https: / / api.example.com / park / api / users, and the parameters in the request body can be an array [{name: name 1, gender: gender 1, mobile: mobile number 1},{name: name 2, gender: gender 2, mobile: mobile number 2}];
[0097] (2) When the target interface is the batch processing interface, and the parameter transmission format and path of the batch processing interface are the paths obtained by adding a specified suffix to the RESTful interface to transmit corresponding parameters, a unique identifier set is obtained from the path of the interaction request, and it is detected whether the interaction request has a request body to obtain a detection result; and the interaction request is responded to according to the detection result to obtain the response result.
[0098] Specifically, responding to the interaction request according to the detection result to obtain the response result includes:
[0099] 1) When the detection result is that the interaction request has a request body, obtain multiple target objects carried in the request body of the interaction request, obtain a first operation corresponding to the interaction request, and process the target object corresponding to each identifier in the unique identifier set with the first operation to obtain the response result.
[0100] For example, when batch modification is required (the corresponding operation method is PUT), the corresponding path is: / api / model_name / __multi__?q_oid__in=oids, and the request body is to pass an object to represent the data content to be modified. Specifically, oids can be a collection of the company's unique identifiers XXX and YYY, then the corresponding path is https: / / api.example.com / park / api / companies / __multi__?q_oids__in=XXX,YYY, and the parameters in the request body are {member_count: number of company members, is_own: whether it is an internal company}, so as to update company information in batches;
[0101] 2) When the detection result is that the interaction request has no request body, obtaining a second operation corresponding to the interaction request, and processing the data corresponding to each identifier in the unique identifier set by the second operation to obtain the response result.
[0102] For example, when batch deletion is required (the corresponding operation method is DELETE), the corresponding path is: / api / model_name / __multi__?q_oid__in=oids. Usually, the request body is not required because the information of the deletion operation is provided through the path and query parameters. Specifically, oids can be a collection of the unique identifiers XXX and YYY of the enterprise. The corresponding path is https: / / api.example.com / park / api / users / __multi__?q_oids__in=XXX,YYY, which does not contain a request body, thereby achieving batch deletion of enterprises.
[0103] The RESTful interface and the batch processing interface both respond to the interaction request based on a standard HTTP method to ensure that the standardization, normativeness and stability of the RESTful interface remain unchanged.
[0104] Through the above embodiments, batch operations on data can be implemented based on the expanded batch processing interface, thereby improving data processing efficiency.
[0105] In this embodiment, the calling of the target interface to respond to the interaction request and obtaining a response result further includes:
[0106] When the target interface is the function processing interface, obtaining a target function processing module identifier and a target function operation identifier corresponding to the function path in the path of the interaction request;
[0107] The target function processing module is connected to according to the target function processing module identifier, and the logic processing function in the target function processing module is called based on the target function operation identifier to perform the logic operation to obtain the response result.
[0108] For example: in the path / plus / model_name / action_name of the function processing interface, the corresponding target function processing module can be determined by model_name, and the specific logic processing function in the target function processing module corresponding to model_name can be determined by action_name, that is, each action_name corresponds to a specific business operation logic, and different logic operations and corresponding processing modules can be defined according to business requirements. For example: for the path / plus / users / reset_password, UserController.resetPassword() can be called for processing through action_name "reset_password".
[0109] Through the above embodiments, more complex business operations can be implemented based on the extended functional processing interface, so that the WEB interface operations are not limited to basic addition, deletion, modification and query.
[0110] S14, feeding back the response result to the client.
[0111] In this embodiment, feeding back the response result to the client includes:
[0112] Obtaining the interface identifier and current timestamp of the target interface;
[0113] Generate a target password according to the interface identifier and the current timestamp;
[0114] Encrypting the response result according to the target password to obtain an encrypted response;
[0115] The encrypted response is sent to the client.
[0116] Among them, a symmetric encryption algorithm or an asymmetric encryption algorithm can be used to generate a target password according to the interface identifier and the current timestamp. The present invention does not limit the encryption algorithm used.
[0117] In the above embodiment, the response result is encrypted with the target interface and the current timestamp, and the response result is encrypted and transmitted, which can ensure the secure transmission of data and prevent data from being tampered with.
[0118] The WEB interaction method used in this embodiment has certain advantages in various business scenarios (such as e-commerce platforms, financial management systems, big data analysis platforms, etc.). For example: in a park management system, it is usually necessary to add new park buildings and floors, but a building basically has more than ten, twenty, or even more than thirty floors. The conventional method is to add them one floor at a time, but if there are several buildings, this repetitive action is very time-consuming and labor-intensive. Therefore, it is necessary to use the batch processing interface in this embodiment to perform batch addition operations. When adding a new building, enter the number of floors, and the corresponding number of floors will be automatically added to bind the building. The administrator will then set the specified floors. In addition, the batch modification function is also required when selecting multiple floors or rooms for the same modification; in a group management system, the administrators of each enterprise under the group need to give new employees The conventional method is to add a new employee file and a new user account of the system at the same time. The operation is cumbersome and error-prone. If the function processing interface in this embodiment is used to add a new file for an enterprise employee, the system will automatically add the user, complete the user information and bind the enterprise. In addition, when a user's password needs to be modified and there are multiple restrictions (such as whether the user has the authority to modify the password, the new password cannot be the same as the original password, the password must be encrypted, etc.), for the security of the password, it cannot be modified based on the general RESTful interface. It is safer to use the function processing interface in this embodiment for processing.
[0119] It can be seen from the above technical solutions that, on the one hand, the present invention builds batch processing interfaces and functional processing interfaces based on the interface specifications of the RESTful interface, which can realize flexible expansion of the interface while ensuring the standardization, normativeness and stability of the RESTful interface; on the other hand, the interaction request is routed and parsed, and the target interface is selected from the RESTful interface, batch processing interface and functional processing interface according to the parsing result to respond to the interaction request, which can not only maintain the advantages of the RESTful interface, but also flexibly support complex business logic operations, which not only reduces the difficulty of development and maintenance, but also can quickly respond to and adjust to dynamically changing business needs.
[0120] like Figure 2 , which is a functional module diagram of a preferred embodiment of the WEB interactive device based on interface extension of the present invention. The WEB interactive device based on interface extension 11 includes a building unit 110, a parsing unit 111, a selection unit 112, a response unit 113, and a feedback unit 114. The module / unit referred to in the present invention refers to a series of computer program segments that can be executed by a processor and can complete fixed functions, which are stored in a memory. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.
[0121] Wherein, the building unit 110 is used to build a batch processing interface and a function processing interface based on the interface specification of the RESTful interface;
[0122] The parsing unit 111 is used to perform routing parsing on the interaction request sent by the client to obtain a parsing result;
[0123] The selection unit 112 is used to select a target interface from the RESTful interface, the batch processing interface and the function processing interface according to the parsing result;
[0124] The response unit 113 is used to call the target interface to respond to the interaction request and obtain a response result;
[0125] The feedback unit 114 is configured to feed back the response result to the client.
[0126] It can be seen from the above technical solutions that, on the one hand, the present invention builds batch processing interfaces and functional processing interfaces based on the interface specifications of the RESTful interface, which can realize flexible expansion of the interface while ensuring the standardization, normativeness and stability of the RESTful interface; on the other hand, the interaction request is routed and parsed, and the target interface is selected from the RESTful interface, batch processing interface and functional processing interface according to the parsing result to respond to the interaction request, which can not only maintain the advantages of the RESTful interface, but also flexibly support complex business logic operations, which not only reduces the difficulty of development and maintenance, but also can quickly respond to and adjust to dynamically changing business needs.
[0127] like Figure 3 FIG. 1 is a schematic diagram of the structure of a computer device of a preferred embodiment of the present invention for implementing a WEB interaction method based on interface extension.
[0128] The computer device 1 may include a memory 12, a processor 13 and a bus, and may also include a computer program stored in the memory 12 and executable on the processor 13, such as a WEB interactive program based on interface extension.
[0129] Those skilled in the art will appreciate that the schematic diagram is merely an example of the computer device 1 and does not constitute a limitation on the computer device 1. The computer device 1 may be a bus-type structure or a star-type structure. The computer device 1 may also include more or less other hardware or software than shown in the diagram, or a different arrangement of components. For example, the computer device 1 may also include input and output devices, network access devices, etc.
[0130] It should be noted that the computer device 1 is only an example, and other existing or future electronic products that are suitable for the present invention should also be included in the protection scope of the present invention and included here by reference.
[0131] The memory 12 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the memory 12 may be an internal storage unit of the computer device 1, such as a mobile hard disk of the computer device 1. In other embodiments, the memory 12 may also be an external storage device of the computer device 1, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the computer device 1. Further, the memory 12 may also include both an internal storage unit of the computer device 1 and an external storage device. The memory 12 may not only be used to store application software and various types of data installed in the computer device 1, such as the code of a WEB interactive program based on interface extension, etc., but may also be used to temporarily store data that has been output or is to be output.
[0132] In some embodiments, the processor 13 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and a combination of various control chips. The processor 13 is the control core (Control Unit) of the computer device 1, and uses various interfaces and lines to connect various components of the entire computer device 1, and executes various functions and processes data of the computer device 1 by running or executing programs or modules stored in the memory 12 (for example, executing WEB interactive programs based on interface extensions, etc.), and calling data stored in the memory 12.
[0133] The processor 13 executes the operating system of the computer device 1 and various installed applications. The processor 13 executes the applications to implement the steps in the above-mentioned WEB interaction method embodiments based on interface extension, for example Figure 1 Steps shown.
[0134] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to implement the present invention. The one or more modules / units may be a series of computer-readable instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program in the computer device 1. For example, the computer program may be divided into a building unit 110, a parsing unit 111, a selection unit 112, a response unit 113, and a feedback unit 114.
[0135] The above-mentioned integrated unit implemented in the form of software function modules can be stored in a computer-readable storage medium. The above-mentioned software function modules are stored in a storage medium, and include several instructions for enabling a computer device (which can be a personal computer, a computer device, or a network device, etc.) or a processor to execute the part of the WEB interaction method based on interface extension described in various embodiments of the present invention.
[0136] If the module / unit integrated in the computer device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware devices through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of each of the above-mentioned method embodiments can be implemented.
[0137] The computer program includes computer program code, which may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory, etc.
[0138] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0139] The blockchain referred to in this invention is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the blockchain underlying platform, platform product service layer, and application service layer.
[0140] The bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 The bus is represented by only one straight line, but it does not mean that there is only one bus or one type of bus. The bus is configured to realize the connection and communication between the memory 12 and at least one processor 13, etc.
[0141] Although not shown, the computer device 1 may also include a power source (such as a battery) for supplying power to various components. Preferably, the power source may be logically connected to the at least one processor 13 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include any components such as one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, and power status indicators. The computer device 1 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0142] Furthermore, the computer device 1 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is usually used to establish a communication connection between the computer device 1 and other computer devices.
[0143] Optionally, the computer device 1 may further include a user interface, which may be a display, an input unit (such as a keyboard), or a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the computer device 1 and to display a visual user interface.
[0144] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0145] It can be understood by those skilled in the art that Figure 3 The structure shown does not constitute a limitation on the computer device 1, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0146] Combination Figure 1 The memory 12 in the computer device 1 stores a plurality of instructions to implement a WEB interaction method based on interface extension, and the processor 13 can execute the plurality of instructions to implement:
[0147] Build batch processing interface and function processing interface based on RESTful interface specification;
[0148] In response to the interaction request sent by the client, performing routing analysis on the interaction request to obtain a analysis result;
[0149] Select a target interface from the RESTful interface, the batch processing interface, and the functional processing interface according to the analysis result;
[0150] Calling the target interface to respond to the interaction request and obtaining a response result;
[0151] Feedback the response result to the client.
[0152] Specifically, the specific implementation method of the processor 13 for the above instructions can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0153] It should be noted that the data involved in this case were all obtained legally.
[0154] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0155] The present invention can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present invention can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present invention can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0156] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0157] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0158] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0159] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0160] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the present invention can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
[0161] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A WEB interaction method based on interface extension, characterized in that: The WEB interaction method based on interface extension includes: Building a batch processing interface and a function processing interface based on the interface specification of the RESTful interface, including: expanding the parameter transmission form and path based on the HTTP action of the RESTful interface to obtain the batch processing interface; wherein the parameter transmission form and path of the batch processing interface include transmitting an array of multiple data records through the path of the RESTful interface, and transmitting corresponding parameters through the path obtained by adding a specified suffix to the RESTful interface; adding a specified prefix and a function path to the path of the RESTful interface to obtain the function processing interface; wherein the function processing interface adopts the POST request method, and the function path includes a function processing module identifier and a function operation identifier; In response to the interaction request sent by the client, performing routing analysis on the interaction request to obtain a analysis result; Select a target interface from the RESTful interface, the batch processing interface, and the functional processing interface according to the analysis result; Calling the target interface to respond to the interaction request and obtaining a response result; Feedback the response result to the client.
2. The WEB interaction method based on interface extension according to claim 1, characterized in that: The calling of the target interface to respond to the interaction request to obtain a response result includes: When the target interface is the batch processing interface, and the parameter transmission format and path of the batch processing interface is an array of multiple data records transmitted through the path of the RESTful interface, each array element carried in the request body of the interaction request is used as a piece of data to be processed to perform the operation corresponding to the interaction request, and obtain the response result; or When the target interface is the batch processing interface, and the parameter transmission format and path of the batch processing interface are to transmit corresponding parameters by a path obtained by adding a specified suffix to the RESTful interface, a unique identifier set is obtained from the path of the interaction request, and it is detected whether the interaction request has a request body to obtain a detection result; the interaction request is responded to according to the detection result to obtain the response result.
3. The WEB interaction method based on interface extension as claimed in claim 2, characterized in that: The responding to the interaction request according to the detection result to obtain the response result includes: When the detection result is that the interaction request has a request body, obtaining multiple target objects carried in the request body of the interaction request, and obtaining a first operation corresponding to the interaction request, and processing the target object corresponding to each identifier in the unique identifier set by the first operation to obtain the response result; or When the detection result is that the interaction request has no request body, a second operation corresponding to the interaction request is obtained, and the data corresponding to each identifier in the unique identifier set is processed by the second operation to obtain the response result.
4. The WEB interaction method based on interface extension as claimed in claim 1, characterized in that: The calling of the target interface to respond to the interaction request and obtaining a response result further comprises: When the target interface is the function processing interface, obtaining a target function processing module identifier and a target function operation identifier corresponding to the function path in the path of the interaction request; The target function processing module is connected to according to the target function processing module identifier, and the logic processing function in the target function processing module is called based on the target function operation identifier to perform the logic operation to obtain the response result.
5. The WEB interaction method based on interface extension as claimed in claim 1, characterized in that: The RESTful interface and the batch processing interface respond to the interaction request based on a standard HTTP method.
6. The WEB interaction method based on interface extension as claimed in claim 1, characterized in that: Feedback of the response result to the client includes: Obtaining the interface identifier and current timestamp of the target interface; Generate a target password according to the interface identifier and the current timestamp; Encrypting the response result according to the target password to obtain an encrypted response; The encrypted response is sent to the client.
7. A WEB interactive device based on interface extension, characterized in that: The WEB interaction device based on interface extension includes: A construction unit, used for constructing a batch processing interface and a function processing interface based on the interface specification of a RESTful interface, comprising: expanding the parameter transmission form and path based on the HTTP action of the RESTful interface to obtain the batch processing interface; wherein the parameter transmission form and path of the batch processing interface include transmitting an array of multiple data records through the path of the RESTful interface, transmitting corresponding parameters through the path obtained by adding a specified suffix to the RESTful interface; adding a specified prefix and a function path to the path of the RESTful interface to obtain the function processing interface; wherein the function processing interface adopts a POST request method, and the function path includes a function processing module identifier and a function operation identifier; A parsing unit, configured to perform routing parsing on the interaction request sent by the client to obtain a parsing result; A selection unit, configured to select a target interface from among the RESTful interface, the batch processing interface and the functional processing interface according to the parsing result; A response unit, used for calling the target interface to respond to the interaction request and obtain a response result; A feedback unit is used to feed back the response result to the client.
8. A computer device, characterized in that: The computer device comprises: a memory storing at least one instruction; and A processor executes instructions stored in the memory to implement the WEB interaction method based on interface extension as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor in a computer device to implement the WEB interaction method based on interface extension as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Method and system for extending application programming interfaces
US20150007199A1