A method and device for processing a service request
By analyzing business requests, acquiring and assembling business data, and dynamically calling computing scripts, the problem of hard-code changing program logic in the existing technology is solved, and the effect of zero deployment and scalability improvement is achieved.
Patent Information
- Application Number
- CN202010505326.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-05
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2040-06-05
AI Technical Summary
In the prior art, configuration can only solve simple application scenario configuration. If you want to change the program logic, it must be hard-coded and the application needs to be redeployed.
By receiving the service requests incoming from the service system, the request is parsed to obtain input service parameters, including the identification of the calculation script and the identification of the service data. The business data is obtained from the database based on the identification of the business data, assembled into a result object, and the calculation script is called based on the identification of the calculation script, and finally the output business parameters are obtained based on the script and the result object.
It realizes the function of changing program logic without hard coding, achieves the technical effect of zero deployment, and improves the scalability of the system.
Smart Images

Figure CN113760343B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for processing a service request. Background Art
[0002] Usually, we use configuration to solve the problem of not having to hard code in order to achieve program flexibility. This is mostly used for service switch configuration, page text replacement function, etc. However, this is only an optimization in configuration. If we need to process the configuration information again to generate the desired result, we still need to hard code the service.
[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:
[0004] Configuration can only solve the configuration of simple application scenarios. If you want to change the program logic through configuration, you must implement the program logic change through hard coding and redeploy the application. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method and apparatus for processing a service request to solve the technical problem that hard coding is required to change program logic.
[0006] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for processing a service request is provided, comprising:
[0007] Receiving a business request from a business system, parsing the business request to obtain input business parameters; wherein the input business parameters include an identifier of a calculation script and an identifier of business data;
[0008] Acquire the business data from the database according to the identifier of the business data, and assemble the business data into a result object;
[0009] Calling a calculation script according to an identifier of the calculation script;
[0010] An output business parameter is obtained according to the calculation script and the result object, and the output business parameter is returned to the business system.
[0011] Optionally, acquiring the business data from a database according to the identifier of the business data includes:
[0012] Determine whether the identifier of the calculation script is one of the identifiers of the configured calculation scripts; if so, continue to determine whether the input attributes corresponding to the identifier of the business data match the identifier of the calculation script; if not, return an error code and an error message to the business system; if the input attributes corresponding to the identifier of the business data match the identifier of the calculation script, obtain the business data from the database according to the identifier of the business data; if the input attributes corresponding to the identifier of the business data do not match the identifier of the calculation script, return an error code and an error message to the business system.
[0013] Optionally, the identification of the business data includes an item ID and a basic attribute ID of the item;
[0014] Acquiring the business data from a database according to the identifier of the business data, and assembling the business data into a result object, including:
[0015] At least one piece of detail line data is obtained from the database according to the identifier of the business data, and the at least one piece of detail line data is assembled into a result object.
[0016] Optionally, the calculation script is saved in a directory node of Zookeeper as a node value of the directory node; and the name of the target node is an identifier of the calculation script.
[0017] Optionally, obtaining output business parameters according to the calculation script and the result object includes:
[0018] The calculation script and the result object are transferred to a rendering engine, and the rendering engine is run to obtain output service parameters.
[0019] Optionally, the rendering engine is Rhino, and the calculation script is a JavaScript calculation script.
[0020] Optionally, both the input business parameter and the output business parameter are JSON objects.
[0021] In addition, according to another aspect of an embodiment of the present invention, there is provided a device for processing a service request, including:
[0022] A receiving module, used for receiving a business request from a business system, parsing the business request to obtain input business parameters; wherein the input business parameters include an identifier of a calculation script and an identifier of business data;
[0023] An assembling module, used to obtain business data from a database according to the identifier of the business data, and assemble the business data into a result object;
[0024] A calling module, used for calling a calculation script according to an identifier of the calculation script;
[0025] The calculation module is used to obtain output business parameters according to the calculation script and the result object, and return the output business parameters to the business system.
[0026] Optionally, the assembly module is further used for:
[0027] Determine whether the identifier of the calculation script is one of the identifiers of the configured calculation scripts; if so, continue to determine whether the input attributes corresponding to the identifier of the business data match the identifier of the calculation script; if not, return an error code and an error message to the business system; if the input attributes corresponding to the identifier of the business data match the identifier of the calculation script, obtain the business data from the database according to the identifier of the business data; if the input attributes corresponding to the identifier of the business data do not match the identifier of the calculation script, return an error code and an error message to the business system.
[0028] Optionally, the identification of the business data includes an item ID and a basic attribute ID of the item;
[0029] The assembly module is also used for:
[0030] At least one piece of detail line data is obtained from the database according to the identifier of the business data, and the at least one piece of detail line data is assembled into a result object.
[0031] Optionally, the calculation script is saved in a directory node of Zookeeper as a node value of the directory node; and the name of the target node is an identifier of the calculation script.
[0032] Optionally, the calculation module is further used for:
[0033] The calculation script and the result object are transferred to a rendering engine, and the rendering engine is run to obtain output service parameters.
[0034] Optionally, the rendering engine is Rhino, and the calculation script is a JavaScript calculation script.
[0035] Optionally, both the input business parameter and the output business parameter are JSON objects.
[0036] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, including:
[0037] one or more processors;
[0038] a storage device for storing one or more programs,
[0039] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of the above embodiments.
[0040] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method described in any one of the above embodiments is implemented.
[0041] An embodiment of the above invention has the following advantages or beneficial effects: because the business data is obtained from the database according to the identification of the business data, the business data is assembled into a result object, and the calculation script is called according to the identification of the calculation script, so as to obtain the output business parameters according to the calculation script and the result object, the technical problem that hard coding is required to change the program logic in the prior art is overcome. The embodiment of the present invention passes parameters through the business system and matches the corresponding calculation script for dynamic calculation. Therefore, there is no need to modify the source code of the dynamic calculation service, and there is no need to redeploy or newly deploy the application, achieving the technical effect of zero deployment. Moreover, from the perspective of the program, the embodiment of the present invention improves scalability.
[0042] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0044] Figure 1 is a schematic diagram of the main process of the method for processing a service request according to an embodiment of the present invention;
[0045] Figure 2 is a schematic diagram of the main process of a method for processing a service request according to a reference embodiment of the present invention;
[0046] Figure 3 is a schematic diagram of regularity checking of input service parameters according to an embodiment of the present invention;
[0047] Figure 4 is a schematic diagram of data acquisition and data assembly according to an embodiment of the present invention;
[0048] Figure 5 is a schematic diagram of calling a calculation script according to an embodiment of the present invention;
[0049] Figure 6 is a schematic diagram of calculating output service parameters according to an embodiment of the present invention;
[0050] Figure 7is a schematic diagram of the main process of a method for processing a service request according to another reference embodiment of the present invention;
[0051] Figure 8 is a schematic diagram of main modules of an apparatus for processing a service request according to an embodiment of the present invention;
[0052] Fig. 9 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0053] Fig.10 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0054] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0055] In order to solve the technical problems existing in the prior art, the embodiments of the present invention realize that the program computing logic can be changed without hard coding through a configurable manner.
[0056] Figure 1 FIG. 1 is a schematic diagram of the main flow of a method for processing a service request according to an embodiment of the present invention. As an embodiment of the present invention, Figure 1 As shown, the method for processing a service request may include:
[0057] Step 101: receiving a service request from a service system, and parsing the service request to obtain input service parameters.
[0058] The business system calls the dynamic computing service and passes in business parameters. Figure 2 As shown, the dynamic computing service receives a business request from the business system, parses the business request, and obtains input business parameters. The input business parameters include the identifier of the computing script and the identifier of the business data. The business data for computing is obtained from the database through the identifier of the business data, and the computing logic for processing the business data is called through the identifier of the computing script.
[0059] When a business service calls a dynamic calculation service, the input business parameters passed in are JSON objects, so the business system service can configure the data structure (i.e., input attributes) of the input business parameters according to different calculation scripts. The data structure of the input business parameters is as follows:
[0060]
[0061] attrObj can customize the data structure according to different calculation scripts, so as to achieve the purpose of dynamically configuring input business parameters.
[0062] Step 102: Acquire the business data from the database according to the identifier of the business data, and assemble the business data into a result object.
[0063] like Figure 2 As shown, after the dynamic calculation service parses and obtains the input business parameters, it can perform parameter verification, data assembly, calculation script calling, and rendering engine running according to the input business parameters to obtain output business parameters (i.e., calculation results).
[0064] Optionally, obtaining business data from a database according to the identifier of the business data includes: determining whether the identifier of the calculation script is one of the identifiers of the configured calculation scripts; if so, continuing to determine whether the input attribute corresponding to the identifier of the business data matches the identifier of the calculation script; if not, returning an error code and an error message to the business system; if the input attribute corresponding to the identifier of the business data matches the identifier of the calculation script, obtaining business data from a database according to the identifier of the business data; if the input attribute corresponding to the identifier of the business data does not match the identifier of the calculation script, returning an error code and an error message to the business system. In an embodiment of the present invention, each calculation script has its corresponding input attributes, such as an item ID, an item's basic attribute ID, etc. As described in step 101, it is necessary to customize the data structure in advance according to different calculation scripts. Therefore, in step 102, the input business parameters are first checked for regularity, that is, determining whether the input attribute corresponding to the identifier of the business data matches the identifier of the calculation script, such as Figure 3 If the match is successful, the business data is obtained from the database according to the identifier of the business data, and the business data is assembled into a result object. If the match fails, the business processing is terminated, and an error code and error message are returned to the business system, indicating that the input business parameters are incorrect.
[0065] Alternatively, if Figure 4As shown, taking the input business parameter A passed in by business system A as an example, the identifier of the business data includes the item ID and the basic attribute ID of the item. Optionally, the business data is obtained from the database according to the identifier of the business data, and the business data is assembled into a result object, including: obtaining at least one detail line data from the database according to the identifier of the business data, and assembling the at least one detail line data into a result object. The input business parameter only passes the key identifier, and the actual data is still stored in a relational or non-relational database, such as (MySQL, MongoDB, HBASE, etc.); the corresponding detail line data is obtained from the database through the key identifier, and after the data is assembled again, it is passed to the calculation script for calculation.
[0066] Step 103: calling the calculation script according to the identifier of the calculation script.
[0067] Optionally, the calculation script is stored in a directory node of Zookeeper as the node value of the directory node; and the name of the target node is the identifier of the calculation script. Figure 5 As shown, each calculation script is saved in the directory node of Zookeeper (the unique identifier of different calculation scripts is used as the node, or other key values are used as the node). By entering the identifier of the calculation script in the business parameter, the directory node -node in Zookeeper is matched, and the corresponding node value -value (calculation script) is obtained, thereby achieving the purpose of dynamically calling the calculation script.
[0068] Step 104: Obtain output business parameters according to the calculation script and the result object, and return the output business parameters to the business system.
[0069] Alternatively, if Figure 6 As shown, obtaining the output business parameters according to the calculation script and the result object includes: transferring the calculation script and the result object to a rendering engine, and running the rendering engine to obtain the output business parameters.
[0070] When the script calculation is completed, the returned output business parameters are JSON objects. The data structure of the output business parameters (i.e., the returned attributes) can also be configured according to different calculation scripts, thereby achieving the purpose of dynamically configuring the output business parameters. The data structure of the output business parameters is as follows:
[0071] name Fields type Required illustrate Return code code String yes Error message msg String yes result dataJson JSON Object yes Dynamic Results
[0072] Optionally, the rendering engine is Rhino, and the calculation script is a JavaScript calculation script. The embodiment of the present invention transmits the input business parameters and the called calculation script to the Rhino JavaScript rendering engine, and the engine outputs the result JSON object after running, which is then returned to the business system. JavaScript has powerful computing power, custom formulas, custom document conversion rules, and the data type is JSON, which lays a performance advantage for real-time calculation. Therefore, the embodiment of the present invention uses JavaScript as the calculation script.
[0073] When the calculation script is adjusted according to business needs, the data structure of the input and output business parameters is modified, and the node value in Zookeeper (calculation script logic) is also modified. The business system can obtain the corresponding calculation results by calling the dynamic calculation service again, thus achieving the technical effect of zero deployment.
[0074] According to the various embodiments described above, it can be seen that the embodiments of the present invention obtain business data from the database according to the identifier of the business data, assemble the business data into a result object, call the calculation script according to the identifier of the calculation script, and thus obtain the output business parameters according to the calculation script and the result object. The technical problem that hard coding is required to change the program logic in the prior art. The embodiments of the present invention pass parameters through the business system and match the corresponding calculation script for dynamic calculation. Therefore, there is no need to modify the source code of the dynamic calculation service, and there is no need to redeploy or newly deploy the application, thus achieving a technical effect of zero deployment. Moreover, from a program perspective, the embodiments of the present invention improve scalability.
[0075] Figure 7 FIG. 1 is a schematic diagram of the main flow of a method for processing a service request according to another reference embodiment of the present invention. As another embodiment of the present invention, Figure 7 As shown, the method for processing a service request may include:
[0076] Step 701: receiving a service request from a service system, and parsing the service request to obtain input service parameters.
[0077] The business system calls the dynamic computing service and passes in the business parameters. The dynamic computing service receives the business request passed in by the business system, parses the business request, and obtains the input business parameters. The input business parameters include the identifier of the computing script and the identifier of the business data. The input business parameters passed in when the business service calls the dynamic computing service are JSON objects, so the business system service can configure the data structure (i.e., input attributes) of the input business parameters according to different computing scripts.
[0078] Step 702 , determine whether the identifier of the calculation script is one of the identifiers of the configured calculation scripts; if so, execute step 703 ; if not, execute step 708 .
[0079] Step 703 , determine whether the input attribute corresponding to the identifier of the business data matches the identifier of the calculation script; if so, execute step 704 ; if not, execute step 708 .
[0080] Step 704: Acquire the business data from the database according to the identifier of the business data, and assemble the business data into a result object.
[0081] The input business parameters are only used to pass key identifiers. The actual data is still stored in relational or non-relational databases, such as (MySQL, MongoDB, HBASE, etc.); the corresponding detail row data is obtained from the database through the key identifier, and the data is assembled again and passed to the calculation script for calculation.
[0082] Step 705: calling the calculation script according to the identifier of the calculation script.
[0083] The calculation script is saved in the directory node of Zookeeper as the node value of the directory node; and the name of the target node is the identifier of the calculation script. Each calculation script is saved in the directory node of Zookeeper (based on the unique identifier of different calculation scripts as node, or based on other key values as node). By inputting the identifier of the calculation script in the business parameter, the directory node -node in Zookeeper is matched, and the corresponding node value -value is obtained, thereby achieving the purpose of dynamically calling the calculation script.
[0084] Step 706: pass the calculation script and the result object to a rendering engine, and run the rendering engine to obtain output business parameters.
[0085] When the script calculation is completed, the returned output business parameters are JSON objects. The data structure of the output business parameters (i.e., the returned attributes) can also be configured according to different calculation scripts, thereby achieving the purpose of dynamically configuring the output business parameters.
[0086] Optionally, the rendering engine is Rhino, and the calculation script is a JavaScript calculation script. In the embodiment of the present invention, the input business parameters and the called calculation script are transmitted to the Rhino JavaScript rendering engine, and the engine outputs the result JSON object after running, which is then returned to the business system.
[0087] When the calculation script is adjusted according to business needs, the data structure of the input and output business parameters is modified, and the node value in Zookeeper (calculation script logic) is also modified. The business system can obtain the corresponding calculation results by calling the dynamic calculation service again, thus achieving the technical effect of zero deployment.
[0088] Step 707: Return the output service parameters to the service system.
[0089] Step 708: Return an error code and an error message to the business system.
[0090] In addition, the specific implementation content of the method for processing a service request in a reference embodiment of the present invention has been described in detail in the method for processing a service request described above, so the repeated content will not be described here.
[0091] Figure 8 is a schematic diagram of main modules of an apparatus for processing a service request according to an embodiment of the present invention, such as Figure 8 As shown, the device 800 for processing business requests includes a receiving module 801, an assembling module 802, a calling module 803 and a calculating module 804; wherein the receiving module 801 is used to receive business requests transmitted by the business system, and parse the business requests to obtain input business parameters; wherein the input business parameters include the identifier of the calculation script and the identifier of the business data; the assembling module 802 is used to obtain business data from the database according to the identifier of the business data, and assemble the business data into a result object; the calling module 803 is used to call the calculation script according to the identifier of the calculation script; the calculating module 804 is used to obtain output business parameters according to the calculation script and the result object, and return the output business parameters to the business system.
[0092] Optionally, the assembling module 802 is further used for:
[0093] Determine whether the identifier of the calculation script is one of the identifiers of the configured calculation scripts; if so, continue to determine whether the input attributes corresponding to the identifier of the business data match the identifier of the calculation script; if not, return an error code and an error message to the business system; if the input attributes corresponding to the identifier of the business data match the identifier of the calculation script, obtain the business data from the database according to the identifier of the business data; if the input attributes corresponding to the identifier of the business data do not match the identifier of the calculation script, return an error code and an error message to the business system.
[0094] Optionally, the identification of the business data includes an item ID and a basic attribute ID of the item;
[0095] The assembly module is also used for:
[0096] At least one piece of detail line data is obtained from the database according to the identifier of the business data, and the at least one piece of detail line data is assembled into a result object.
[0097] Optionally, the calculation script is saved in a directory node of Zookeeper as a node value of the directory node; and the name of the target node is an identifier of the calculation script.
[0098] Optionally, the calculation module 804 is further configured to:
[0099] The calculation script and the result object are transferred to a rendering engine, and the rendering engine is run to obtain output service parameters.
[0100] Optionally, the rendering engine is Rhino, and the calculation script is a JavaScript calculation script.
[0101] Optionally, both the input business parameter and the output business parameter are JSON objects.
[0102] According to the various embodiments described above, it can be seen that the embodiments of the present invention obtain business data from the database according to the identifier of the business data, assemble the business data into a result object, call the calculation script according to the identifier of the calculation script, and thus obtain the output business parameters according to the calculation script and the result object. The technical problem that hard coding is required to change the program logic in the prior art. The embodiments of the present invention pass parameters through the business system and match the corresponding calculation script for dynamic calculation. Therefore, there is no need to modify the source code of the dynamic calculation service, and there is no need to redeploy or newly deploy the application, thus achieving a technical effect of zero deployment. Moreover, from a program perspective, the embodiments of the present invention improve scalability.
[0103] It should be noted that the specific implementation content of the device for processing a service request in the present invention has been described in detail in the method for processing a service request described above, so the repeated content will not be described again here.
[0104] Fig. 9 An exemplary system architecture 900 is shown to which the method for processing a service request or the apparatus for processing a service request according to the embodiments of the present invention can be applied.
[0105] like Fig. 9 As shown, system architecture 900 may include terminal devices 901, 902, 903, network 904 and server 905. Network 904 is used to provide a medium for communication links between terminal devices 901, 902, 903 and server 905. Network 904 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0106] Users can use terminal devices 901, 902, 903 to interact with server 905 through network 904 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 901, 902, 903, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0107] The terminal devices 901 , 902 , and 903 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.
[0108] The server 905 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 901, 902, and 903. The backend management server may analyze and process the received data such as the item information query request, and feed back the processing results (such as target push information, item information - only an example) to the terminal device.
[0109] It should be noted that the method for processing a service request provided in the embodiment of the present invention is generally executed by the server 905 , and accordingly, the device for processing a service request is generally disposed in the server 905 .
[0110] It should be understood that Fig. 9 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0111] Reference below Fig.10 , which shows a schematic diagram of the structure of a computer system 1000 of a terminal device suitable for implementing an embodiment of the present invention. Fig.10 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0112] like Fig.10 As shown, the computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the system 1000 are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0113] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.
[0114] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the central processing unit (CPU) 1001, the above-mentioned functions defined in the system of the present invention are executed.
[0115] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0116] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0117] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as follows: a processor includes a receiving module, an assembling module, a calling module and a computing module, wherein the names of these modules do not constitute limitations on the modules themselves in some cases.
[0118] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device implements the following method: receiving a business request passed in by a business system, parsing the business request to obtain input business parameters; wherein the input business parameters include the identifier of the calculation script and the identifier of the business data; obtaining business data from the database according to the identifier of the business data, and assembling the business data into a result object; calling the calculation script according to the identifier of the calculation script; obtaining output business parameters according to the calculation script and the result object, and returning the output business parameters to the business system.
[0119] According to the technical solution of the embodiment of the present invention, the technical means of obtaining business data from the database according to the identifier of the business data, assembling the business data into a result object, calling the calculation script according to the identifier of the calculation script, and obtaining the output business parameters according to the calculation script and the result object are adopted, so the technical problem that hard coding is required to change the program logic in the prior art is overcome. The embodiment of the present invention passes parameters through the business system and matches the corresponding calculation script for dynamic calculation. Therefore, there is no need to modify the source code of the dynamic calculation service, and there is no need to redeploy or newly deploy the application, achieving the technical effect of zero deployment. Moreover, from the perspective of the program, the embodiment of the present invention improves scalability.
[0120] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for processing a service request, characterized in that: include: Receiving a business request from a business system, parsing the business request to obtain input business parameters; wherein the input business parameters include an identifier of a calculation script and an identifier of business data; Acquire the business data from the database according to the identifier of the business data, and assemble the business data into a result object; Calling a calculation script according to an identifier of the calculation script; Obtaining output business parameters according to the calculation script and the result object, and returning the output business parameters to the business system; The identification of the business data includes an item ID and an item's basic attribute ID; Acquiring the business data from a database according to the identifier of the business data, and assembling the business data into a result object, including: Acquire at least one piece of detail line data from a database according to the identifier of the business data, and assemble the at least one piece of detail line data into a result object; The calculation script is stored in the directory node of Zookeeper as the node value of the directory node; and the name of the directory node is the identifier of the calculation script; Acquiring the business data from the database according to the identifier of the business data includes: Determine whether the identifier of the calculation script is one of the identifiers of the configured calculation scripts; if so, continue to determine whether the input attributes corresponding to the identifier of the business data match the identifier of the calculation script; if not, return an error code and an error message to the business system; if the input attributes corresponding to the identifier of the business data match the identifier of the calculation script, obtain the business data from the database according to the identifier of the business data; if the input attributes corresponding to the identifier of the business data do not match the identifier of the calculation script, return an error code and an error message to the business system.
2. The method according to claim 1, characterized in that Obtaining output business parameters according to the calculation script and the result object includes: The calculation script and the result object are transferred to a rendering engine, and the rendering engine is run to obtain output service parameters.
3. The method according to claim 2, characterized in that The rendering engine is Rhino, and the calculation script is a JavaScript calculation script.
4. The method according to claim 1, characterized in that: The input service parameters and the output service parameters are both JSON objects.
5. A device for processing a service request, characterized in that: include: A receiving module, used for receiving a business request from a business system, parsing the business request to obtain input business parameters; wherein the input business parameters include an identifier of a calculation script and an identifier of business data; An assembling module, used to obtain business data from a database according to the identifier of the business data, and assemble the business data into a result object; A calling module, used for calling a calculation script according to an identifier of the calculation script; A calculation module, used for obtaining output business parameters according to the calculation script and the result object, and returning the output business parameters to the business system; The identification of the business data includes an item ID and an item's basic attribute ID; The assembly module is also used for: Acquire at least one piece of detail line data from a database according to the identifier of the business data, and assemble the at least one piece of detail line data into a result object; The calculation script is stored in the directory node of Zookeeper as the node value of the directory node; and the name of the directory node is the identifier of the calculation script; The assembly module is also used for: Determine whether the identifier of the calculation script is one of the identifiers of the configured calculation scripts; if so, continue to determine whether the input attributes corresponding to the identifier of the business data match the identifier of the calculation script; if not, return an error code and an error message to the business system; if the input attributes corresponding to the identifier of the business data match the identifier of the calculation script, obtain the business data from the database according to the identifier of the business data; if the input attributes corresponding to the identifier of the business data do not match the identifier of the calculation script, return an error code and an error message to the business system.
6. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.
7. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Data processing method, device, apparatus, and computer-readable storage medium
CN109063180A
Index calculation method and device
CN109447443A
Service data processing method, server and storage medium
CN111026797A