Data processing method, device, electronic device and storage medium
By setting up multi-level nodes in electronic devices and using target processing templates, the problems of complex routing rule configuration and low efficiency in the existing technology are solved, and the effects of simplifying configuration and improving data processing efficiency are achieved.
Patent Information
- Application Number
- CN202011244932.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-10
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2040-11-10
AI Technical Summary
In the existing technology, the routing rule configuration process is complex and inefficient, resulting in low server processing efficiency and a large amount of duplicate code, which increases the developer's workload and configuration time.
By setting nodes representing service types and front-end request path nodes in the electronic device, the target node is selected according to the request type and path sent by the user device, and the target processing template is used for data processing, which reduces the need for code writing and traversal combinations, and improves improve processing efficiency.
It simplifies the routing rule configuration process, reduces repetitive code writing, improves data processing efficiency, reduces server processing time, and simplifies routing rule management and maintenance.
Smart Images

Figure CN112398941B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data processing method, device, electronic equipment and storage medium. Background Art
[0002] In the computer field, the user device sends a Hypertext Transfer Protocol (HTTP) request to the server, and the server processes the data accordingly according to the configured routing rules.
[0003] In the related art, developers first configure routing rules: write a set of codes for each preset path and each corresponding processing parameter under the preset request type, that is, a set of codes includes the request type, path and processing parameters. After completing the configuration, the user device sends an HTTP request to the server. After the server determines that the request is valid, it obtains the request type and path carried by the request, and determines the corresponding code based on the above routing rules, and processes the data based on the code.
[0004] However, one request type corresponds to multiple paths, and each path corresponds to multiple processing parameters. The code writing in the above solution is relatively messy, which makes the routing rule configuration process time-consuming and labor-intensive, and the server processing process is inefficient. Summary of the invention
[0005] The present invention provides a data processing method, device, electronic device and storage medium for simplifying routing rule configuration and improving data processing efficiency.
[0006] In a first aspect, an embodiment of the present invention provides a data processing method, which is applied to an electronic device, and the method includes:
[0007] According to the target service type carried in the request sent by the user equipment, selecting a node corresponding to the target service type from the nodes representing the service type, wherein the node representing the service type is a node set according to the service type provided by the electronic device;
[0008] Selecting a target node representing the target path carried in the request from the nodes representing the front-end request path at a lower level of the node corresponding to the target service type;
[0009] The processing parameters corresponding to the target node and the target path are input into a target processing template determined according to the target service type, and the data corresponding to the request is processed according to the output target processing method.
[0010] In the above scheme, a node representing the service type is set according to the service type provided by the electronic device, and a corresponding node representing the front-end request path is set at the subordinate level of the node representing the service type. Each node representing the front-end request path corresponds to multiple processing parameters. In this way, the electronic device can select the node corresponding to the target service type carried in the request sent by the user device from the node representing the service type, and then select the target node representing the target path carried in the above request from the node representing the front-end request path at the subordinate level of the corresponding node, so as to determine all processing parameters corresponding to the target path carried in the request. Therefore, there is no need to configure code combinations one by one according to a service type and each related front-end request path, and a front-end request path and each related processing parameter, thereby reducing the writing of repeated code; and by setting multi-level nodes, the electronic device only needs to select a node according to the above request, and does not need to determine the processing parameters corresponding to the path by traversing all combination codes, thereby reducing the time required to determine the processing parameters corresponding to the path and improving processing efficiency.
[0011] In some optional implementations, the processing parameters corresponding to the target node include: processing parameters contained in the subordinate nodes of the target node, wherein the subordinate nodes of the target node are nodes set with classification types obtained by classifying the processing parameters according to a preset classification method.
[0012] The above scheme can conveniently search for processing parameters according to the classification type by setting nodes according to the classification type of the corresponding processing parameters under the target node.
[0013] In some optional implementations, the preset classification method is classification by business type.
[0014] The above solution classifies the processing parameters according to their business types, so that the classification method is more in line with the scenario of configuring routing rules and is more convenient for managing and maintaining routing rules.
[0015] In some optional implementations, the processing parameters corresponding to the target node and the target path are input into a target processing template determined according to the target service type, and the data corresponding to the request is processed according to the output target processing mode, including:
[0016] Combining the target path and the corresponding processing parameters respectively to obtain the target path and processing parameters of each route;
[0017] Input the target path and processing parameters of each route into the target processing template respectively to obtain the target processing mode corresponding to each route;
[0018] The data corresponding to the request is processed according to the target processing mode of each route.
[0019] The above scheme only needs to combine the target path and the corresponding processing parameters respectively to obtain the target path and processing parameters of each route; the target path and processing parameters of each route are respectively input into the target processing template to obtain the target processing method corresponding to each route, and then according to the target processing method of each route, the data corresponding to the above request can be processed.
[0020] In some optional implementations, the target path and the corresponding processing parameter are respectively combined, including:
[0021] The target paths and the corresponding processing parameters are respectively formed into a set of arrays.
[0022] The above scheme can obtain the target path and processing parameters of each route by forming a set of arrays with the target paths and the corresponding processing parameters respectively, and then performing simple combination.
[0023] In some optional implementations, the data corresponding to the request includes the data carried in the request and / or the data of the target location of the database corresponding to the target path.
[0024] In some optional implementations, if the target service type is a GET (get page) service or a HEAD (get page header) service, the data corresponding to the request is the data of the target location of the database corresponding to the target path.
[0025] In some optional implementations, after processing the data corresponding to the request according to the output target processing mode, the method further includes:
[0026] The processed data is sent to the user equipment.
[0027] In some optional implementations, if the target service type is a POST (submit) service, the data corresponding to the request is the data carried in the request.
[0028] In some optional implementations, if the target service type is a PUT (replace) service, the data corresponding to the request is the data carried in the request and the data of the target location of the database corresponding to the target path.
[0029] In some optional implementations, if the target service type is a DELETE service, the data corresponding to the request is the data at the target location of the database corresponding to the target path.
[0030] In a second aspect, an embodiment of the present invention provides a data processing device, including:
[0031] a node selection unit, configured to select, according to the target service type carried in the request sent by the user equipment, a node corresponding to the target service type from the nodes representing the service type, wherein the node representing the service type is a node set according to the service type provided by the electronic device;
[0032] The node selection unit is further configured to select a target node representing a target path carried in the request from nodes representing a front-end request path at a lower level of the node corresponding to the target service type;
[0033] The data processing unit is used to input the processing parameters corresponding to the target node and the target path into the target processing template determined according to the target service type, and process the data corresponding to the request according to the output target processing method.
[0034] In some optional implementations, the processing parameters corresponding to the target node include: processing parameters contained in the subordinate nodes of the target node, wherein the subordinate nodes of the target node are nodes set with classification types obtained by classifying the processing parameters according to a preset classification method.
[0035] In some optional implementations, the preset classification method is classification by business type.
[0036] In some optional implementations, the data processing unit inputs the processing parameters corresponding to the target node and the target path into a target processing template determined according to the target service type, and processes the data corresponding to the request according to the output target processing mode, including:
[0037] Combining the target path and the corresponding processing parameters respectively to obtain the target path and processing parameters of each route;
[0038] Input the target path and processing parameters of each route into the target processing template respectively to obtain the target processing mode corresponding to each route;
[0039] The data corresponding to the request is processed according to the target processing mode of each route.
[0040] In some optional implementations, the data processing unit combines the target path with the corresponding processing parameters respectively, including:
[0041] The target paths and the corresponding processing parameters are respectively formed into a set of arrays.
[0042] In some optional implementations, the data corresponding to the request includes the data carried in the request and / or the data of the target location of the database corresponding to the target path.
[0043] In some optional implementations, if the target service type is a GET service or a HEAD service, the data corresponding to the request is the data of the target location of the database corresponding to the target path.
[0044] In some optional implementations, the data processing unit is further configured to:
[0045] After processing the data corresponding to the request according to the output target processing mode, the processed data is sent to the user equipment.
[0046] In some optional implementations, if the target service type is a POST service, the data corresponding to the request is the data carried in the request.
[0047] In some optional implementations, if the target service type is a PUT service, the data corresponding to the request is the data carried in the request and the data of the target location of the database corresponding to the target path.
[0048] In some optional implementations, if the target service type is a DELETE service, the data corresponding to the request is the data at the target location of the database corresponding to the target path.
[0049] In a third aspect, an embodiment of the present invention provides an electronic device, including: a processor and a memory;
[0050] Wherein, the memory stores program code, and when the program code is executed by the processor, the processor executes the steps of the method described in the first aspect above.
[0051] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the first aspect above.
[0052] In addition, the technical effects brought about by any implementation method in the second to fourth aspects can refer to the technical effects brought about by different implementation methods in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0054] Figure 1 A schematic diagram of routing rules provided by an embodiment of the present invention;
[0055] Figure 2 A schematic diagram of an application scenario provided by an embodiment of the present invention;
[0056] Figure 3 A schematic flow chart of a first data processing method provided by an embodiment of the present invention;
[0057] Figure 4A A schematic diagram of the first node distribution provided in an embodiment of the present invention;
[0058] Figure 4B A schematic diagram of a second node distribution provided in an embodiment of the present invention;
[0059] Figure 4C A schematic diagram of a third node distribution provided in an embodiment of the present invention;
[0060] Figure 4D A schematic diagram of a fourth node distribution provided in an embodiment of the present invention;
[0061] Figure 5 A schematic flow chart of a second data processing method provided by an embodiment of the present invention;
[0062] Figure 6 A schematic flow chart of a third data processing method provided by an embodiment of the present invention;
[0063] Figure 7 A schematic diagram of the structure of a data processing device provided by an embodiment of the present invention;
[0064] Figure 8 A schematic block diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0065] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0066] In the embodiments of the present invention, the term "and / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0067] The terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, unless otherwise specified, "plurality" means two or more.
[0068] In the description of this application, it should be noted that, unless otherwise clearly specified and limited, the term "connection" should be understood in a broad sense, for example, it can be directly connected, or indirectly connected through an intermediate medium, or it can be the internal connection of two devices. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0069] The user device sends an HTTP request to the server, and the server processes the data accordingly according to the configured routing rules.
[0070] In some embodiments, the developer first configures the routing rules: write a set of codes for each preset path and each corresponding processing parameter under the preset request type, that is, a set of codes includes the request type, path and processing parameters. After completing the configuration, the user device sends an HTTP request to the server. After the server determines that the request is valid, it obtains the request type and path carried by the request, and determines the corresponding code according to the above routing rules, and processes the data based on the code.
[0071] A request type includes multiple paths, each path corresponds to multiple processing parameters, see Figure 1 As shown, for a GRT request, it includes path 1, path 2, ... path n, path 1 corresponds to processing parameters 11, processing parameters 12, ... processing parameters N1, path 2 corresponds to processing parameters 21, processing parameters 22, ... processing parameters N2, ... path n corresponds to processing parameters n1, processing parameters n2, ... processing parameters N n .
[0072] As you can see, Figure 1 Only the contents of the code related to the GRT request are shown. In actual applications, there may be multiple types of requests, so the routing rules will be more confusing.
[0073] In the above embodiment, there are a lot of repeated codes in the routing rules, and the configuration is time-consuming and laborious; and the routing rules are relatively chaotic. The server can only traverse all routing rules to obtain the route corresponding to a certain action and path, and then determine the processing parameters of the route. Therefore, the processing efficiency of the server is low.
[0074] In order to simplify routing rule configuration and improve data processing efficiency, the embodiments of the present invention provide a data processing method, device, electronic device and storage medium. The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments.
[0075] like Figure 2 , which is a schematic diagram of an application scenario of an embodiment of the present invention. The application scenario diagram includes user equipment (two user equipments: user equipment 1101 and user equipment 1102 are used as an example for illustration, and the number of user equipments in actual applications may be more or less) and electronic device 120.
[0076] The user equipment and the electronic device 120 can communicate with each other through various communication networks. Here, the user equipment can be allowed to communicate with the electronic device 120 through a local area network (LAN), a wireless local area network (WLAN) and other networks, for example, the user equipment sends an HTTP request to the electronic device 120 through the WLAN.
[0077] The electronic device 120 may select a node corresponding to the target service type from the nodes representing the service type according to the target service type carried in the request sent by the user equipment, wherein the node representing the service type is a node set according to the service type provided by the electronic device;
[0078] A target node representing the target path carried in the request may also be selected from the nodes representing the front-end request path at a lower level of the node corresponding to the target service type;
[0079] The processing parameters corresponding to the target node and the target path may also be input into a target processing template determined according to the target service type, and the data corresponding to the request may be processed according to the output target processing method.
[0080] In the embodiment of the present invention, the user device may be a personal computer, a mobile phone, a tablet computer, a notebook, an e-book reader, or other device that has certain computing capabilities and runs instant messaging software and websites or social software and websites.
[0081] The electronic device 120 includes one or more groups of servers, and the servers can be of one or more types.
[0082] The above application scenarios are only examples of application scenarios for implementing the embodiments of the present invention, and the embodiments of the present invention are not limited to the above application scenarios.
[0083] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0084] Figure 3 A schematic flow chart of a first data processing method provided by an embodiment of the present invention is applied to the above electronic device, such as Figure 3 As shown, the method may include:
[0085] Step 301: According to the target service type carried in the request sent by the user equipment, a node corresponding to the target service type is selected from nodes representing the service type.
[0086] The node representing the service type is a node set according to the service type provided by the electronic device.
[0087] In this embodiment, the node representing the service type may be set according to part or all of the service types provided by the electronic device, for example:
[0088] 1) The service types provided by the electronic device include GET service, HEAD service, POST service, PUT service and DELETE service. Set the nodes corresponding to these five services;
[0089] 2) The service types provided by the electronic device include GET service, HEAD service, POST service, PUT service and DELETE service, and only the nodes corresponding to GET service and POST service are set;
[0090] 3) Services for certain resources provided by electronic devices, including GET service, HEAD service, POST service, PUT service, and DELETE service; there are also services for electronic devices, including TRACE (echo) service and OPTIONS (view performance) service, and only the nodes corresponding to GET service, HEAD service, POST service, PUT service, and DELETE service are set.
[0091] The service types provided by the above electronic devices and the nodes representing the service types are only exemplary. The service types provided by the electronic devices may be different from the above service types, and the nodes representing the above service types may also be set according to actual application scenarios, which will not be described in detail here.
[0092] This embodiment does not limit the manner in which the electronic device determines the target service type carried in the request sent by the user equipment, for example:
[0093] The request method field in the request line of the request sent by the user equipment is used as the target service type.
[0094] In this embodiment, the node corresponding to the target service type may be selected from the nodes representing the service type in the following manner, but is not limited to:
[0095] 1) If the name of the node representing the service type is the corresponding service type, the node named as the target service type is directly used as the node corresponding to the target service type;
[0096] 2) If the name of the node representing the service type is a code (numbers, letters or a combination thereof, etc.) that can identify the service type, determine the code corresponding to the target service type based on the preset correspondence between the code and the service type, and use the node corresponding to the code as the node corresponding to the target service type.
[0097] The above two methods of selecting nodes corresponding to the target service type are merely exemplary. This embodiment may also use other methods to select nodes corresponding to the target service type.
[0098] Step 302: Select a target node representing the target path carried in the request from the nodes representing the front-end request path at a lower level of the node corresponding to the target service type.
[0099] In this embodiment, each node representing the service type is provided with a corresponding node representing the front-end request path at a lower level, and each node representing the front-end request path corresponds to a plurality of processing parameters.
[0100] Among them, each node representing the service type is set at the lower level, and the corresponding node representing the front-end request path is implemented in a variety of ways, for example:
[0101] 1) A corresponding node representing the front-end request path is directly set at the lower level of the node representing the service type;
[0102] 2) A first-level intermediate node is set below each node representing the service type, and different nodes representing the front-end request path are set below each intermediate node;
[0103] 3) Multiple levels of intermediate nodes are set below each node representing the service type, and different nodes representing the front-end request path are set below the lowest intermediate node.
[0104] The method of setting the corresponding node representing the front-end request path is not limited to the above three methods. The specific setting method can be selected according to the actual application scenario.
[0105] In this embodiment, the target node representing the target path carried in the request may be selected from the lower-level nodes representing the front-end request path by, but not limited to, the following methods:
[0106] 1) If the node name representing the front-end request path is the corresponding path, the node named as the target path is directly used as the target node representing the target path;
[0107] 2) If the node name representing the front-end request path is a code (numbers, letters or a combination thereof, etc.) that can identify the front-end request path, determine the code corresponding to the target path based on the preset correspondence between the code and the path, and use the node corresponding to the code as the target node representing the target path.
[0108] The above two methods of selecting a target node are merely exemplary. This embodiment may also use other methods to select a target node.
[0109] This embodiment does not limit the specific manner of setting the node representing the service type and setting the node representing the front-end request path. For example:
[0110] 1) Create a folder representing the service type in the project root directory of KOA (a network development framework); set a first-level subfolder in the folder representing the service type as a node representing the front-end request path;
[0111] 2) Create a folder representing the service type in the project root directory of KOA; set a folder of the first-level intermediate node in the folder representing the service type, and set a different folder representing at least one front-end request path in the folder of each first-level intermediate node;
[0112] 3) The first-level nodes of the tree topology structure are used as nodes representing the service type, and the branch nodes of the first-level nodes are used as nodes representing the front-end request path.
[0113] This embodiment may also adopt other tree-like distribution methods to set the nodes representing the service types and the nodes representing the front-end request paths.
[0114] Step 303: Input the processing parameters corresponding to the target node and the target path into a target processing template determined according to the target service type, and process the data corresponding to the request according to the output target processing method.
[0115] In this embodiment, the processing parameters corresponding to the target node may be obtained by, but not limited to, the following methods:
[0116] The first method: the target node directly corresponds to multiple documents containing corresponding processing parameters. After the target node is determined, the processing parameters contained in these multiple documents are obtained.
[0117] For example, the nodes representing service types include GET folder, HEAD folder, POST folder, PUT folder, and DELETE folder. Figure 4A As shown:
[0118] The target service type is GET service, and the corresponding node is GET folder. The corresponding node representing the front-end request path is directly set under the GET folder ( Figure 4A Taking path 1 folder, path 2 folder, ... path n folder as an example), path 2 folder is a target node representing the target path, and a plurality of tables containing corresponding processing parameters are set in the folder. Figure 4A Take for example that each table carries a processing parameter.
[0119] Figure 4A This is just an example of node distribution. This embodiment adopts other node distribution methods. For example, a folder of the first-level intermediate node can be set in each folder representing the service type, and different folders representing the front-end request path can be set in each folder of the first-level intermediate node, and so on. The above table can also be replaced by other documents containing processing parameters, which will not be repeated here.
[0120] The second method: the target node directly corresponds to a document containing all corresponding processing parameters. After the target node is determined, all processing parameters contained in this document are obtained.
[0121] Take the node as a folder, and the nodes representing the service type include GET folder, HEAD folder, POST folder, PUT folder and DELETE folder as an example. Figure 4B As shown:
[0122] The target service type is GET service, and the corresponding node is GET folder. The corresponding node representing the front-end request path is directly set under the GET folder ( Figure 4B Taking path 1 folder, path 2 folder, ..., path n folder as an example), path 2 folder is a target node representing the target path, and a processing parameter table containing all corresponding processing parameters is set in the folder.
[0123] Figure 4B This is just an example of node distribution. This embodiment adopts other node distribution methods. For example, a folder of the first-level intermediate node can be set in each folder representing the service type, and different folders representing the front-end request path can be set in each folder of the first-level intermediate node, and so on. The above table can also be replaced by other documents containing all corresponding processing parameters, which will not be repeated here.
[0124] In some embodiments, the subordinate nodes of the target node include a plurality of processing parameters, wherein the subordinate nodes of the target node are nodes set according to classification types obtained by classifying the processing parameters according to a preset classification method.
[0125] By setting nodes according to the classification type of the corresponding processing parameters under the target node, developers can easily find processing parameters according to the classification type.
[0126] The above-mentioned preset classification method can be set according to the actual application scenario. In some specific embodiments, the preset classification method is classification by business type.
[0127] Taking the path of the mall page as an example, the corresponding processing parameters are divided into user processing parameters, order processing parameters, and commodity processing parameters. All user processing parameters correspond to user nodes, all order processing parameters correspond to order nodes, and all commodity processing parameters correspond to commodity nodes.
[0128] By classifying the processing parameters according to their business types, the classification method is more in line with the scenario of configuring routing rules, making it easier to manage and maintain routing rules.
[0129] The third method: each subordinate node representing a business type of the target node corresponds to at least one document, each document contains a processing parameter, and after the target node is determined, the processing parameters contained in these multiple documents are obtained.
[0130] Take the node as a folder, and the nodes representing the service type include GET folder, HEAD folder, POST folder, PUT folder and DELETE folder as an example. Figure 4C As shown:
[0131] The target service type is GET service, and the corresponding node is GET folder. The corresponding node representing the front-end request path is directly set under the GET folder ( Figure 4C Taking path 1 folder, path 2 folder, ..., path n folder as an example), path 2 folder is the target node representing the target path, and a folder representing the business type is set in the folder ( Figure 4C Taking a business type 1 folder, a business type 2 folder, ... a business type N folder as an example), each folder representing a business type is provided with at least one table containing processing parameters of the corresponding business type.
[0132] Figure 4CThis is just an example of node distribution. This embodiment adopts other node distribution methods. For example, a folder of a first-level intermediate node can be set in each folder representing a service type, and different folders representing front-end request paths can be set in each folder of a first-level intermediate node, and the above table can also be replaced by other documents containing processing parameters, which will not be repeated here.
[0133] The fourth method: each subordinate node representing the business type of the target node corresponds to a document containing corresponding processing parameters. After the target node is determined, all processing parameters contained in these documents are obtained.
[0134] Take the node as a folder, and the nodes representing the service type include GET folder, HEAD folder, POST folder, PUT folder and DELETE folder as an example. Figure 4D As shown:
[0135] The target service type is GET service, and the corresponding node is GET folder. The corresponding node representing the front-end request path is directly set under the GET folder ( Figure 4D Taking path 1 folder, path 2 folder, ..., path n folder as an example), path 2 folder is the target node representing the target path, and a folder representing the business type is set in the folder ( Figure 4D Taking a business type 1 folder, a business type 2 folder, ... a business type N folder as an example), each folder representing a business type is provided with a table containing all processing parameters of the business type.
[0136] Figure 4D This is just an example of node distribution. This embodiment adopts other node distribution methods. For example, a folder of a first-level intermediate node can be set in each folder representing a service type, and different folders representing front-end request paths can be set in each folder of a first-level intermediate node, and the above table can also be replaced by other documents containing processing parameters, which will not be repeated here.
[0137] The above four methods of obtaining the processing parameters corresponding to the target node are only examples, and the present embodiment is not limited thereto.
[0138] This embodiment does not limit the specific method of obtaining the target processing method, and takes KOA as an example:
[0139] If the request service type is GET service, the target path is input into the first parameter entry of the router.get() (routing method for obtaining the page) template, and the corresponding processing parameters are input into the second parameter entry of the router.get() template. The router.get() template outputs the processing method of the request.
[0140] Among them, the KOA mentioned in the above embodiments can be replaced by other network development frameworks based on the nodejs (scripting language interpreter running on the server) platform. The specific implementation method of using other frameworks is similar to the specific implementation method of using KOA, and will not be illustrated one by one here.
[0141] In the above scheme, a node representing the service type is set according to the service type provided by the electronic device, and a corresponding node representing the front-end request path is set at the subordinate level of the node representing the service type. Each node representing the front-end request path corresponds to multiple processing parameters. In this way, the electronic device can select the node corresponding to the target service type carried in the request sent by the user device from the node representing the service type, and then select the target node representing the target path carried in the above request from the node representing the front-end request path at the subordinate level of the corresponding node, so as to determine all processing parameters corresponding to the target path carried in the request. Therefore, there is no need to configure code combinations one by one according to a service type and each related front-end request path, and a front-end request path and each related processing parameter, thereby reducing the writing of repeated code; and by setting multi-level nodes, the electronic device only needs to select a node according to the above request, and does not need to determine the processing parameters corresponding to the path by traversing all combination codes, thereby reducing the time required to determine the processing parameters corresponding to the path and improving processing efficiency.
[0142] Figure 5 A schematic flow chart of a second data processing method provided by an embodiment of the present invention is applied to the above electronic device, such as Figure 5 As shown, the method may include:
[0143] Step 501: According to the target service type carried in the request sent by the user equipment, a node corresponding to the target service type is selected from nodes representing the service type.
[0144] The node representing the service type is a node set according to the service type provided by the electronic device.
[0145] Step 502: Select a target node representing the target path carried in the request from the nodes representing the front-end request path at a lower level of the node corresponding to the target service type.
[0146] The implementation of steps 501-502 is the same as that of the above steps 301-302, and will not be repeated here.
[0147] Step 503: Combine the target path and the corresponding processing parameters respectively to obtain the target path and processing parameters of each route.
[0148] In this embodiment, a target path and all corresponding processing parameters are obtained. Only by taking the target path and each corresponding processing parameter as two parameters of the corresponding route and inputting the two parameters of each route into the target processing template can the target processing method of each route be obtained. Based on this, it is necessary to first combine the target path and each corresponding processing parameter.
[0149] In some specific embodiments, the target path and the corresponding processing parameters are respectively combined in the following manner: the target path and the corresponding processing parameters are respectively combined into a group of arrays.
[0150] The target path and the processing parameters of each route can be obtained by forming a set of arrays with the target paths and the corresponding processing parameters by simple combination.
[0151] Combining the target path with the corresponding processing parameters respectively means combining the target path with each corresponding processing parameter.
[0152] Step 504: input the target path and processing parameters of each route into the target processing template respectively to obtain the target processing mode corresponding to each route.
[0153] As mentioned above, only by taking the target path and each corresponding processing parameter as the two parameters of the corresponding route and inputting the two parameters of each route into the target processing template can the target processing method of each route be obtained. After combining the target path and each corresponding processing parameter, the two parameters of each route are input into the target processing template.
[0154] Step 505: Process the data corresponding to the request according to the target processing mode of each route.
[0155] Take the target service type of the request as GET service, path 2 as the target path, and the corresponding processing parameters as processing parameter 21, processing parameter 22, ... processing parameter N2 as an example:
[0156] Through the preset plug-in, path 2 and processing parameter 21 are combined into an array, path 2 is used as the target path of route 2, and processing parameter 21 is used as the processing parameter of route 2; path 2 and processing parameter 22 are combined into an array, path 2 is used as the target path of route 2, and processing parameter 22 is used as the processing parameter of route 2; ...; path 2 and processing parameter N2 are combined into an array, path 2 is used as the target path of route N, and processing parameter N2 is used as the processing parameter of route N;
[0157] Input the target path (path 2) of route 1 into the first parameter entry of the router.get() template, input the processing parameters of route 1 (processing parameters 21) into the second parameter entry of the router.get() template, and the router.get() template outputs the target processing method of route 1, which is recorded as processing method 1; input the target path (path 2) of route 2 into the first parameter entry of the router.get() template, input the processing parameters of route 2 (processing parameters 22) into the second parameter entry of the router.get() template, and the router.get() template outputs the target processing method of route 2, which is recorded as processing method 2; ...; input the target path (path 2) of route N into the first parameter entry of the router.get() template, input the processing parameters of route N (processing parameters N2) into the second parameter entry of the router.get() template, and the router.get() template outputs the target processing method of route N, which is recorded as processing method N;
[0158] Based on the above processing method 1, the data corresponding to the above request is processed once; based on the above processing method 2, the data corresponding to the above request is processed once; ...; based on the above processing method N, the data corresponding to the above request is processed once.
[0159] The above processing process is only an example description, and the processing parameters corresponding to the target path can be set according to the actual application scenario.
[0160] The above scheme only needs to combine the target path and the corresponding processing parameters respectively to obtain the target path and processing parameters of each route; the target path and processing parameters of each route are respectively input into the target processing template to obtain the target processing method corresponding to each route, and then according to the target processing method of each route, the data corresponding to the above request can be processed.
[0161] In some embodiments, the data corresponding to the request includes the data carried in the request and / or the data of the target location of the database corresponding to the target path. That is to say, the data corresponding to the request may be the data carried in the request, or the data of the target location of the database corresponding to the target path, or may include both the data carried in the request and the data of the target location of the database corresponding to the target path.
[0162] The data corresponding to the request specifically includes data related to the target service type of the request, for example:
[0163] 1) If the target service type is a GET service or a HEAD service, the data corresponding to the request is the data of the target location of the database corresponding to the target path.
[0164] The GET service is a service that determines the data of the target location of the database corresponding to the target path and returns it to the user device, for example:
[0165] The user types the relevant URL of the electronic device identified as 1111 (taking http: / / 1111 / as an example) in the URL input bar on the user interface provided by the user device in the prescribed format, which triggers the request to send an instruction. Based on the instruction, the user device can request the GET service with a target path of " / " from the electronic device 1111 (displaying the page corresponding to " / ").
[0166] The HEAD service is a service that determines the data of the target location of the database corresponding to the target path and returns the message header to the user device.
[0167] 2) If the target service type is to submit a POST service, the data corresponding to the request is the data carried in the request.
[0168] The POST service is a service that stores the data carried in the request body to the target location of the database corresponding to the target path, for example:
[0169] The user enters information in the specified format through the form on the user interface provided by the user device and clicks the button representing submission of the form, which triggers a request to send an instruction. Based on the instruction, the user device can request a POST service (request to store the above form) from the electronic device.
[0170] 3) If the target service type is to replace the PUT service, the data corresponding to the request is the data carried in the request and the data of the target location of the database corresponding to the target path.
[0171] The PUT service obtains the data carried in the request body of the request, determines the data at the target location of the database corresponding to the target path, and replaces the data at the target location with the carried data.
[0172] 4) If the target service type is a DELETE service, the data corresponding to the request is the data of the target location of the database corresponding to the target path.
[0173] The DELETE service is a service for determining the data at the target location of the database corresponding to the target path and deleting the data.
[0174] The above-mentioned service types are only examples. The service types that an electronic device can provide may be different from the above-mentioned service types, and the specific data contained in the request corresponding to the data may also change accordingly. For example, an electronic device may only provide GET service and POST service.
[0175] The method of determining the target service type may refer to the above embodiment and will not be described in detail here.
[0176] By processing different data according to the target service type requested, different requested services can be completed.
[0177] Figure 6 A schematic flow chart of a third data processing method provided by an embodiment of the present invention is applied to the above electronic device. If the target service type is a GET service or a HEAD service, such as Figure 6 As shown, the method may include:
[0178] Step 601: According to the target service type carried in the request sent by the user equipment, a node corresponding to the target service type is selected from nodes representing the service type.
[0179] The node representing the service type is a node set according to the service type provided by the electronic device.
[0180] Step 602: Select a target node representing the target path carried in the request from the nodes representing the front-end request path at a lower level of the node corresponding to the target service type.
[0181] Step 603: Input the processing parameters corresponding to the target node and the target path into a target processing template determined according to the target service type, and process the data corresponding to the request according to the output target processing method.
[0182] The implementation of steps 601-603 is the same as that of the above steps 301-303, and will not be repeated here.
[0183] Step 604: Send the processed data to the user equipment.
[0184] As described above, if the target service type is a GET service or a HEAD service, the electronic device not only needs to process the data, but also needs to send the processed data to the user device, so as to complete the requested service.
[0185] like Figure 7 As shown, based on the same inventive concept, an embodiment of the present invention provides a data processing device 700, including:
[0186] A node selection unit 701 is configured to select a node corresponding to the target service type from nodes representing service types according to the target service type carried in the request sent by the user equipment, wherein the node representing the service type is a node set according to the service type provided by the electronic device;
[0187] The node selection unit 701 is further configured to select a target node representing a target path carried in the request from the nodes representing the front-end request path at a lower level of the node corresponding to the target service type;
[0188] The data processing unit 702 is used to input the processing parameters corresponding to the target node and the target path into a target processing template determined according to the target service type, and process the data corresponding to the request according to the output target processing method.
[0189] In some optional implementations, the processing parameters corresponding to the target node include: processing parameters contained in the subordinate nodes of the target node, wherein the subordinate nodes of the target node are nodes set with classification types obtained by classifying the processing parameters according to a preset classification method.
[0190] In some optional implementations, the preset classification method is classification by business type.
[0191] In some optional implementations, the data processing unit 702 inputs the processing parameters corresponding to the target node and the target path into a target processing template determined according to the target service type, and processes the data corresponding to the request according to the output target processing mode, including:
[0192] Combining the target path and the corresponding processing parameters respectively to obtain the target path and processing parameters of each route;
[0193] Input the target path and processing parameters of each route into the target processing template respectively to obtain the target processing mode corresponding to each route;
[0194] The data corresponding to the request is processed according to the target processing mode of each route.
[0195] In some optional implementations, the data processing unit 702 combines the target path with the corresponding processing parameters respectively, including:
[0196] The target paths and the corresponding processing parameters are respectively formed into a set of arrays.
[0197] In some optional implementations, the data corresponding to the request includes the data carried in the request and / or the data of the target location of the database corresponding to the target path.
[0198] In some optional implementations, if the target service type is a GET service or a HEAD service, the data corresponding to the request is the data of the target location of the database corresponding to the target path.
[0199] In some optional implementations, the data processing unit is further configured to:
[0200] After processing the data corresponding to the request according to the output target processing mode, the processed data is sent to the user equipment.
[0201] In some optional implementations, if the target service type is a POST service, the data corresponding to the request is the data carried in the request.
[0202] In some optional implementations, if the target service type is a PUT service, the data corresponding to the request is the data carried in the request and the data of the target location of the database corresponding to the target path.
[0203] In some optional implementations, if the target service type is a DELETE service, the data corresponding to the request is the data at the target location of the database corresponding to the target path.
[0204] Since the device is the device in the method in the embodiment of the present invention, and the principle of solving the problem by the device is similar to that of the method, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0205] like Figure 8 As shown, based on the same inventive concept, an embodiment of the present invention provides an electronic device 800, including: a processor 801 and a memory 802;
[0206] The memory 802 is used to store the computer program executed by the processor 801. The memory 802 can be a volatile memory, such as a random-access memory (RAM); the memory 802 can also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), or the memory 802 is any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 802 can be a combination of the above memories.
[0207] The processor 801 may include one or more central processing units (CPU), graphics processing units (GPU) or digital processing units, etc.
[0208] The specific connection medium between the memory 802 and the processor 801 is not limited in the embodiment of the present invention. Figure 8 In the embodiment, the memory 802 and the processor 801 are connected via a bus 803. The bus 803 is connected to the processor 801 via a bus 803. Figure 8 The connection between other components is shown by bold lines, and is not intended to be limiting. The bus 803 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0209] The memory stores program codes, and when the program codes are executed by the processor, the processor 801 performs the following process:
[0210] According to the target service type carried in the request sent by the user equipment, selecting a node corresponding to the target service type from the nodes representing the service type, wherein the node representing the service type is a node set according to the service type provided by the electronic device;
[0211] Selecting a target node representing the target path carried in the request from the nodes representing the front-end request path at a lower level of the node corresponding to the target service type;
[0212] The processing parameters corresponding to the target node and the target path are input into a target processing template determined according to the target service type, and the data corresponding to the request is processed according to the output target processing method.
[0213] In some optional implementations, the processing parameters corresponding to the target node include: processing parameters contained in the subordinate nodes of the target node, wherein the subordinate nodes of the target node are nodes set with classification types obtained by classifying the processing parameters according to a preset classification method.
[0214] In some optional implementations, the preset classification method is classification by business type.
[0215] In some optional implementations, the processor 801 is specifically configured to:
[0216] Combining the target path and the corresponding processing parameters respectively to obtain the target path and processing parameters of each route;
[0217] Input the target path and processing parameters of each route into the target processing template respectively to obtain the target processing mode corresponding to each route;
[0218] The data corresponding to the request is processed according to the target processing mode of each route.
[0219] In some optional implementations, the processor 801 is specifically configured to:
[0220] The target paths and the corresponding processing parameters are respectively formed into a set of arrays.
[0221] In some optional implementations, the data corresponding to the request includes the data carried in the request and / or the data of the target location of the database corresponding to the target path.
[0222] In some optional implementations, if the target service type is a GET service or a HEAD service, the data corresponding to the request is the data of the target location of the database corresponding to the target path.
[0223] In some optional implementations, the processor 801 is further configured to: after processing the data corresponding to the request according to the output target processing method, send the processed data to the user equipment.
[0224] In some optional implementations, if the target service type is a POST service, the data corresponding to the request is the data carried in the request.
[0225] In some optional implementations, if the target service type is a PUT service, the data corresponding to the request is the data carried in the request and the data of the target location of the database corresponding to the target path.
[0226] In some optional implementations, if the target service type is a DELETE service, the data corresponding to the request is the data at the target location of the database corresponding to the target path.
[0227] Since the electronic device is an electronic device that executes the method in the embodiment of the present invention, and the principle of solving the problem by the electronic device is similar to that of the method, the implementation of the electronic device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0228] An embodiment of the present invention provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the above-mentioned data processing method are implemented. The computer-readable storage medium may be a non-volatile computer-readable storage medium.
[0229] The present application is described above with reference to the block diagrams and / or flow charts illustrating the methods, devices (systems) and / or computer program products according to embodiments of the present invention. It should be understood that a block of a block diagram and / or flow chart diagram and a combination of blocks of a block diagram and / or flow chart diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer and / or other programmable data processing device to produce a machine so that instructions executed via a computer processor and / or other programmable data processing device create a method for implementing the functions / actions specified in the block diagram and / or flow chart block.
[0230] Accordingly, the present application may also be implemented with hardware and / or software (including firmware, resident software, microcode, etc.). Furthermore, the present application may take the form of a computer program product on a computer-usable or computer-readable storage medium, which has a computer-usable or computer-readable program code implemented in the medium, for use by an instruction execution system or in conjunction with an instruction execution system. In the context of the present application, a computer-usable or computer-readable medium may be any medium that may contain, store, communicate, transmit, or convey a program for use by an instruction execution system, device, or apparatus, or in conjunction with an instruction execution system, device, or apparatus.
[0231] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0232] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A data processing method, characterized in that: Applied to electronic equipment, the method comprises: According to the target service type carried in the request sent by the user equipment, selecting a node corresponding to the target service type from the nodes representing the service type, wherein the node representing the service type is a node set according to the service type provided by the electronic device; Selecting a target node representing the target path carried in the request from the nodes representing the front-end request path at a lower level of the node corresponding to the target service type; The processing parameters corresponding to the target node and the target path are input into a target processing template determined according to the target service type, and the data corresponding to the request is processed according to the output target processing method.
2. The method according to claim 1, characterized in that The processing parameters corresponding to the target node include: processing parameters contained in subordinate nodes of the target node, wherein the subordinate nodes of the target node are nodes set to classification types obtained by classifying the processing parameters according to a preset classification method.
3. The method according to claim 2, characterized in that The preset classification method is classification by business type.
4. The method according to claim 1, characterized in that: Inputting the processing parameters corresponding to the target node and the target path into a target processing template determined according to the target service type, and processing the data corresponding to the request according to the output target processing mode, including: Combining the target path and the corresponding processing parameters respectively to obtain the target path and processing parameters of each route; Input the target path and processing parameters of each route into the target processing template respectively to obtain the target processing mode corresponding to each route; The data corresponding to the request is processed according to the target processing mode of each route.
5. The method according to claim 4, characterized in that Combining the target path with the corresponding processing parameters respectively includes: The target paths and the corresponding processing parameters are respectively formed into a set of arrays.
6. The method according to any one of claims 1 to 5, characterized in that: The data corresponding to the request includes the data carried in the request and / or the data of the target location of the database corresponding to the target path.
7. The method according to claim 6, characterized in that If the target service type is a GET service for obtaining a page or a HEAD service for obtaining a page header, the data corresponding to the request is the data at the target location of the database corresponding to the target path.
8. The method according to claim 7, characterized in that After processing the data corresponding to the request according to the output target processing method, the method further includes: The processed data is sent to the user equipment.
9. The method according to claim 6, characterized in that If the target service type is to submit a POST service, the data corresponding to the request is the data carried in the request.
10. The method according to claim 6, characterized in that If the target service type is to replace the PUT service, the data corresponding to the request is the data carried in the request and the data of the target location of the database corresponding to the target path.
11. The method according to claim 6, characterized in that If the target service type is a DELETE service, the data corresponding to the request is the data of the target location of the database corresponding to the target path.
12. A data processing device, characterized in that: The device includes: a node selection unit, configured to select, according to the target service type carried in the request sent by the user equipment, a node corresponding to the target service type from the nodes representing the service type, wherein the node representing the service type is a node set according to the service type provided by the data processing device; The node selection unit is further configured to select a target node representing a target path carried in the request from nodes representing a front-end request path at a lower level of the node corresponding to the target service type; The data processing unit is used to input the processing parameters corresponding to the target node and the target path into the target processing template determined according to the target service type, and process the data corresponding to the request according to the output target processing method.
13. The device according to claim 12, characterized in that The processing parameters corresponding to the target node include: processing parameters contained in subordinate nodes of the target node, wherein the subordinate nodes of the target node are nodes set to classification types obtained by classifying the processing parameters according to a preset classification method.
14. The device according to claim 13, characterized in that The preset classification method is classification by business type.
15. The device according to claim 12, characterized in that The data processing unit inputs the processing parameters corresponding to the target node and the target path into a target processing template determined according to the target service type, and processes the data corresponding to the request according to the output target processing mode, including: Combining the target path and the corresponding processing parameters respectively to obtain the target path and processing parameters of each route; Input the target path and processing parameters of each route into the target processing template respectively to obtain the target processing mode corresponding to each route; The data corresponding to the request is processed according to the target processing mode of each route.
16. The device according to claim 15, characterized in that The data processing unit combines the target path with the corresponding processing parameters respectively, including: The target paths and the corresponding processing parameters are respectively formed into a set of arrays.
17. The device according to any one of claims 12 to 16, characterized in that: The data corresponding to the request includes the data carried in the request and / or the data of the target location of the database corresponding to the target path.
18. The device according to claim 17, characterized in that If the target service type is a GET service or a HEAD service, the data corresponding to the request is the data of the target location of the database corresponding to the target path.
19. The device according to claim 18, characterized in that The data processing unit is also used for: After processing the data corresponding to the request according to the output target processing mode, the processed data is sent to the user equipment.
20. The device according to claim 17, characterized in that If the target service type is a POST service, the data corresponding to the request is the data carried in the request.
21. The device according to claim 17, characterized in that If the target service type is a PUT service, the data corresponding to the request is the data carried in the request and the data of the target location of the database corresponding to the target path.
22. The device according to claim 17, characterized in that If the target service type is a DELETE service, the data corresponding to the request is the data of the target location of the database corresponding to the target path.
23. An electronic device, characterized in that: comprising one or more processors, and a memory for storing instructions executable by said processors; The processor is configured to execute the instructions to implement the data processing method according to any one of claims 1 to 11.
24. A storage medium, characterized in that The storage medium stores a computer program, and when the computer program is executed by the processor, the data processing method according to any one of claims 1 to 11 is implemented.
