Pre-verification method and device based on real-time service and storage medium
By performing pre-checking based on real-time service between the business system and the real-time application system, and using the verification rule configuration information to verify the parameter legality of business requests, the problem of rigidity and inflexibility of traditional data verification methods is solved, and the combination of flexibility checking and efficient performance is achieved.
Patent Information
- Application Number
- CN202311213382.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-19
- Publication Date
- 2025-03-21
AI Technical Summary
The traditional data verification method is rigid and inflexible, and cannot achieve flexibility verification of requested parameters and cannot meet the enterprise's needs for operational flexibility.
Provide a pre-checking method based on real-time services. By obtaining verification rule configuration information, loading it into the cache, and performing parameter legality verification of business requests based on these rules, determining whether the request passes the verification and forwarding it to the real-time application system.
It realizes the independence and flexibility of parameter legality verification, can meet the real-time and efficient performance requirements, and at the same time meet the enterprise's needs for operational flexibility.
Smart Images

Figure CN119669277A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data verification technology, and in particular to a pre-verification method, device and storage medium based on real-time services. Background Art
[0002] The traditional data verification method is to implement parameter validity verification in the real-time service interface through solidified code, that is, to directly solidify the parameter validity verification in the interface code for logical judgment and verification. However, this data verification method is rigid and inflexible, and cannot implement various flexible verifications of request parameters, thus failing to meet the enterprise's needs for operational flexibility. Summary of the invention
[0003] The embodiment of the present application provides a pre-verification method, device, equipment and storage medium based on real-time service to solve the problems existing in the related technology. The technical solution is as follows:
[0004] In a first aspect, an embodiment of the present application provides a pre-verification method based on a real-time service, comprising:
[0005] Obtain verification rule configuration information, where the verification rule configuration information is configured on the visual management page according to the request parameters of any business interface;
[0006] Loading the verification rule configuration information into a cache;
[0007] Receive the business request sent by the target business interface of the business system;
[0008] Performing parameter validity verification on the service request according to the verification rule configuration information to obtain a verification result;
[0009] After determining that the service request passes the verification according to the verification result, the service request is forwarded to the real-time application system.
[0010] In one implementation, the verification rule configuration information includes the interface name and verification rule of any of the service interfaces, and the verification rule includes a verification parameter path, a verification method and its corresponding verification value.
[0011] In one implementation, performing parameter validity verification on the service request according to the verification rule configuration information, and obtaining the verification result includes:
[0012] According to the interface name of the target service interface, query the target verification rule of the target service interface from the verification rule configuration information in the cache;
[0013] According to the verification parameter path in the target verification rule, the request parameters of the business request are parsed, and each to-be-verified parameter and its parameter value that need to be verified are extracted from the request parameters;
[0014] According to the verification method in the target verification rule and its corresponding verification value, the legality of the parameter value of each parameter to be verified is verified one by one to obtain the verification result.
[0015] In one implementation, when the verification method is to verify the parameter length, the verification value corresponding to the verification method is the parameter length value;
[0016] When the verification method is to verify the time format of the parameter, the verification value corresponding to the verification method is the time format value;
[0017] When the verification method is to verify the value range of the parameter, the verification value corresponding to the verification method is a regular expression;
[0018] When the verification method is to verify the dynamic value range of the parameter, the verification value corresponding to the verification method is the database table and the field name;
[0019] When the verification method is to verify the logical expression of the parameter, the verification value corresponding to the verification method is the logical expression.
[0020] In one implementation, according to the verification method and the corresponding verification value in the target verification rule, the legality of the parameter value of each parameter to be verified is verified one by one, and obtaining the verification result includes:
[0021] According to the verification method in the target verification rule, determine the target verification method corresponding to the parameter value of each parameter to be verified one by one;
[0022] According to the target verification method corresponding to the parameter value of each parameter to be verified, verify whether the parameter value of each parameter to be verified meets the verification value corresponding to the target verification method, so as to determine whether the parameter value of each parameter to be verified passes the verification and obtain the verification result.
[0023] In one implementation, determining that the service request has passed the verification according to the verification result includes: when the verification result is that the parameter values of each of the parameters to be verified have passed the verification, determining that the service request has passed the verification;
[0024] The verification rule also includes abnormal prompt information when the verification fails, and the method also includes:
[0025] When the verification result is that at least one parameter value of the to-be-verified parameter fails the verification, it is determined that the service request fails the verification, the service request is terminated, and the abnormal prompt information in the target verification rule is returned to the target service interface.
[0026] In one embodiment, the method further comprises:
[0027] An adjustment operation is received, where the adjustment operation is an operation of adjusting the verification rule configuration information in real time on the visual management page;
[0028] In response to the adjustment operation, updating the verification rule configuration information;
[0029] The updated verification rule configuration information is hot loaded into the cache.
[0030] In a second aspect, the embodiment of the present application further provides a pre-verification device, including:
[0031] A storage unit, used to obtain verification rule configuration information, wherein the verification rule configuration information is obtained by configuring on a visual management page according to request parameters of any business interface; and loading the verification rule configuration information into a cache;
[0032] The verification unit is used to receive a business request sent by a target business interface of a business system; perform parameter legitimacy verification on the business request according to the verification rule configuration information to obtain a verification result; after determining that the business request has passed the verification according to the verification result, forward the business request to the real-time application system.
[0033] In one implementation, the verification rule configuration information includes the interface name and verification rule of any of the service interfaces, and the verification rule includes a verification parameter path, a verification method and its corresponding verification value.
[0034] In one implementation, the verification unit is specifically used to:
[0035] According to the interface name of the target service interface, query the target verification rule of the target service interface from the verification rule configuration information in the cache;
[0036] According to the verification parameter path in the target verification rule, the request parameters of the business request are parsed, and each to-be-verified parameter and its parameter value that need to be verified are extracted from the request parameters;
[0037] According to the verification method in the target verification rule and its corresponding verification value, the legality of the parameter value of each parameter to be verified is verified one by one to obtain the verification result.
[0038] In one implementation, when the verification method is to verify the parameter length, the verification value corresponding to the verification method is the parameter length value;
[0039] When the verification method is to verify the time format of the parameter, the verification value corresponding to the verification method is the time format value;
[0040] When the verification method is to verify the value range of the parameter, the verification value corresponding to the verification method is a regular expression;
[0041] When the verification method is to verify the dynamic value range of the parameter, the verification value corresponding to the verification method is the database table and the field name;
[0042] When the verification method is to verify the logical expression of the parameter, the verification value corresponding to the verification method is the logical expression.
[0043] In one implementation, the verification unit is specifically used to:
[0044] According to the verification method in the target verification rule, determine the target verification method corresponding to the parameter value of each parameter to be verified one by one;
[0045] According to the target verification method corresponding to the parameter value of each parameter to be verified, verify whether the parameter value of each parameter to be verified meets the verification value corresponding to the target verification method, so as to determine whether the parameter value of each parameter to be verified passes the verification and obtain the verification result.
[0046] In one implementation, the verification unit is specifically configured to: when the verification result is that the parameter values of the parameters to be verified all pass the verification, determine that the service request passes the verification;
[0047] The verification rule also includes abnormal prompt information when the verification fails, and the verification unit is also used to:
[0048] When the verification result is that at least one parameter value of the to-be-verified parameter fails the verification, it is determined that the service request fails the verification, the service request is terminated, and the abnormal prompt information in the target verification rule is returned to the target service interface.
[0049] In one implementation, the verification unit is further configured to:
[0050] An adjustment operation is received, where the adjustment operation is an operation of adjusting the verification rule configuration information in real time on the visual management page;
[0051] In response to the adjustment operation, updating the verification rule configuration information;
[0052] The updated verification rule configuration information is hot loaded into the cache.
[0053] In a third aspect, an embodiment of the present application further provides a computer device, the computer device comprising: a memory and a processor. The memory stores instructions, the instructions are loaded and executed by the processor to implement the method in any of the above-mentioned embodiments. The memory and the processor communicate with each other through an internal connection path.
[0054] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program runs on a computer, the method in any one of the above-mentioned embodiments is implemented.
[0055] The advantages or beneficial effects of the above technical solution include at least:
[0056] This application places the parameter validity check of the business request between the business system and the real-time application system. The parameter validity check can be independent of the real-time service interface of the real-time application system and does not rely on the business logic of the real-time service interface. The independence of the parameter validity check can be achieved. It can also be guided by the verification rule configuration to achieve various flexible checks on the request parameters, which can not only meet the real-time and efficient performance requirements and ensure the validity of the business request data, but also meet the enterprise's needs for operational flexibility.
[0057] The above summary is for illustrative purposes only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments and features described above, further aspects, embodiments and features of the present application will be readily apparent by reference to the accompanying drawings and the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the multiple drawings represent the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments disclosed in the present application and should not be regarded as limiting the scope of the present application.
[0059] Figure 1 A flowchart of a pre-verification method based on real-time service provided by this application;
[0060] Figure 2 A structural block diagram of a pre-verification device provided in this application;
[0061] Figure 3 This is a structural block diagram of a computer device provided in this application. DETAILED DESCRIPTION
[0062] In the following, only some exemplary embodiments are briefly described. As those skilled in the art will appreciate, the described embodiments may be modified in various ways without departing from the spirit or scope of the present application. Therefore, the drawings and descriptions are considered to be exemplary and non-restrictive in nature.
[0063] Figure 1 The flowchart of the pre-verification method based on real-time service according to an embodiment of the present application is shown. The method can be executed by a pre-verification device, which is arranged between the business system and the real-time application system. Figure 1 As shown, the method may include the following steps:
[0064] S110: Obtain verification rule configuration information.
[0065] In one implementation, the verification rule configuration information is configured on a visual management page according to request parameters of any business interface.
[0066] In one embodiment, the pre-verification device can provide a visual management page, on which parameter verification can be abstracted into verification rules, and the verification rule configuration information can be visually managed through the visual page, thereby realizing visual configuration management of the verification rules.
[0067] In the specific implementation, the operator can configure the parameter verification of the specified business interface according to the business rules through the operations such as adding, modifying, deleting, and querying provided by the visual management page. For example, the request parameters of the business interface can be configured with rule verification one by one, and the corresponding rule verification content can be added. After the operator configures the verification rule configuration information, it can be saved by clicking the Save button provided on the visual management page. The pre-verification device can obtain the verification rule configuration information by responding to the operator's save operation.
[0068] In this application, by configuring the verification rule configuration information through the visual management page, the requirements of operational visualization and flexible rule-based configuration can be met. At the same time, the operator can intuitively view which business interfaces and which request parameters of the business interfaces have been configured with verification rules through the visual management page, which is convenient for later operation and maintenance.
[0069] S120: Load the verification rule configuration information into the cache.
[0070] In one implementation, the pre-verification device may load the verification rule configuration information into a cache to complete the initialization of the verification rule configuration information, so that the verification rule configuration information can be accessed and used in real time during the subsequent parameter verification process.
[0071] In this application, by loading the verification rule configuration information into the cache, the high-speed access efficiency of the cache can be utilized to ensure high concurrency and timeliness of subsequent verification rule access, facilitate the subsequent rapid completion of parameter legitimacy verification of business requests, and help improve the success rate of business processing.
[0072] S130: Receive a service request sent by a target service interface of the service system.
[0073] In one implementation, when an enterprise has a corresponding business need, a business request can be initiated through a business system. For example, taking the business system as an invoicing end business system, when an enterprise needs to issue an invoice, an invoicing request can be initiated through the invoicing business system. Correspondingly, the pre-verification device receives the business request.
[0074] In specific implementation, the target business interface can be understood as the business interface that currently initiates the business request of the business system.
[0075] S140: Perform parameter validity verification on the service request according to the verification rule configuration information to obtain a verification result.
[0076] In one implementation, the verification rule configuration information may include the interface name and verification rule of any business interface, and the verification rule may include but is not limited to the verification parameter path, verification method and its corresponding verification value. It can be understood that on the above-mentioned visual management page, the content to be configured includes the interface name, verification parameter path, verification method and its corresponding verification value of any business interface to be verified.
[0077] In the specific implementation, the interface name is used to specify the business interface that needs to be verified. For the same business interface, there are multiple parameters that need to be verified, and there may be multiple verification logics for the same parameter. Therefore, multiple verification rules can be configured for a certain parameter of the same business interface. If a business interface is not configured, the business request corresponding to the business interface will not be verified when passing through the front-end verification device, and will be directly transmitted to the back-end application interface (i.e., the application interface of the real-time application system).
[0078] In the specific implementation, the verification parameter path is used to represent the value label of the parameter to be verified. In this embodiment, JSON data format support can be provided, with the English period "." as the sub-object separator. For example, the configuration parameter path is fpmx.xmmc, indicating that the parameter xmmc needs to be verified, and the path to obtain the parameter is in the JSONObject object fpmx, as follows:
[0079]
[0080] In specific implementation, for different verification modes, the corresponding verification values have different meanings. Several examples are given below to illustrate.
[0081] Case 1: The verification method is to verify the parameter length.
[0082] In the first scenario, the minimum length, maximum length or fixed length of the parameter to be checked may be checked, and in this case, the check value is represented as the parameter length value.
[0083] Minimum length: The length of the parameter to be verified must meet the minimum length limit. For example, the minimum length of the configuration parameter is 8 (that is, the verification value indicates that the minimum length value is 8). For example, when the length of the parameter to be verified is equal to 4, which is less than the minimum length value, it does not meet the requirement and the verification fails.
[0084] Maximum length: The length of the parameter to be verified must meet the maximum length limit. For example, the maximum length of the configuration parameter is 8 (that is, the verification value indicates that the minimum length value is 8). For example, when the length of the parameter to be verified is equal to 10, it exceeds the maximum length value, does not meet the requirement, and the verification fails.
[0085] Fixed length: The length of the parameter to be verified is a fixed length limit, for example: the configuration parameter fixed length is 8 (that is, the verification value indicates a fixed length value of 8). For example, when the lengths of two parameters to be verified are equal to 3 and 10 respectively, the two parameters to be verified do not meet the requirement that the length value is equal to 8, and both fail to verify.
[0086] For example, in the scenario of a digital electricity invoice project, if the purchaser's name is required to be limited to no more than 300 characters, the verification method can be set to verify the maximum length of the purchaser's name parameter, and the verification value corresponding to this verification method is 300.
[0087] Case 2: The verification method is to verify the time format of the parameter.
[0088] In the second scenario, the format of the time parameter and the validity of the time data can be checked. In this case, the check value represents the time format value.
[0089] Among them, in the second situation, the time format specification in the Java language can be used. During verification, the parameter value of the parameter to be verified is tried to be converted according to the time format corresponding to the verification value. If the conversion fails, an exception is prompted.
[0090] For example, several sample parameter values (202305, 202313, 2023-12, 2023-11-04, 20231014, 2023-05-06 07:08:09), the verification results and descriptions in different verification values are as follows:
[0091] Verification value 1: YYmm, represents year and month, with no separator in the middle. Among the above sample parameter values, only 202305 meets the conditions, and the others do not meet the requirements for year and month data values.
[0092] Verification value 2: YY-mm-dd, which indicates year, month, and day, with "-" as a separator. Among the above sample parameter values, only 2023-11-04 meets the verification requirements, and the rest do not meet the verification value requirements.
[0093] Verification value 3: YY-mm-dd HH:MM:SS, which indicates year, month, day, hour, minute, and second. Among the above sample parameter values, only 2023-05-06 07:08:09 meets the verification requirements, and the rest do not meet the verification value requirements.
[0094] For example, in the scenario of digital invoice project, the issuance of red invoice requires that the invoice time format of the blue invoice passed in is YY-mm-dd HH:MM:SS. Then the verification method can be set to verify the time format of the blue invoice invoice time parameter. The verification value corresponding to this verification method is YY-mm-dd HH:MM:SS.
[0095] Case 3: The verification method is to verify the value range of the parameter.
[0096] In case 3, the parameter value range can be expressed using enumeration type, positive integer, negative number, floating point number, English letter string or Chinese character, etc. In this case, the check value is configured as a regular expression.
[0097] Enumeration type: For example, the regular expression is ^(01|02|03)$, which means that the value range of the parameter to be verified is limited to 01, 02, and 03.
[0098] Positive integer: For example, the regular expression is ^[1-9]\d*$, which means that the verification passes if the parameter value of the parameter to be verified is any positive integer.
[0099] Negative integer: For example, the regular expression is ^-[1-9]\d*$, which means that the verification passes if the parameter value of the parameter to be verified is any negative integer.
[0100] Floating point number: For example, if the regular expression is ^[-]? (([1-9]{1}\d*)|(0{1}))(\.\d{1,2})? $, the verification will pass if the parameter value to be verified is any 2 decimal places.
[0101] English string: For example, if the regular expression is ^[A-Za-z]+$, the verification passes if the parameter value of the parameter to be verified is a string consisting of uppercase and lowercase English letters.
[0102] Chinese characters: For example, the regular expression is ^[\u4e00-\u9fa5]+$, which means that the parameter value to be verified is a string consisting of Chinese characters, and the verification passes.
[0103] For example, in the scenario of digital invoice projects, the invoice types support two types: 01-special invoice and 02-ordinary invoice. The verification method can be set to verify the value range of the invoice type parameter. The value range is represented by an enumeration type, and the verification value corresponding to this verification method is ^(01|02)$.
[0104] Case 4: The verification method is to verify the dynamic value range of the parameter.
[0105] In scenario 4, the value range of the parameter to be verified is taken from the configuration data in the database, which can be used to verify the validity of the parameter. In this case, the verification value is configured as the database table and field name. The table name and field name of the database table are separated by ".".
[0106] For example, in the scenario of digital invoice items, the tax rate of the invoice item must exist in the available tax rate table. The verification value of the tax rate parameter can be set to: TAX_RATE.TAX_VALUE, which means that the parameter value range is taken from the TAX_VALUE field value of the TAX_RATE table.
[0107] In scenario 4, when the data in the database table is updated, it will be synchronously updated to the cache of the pre-verification device in real time, without affecting the data verification range of the pre-verification, thereby ensuring that the parameter value range configuration can be dynamically adjusted.
[0108] Case 5: The verification method is to verify the logical expression of the parameter.
[0109] In scenario five, the verification parameter path does not need to be configured, and the verification value is configured in the mode of a logical expression. Among them, the logical expression includes one or more verification parameters, all expressed in the form of ${XX}. In this embodiment, the pre-verification device can support simple logical expressions, replace the parameters to be verified with actual parameter values through lexical analysis, convert the expressions on both sides of the comparison operator into reverse Polish notations, store them in a stack, perform a pop calculation, compare the obtained results, and determine whether the final result of the logical expression is true. If it is not true, the verification fails, and the request input parameter is abnormal.
[0110] Other instructions for logical expressions:
[0111] Supported four arithmetic operators: addition (+), subtraction (-), multiplication (*), division ( / )
[0112] Supported comparison operators: equal to (==), greater than or equal to (>=), greater than (>), less than (<), less than or equal to (<=), not equal to (!=).
[0113] For example, in the scenario of the digital invoice project, the three request parameters are required to satisfy the following formula:
[0114] Amount excluding tax (fpje) + amount of tax (fpse) = amount including tax (jshj)
[0115] The check value can be configured as ${fpje}+${fpse}==${jshj}, which means that the sum of the values of the request parameters fpje and fpse is equal to the value of the parameter jshj. The detailed processing flow of the pre-check is as follows:
[0116] Step 1: Lexical analysis, get three parameters to be checked: fpje, fpse, jshj. Refer to the instructions in the verification parameter path, extract the parameter values of the above three parameters to be checked from the request parameters (assuming that the parameter values are: 3, 4, 6), use the parameter values to replace the above variables in the logical expression, and get the parameter-free logical expression: 3+4==6;
[0117] Step 2: Get the comparison operator "==";
[0118] Step 3: Using the comparison operator "==" as a separator, the two expressions are converted into reverse Polish notation, which are: 3 4+ and 6, and saved in the stack;
[0119] Step 4: Using the first-in, last-out feature of the stack, calculate the values of two reverse Polish expressions, and get 7 and 6 respectively;
[0120] Step 5: Use comparison operators to compare the two values obtained from the above calculations to determine whether the expression result is true or false. The result is false.
[0121] Step 6: Take corresponding actions based on the result (if the result is not true, the verification fails).
[0122] It should be understood that, in specific implementation, the verification methods involved in this application may not be limited to the verification methods in the above five situations. In practical applications, operators can add corresponding verification methods on the visual management page according to actual needs.
[0123] In this application, the mainstream JSON protocol can be supported (which can be further expanded to support XML, YAML and other formats), and multi-dimensional verification such as parameter length, time format, and value range can be supported. It can also support multiple types of personalized data verification methods such as dynamic value range and logical expression. It can associate the existing configuration of the database for validity verification, and is suitable for logical relationship comparison between multiple parameters, so as to meet most business application scenarios.
[0124] In one embodiment, the pre-verification device can query the target verification rule of the target business interface from the verification rule configuration information in the cache according to the interface name of the target business interface. The target verification rule refers to the verification rule of the target business interface. For example, after receiving the business request, the pre-verification device can extract the keyword in the business request (such as the interface name of the target business interface), and then read the target verification rule corresponding to the keyword from the cache according to the keyword.
[0125] In one implementation, the pre-verification device may parse the request parameters (i.e., request input parameters) of the business request according to the verification parameter path in the target verification rule, and extract the various parameters to be verified and their parameter values from the request parameters.
[0126] In one embodiment, the pre-verification device can perform a legality check on the parameter values of each parameter to be verified one by one according to the verification method and verification value in the target verification rule to obtain a verification result. For example, the target verification method corresponding to the parameter value of each parameter to be verified can be determined one by one according to the verification method in the target verification rule; then, according to the target verification method corresponding to the parameter value of each parameter to be verified, verify whether the parameter value of each parameter to be verified matches the verification value corresponding to the target verification method, so as to determine whether the parameter value of each parameter to be verified passes the verification and obtain the verification result. For example, in the scenario of a digital electricity invoice project, taking the buyer's name parameter as an example of a parameter to be verified in the request parameter, it can be verified whether the maximum length value of the buyer's name parameter meets or is less than or equal to 300. If it meets, the buyer's name parameter passes the verification.
[0127] In another embodiment, if the pre-verification device fails to query the target verification rule of the target business interface from the verification rule configuration information in the cache based on the interface name of the target business interface, it means that the target business interface does not need to perform parameter validity verification, and the pre-verification device can forward the business request directly to the real-time application system, and the real-time application system will perform corresponding business processing according to the business request.
[0128] S150: After determining that the service request has passed the verification according to the verification result, forward the service request to the real-time application system.
[0129] In one implementation, when the verification result is that the parameter values of all the parameters to be verified have passed the verification, it is determined that the service request has passed the verification. At this time, the pre-verification device can forward the service request to the real-time application system.
[0130] In this application, by setting the parameter validity check of the business request between the business system and the real-time application system, the parameter validity check can be independent of the real-time service interface of the real-time application system and does not rely on the business logic of the real-time service interface. The independence of the parameter validity check can be achieved, and various flexibility checks on the request parameters can be achieved based on the verification rule configuration. It can not only meet the real-time and efficient performance requirements and ensure the validity of the business request data, but also meet the enterprise's needs for operational flexibility.
[0131] It can be understood that the pre-verification device in this embodiment serves as a pre-filter of the real-time application system, which has a general verification capability and can be applied to http requests with POST method transmitted to JSON type parameters, such as business requests of digital electricity invoice systems.
[0132] For example, in the scenario of a digital electronic invoice project, since the pre-verification device has performed sufficient parameter legitimacy verification on the business request, the legitimacy of the business request can be ensured to meet business needs, thereby ensuring the success rate of the invoice system (real-time application system) uploading the bill to the digital electronic invoice platform (such as the Leqi Digital Platform).
[0133] In an applicable scenario provided by this application, operators can choose whether to configure abnormal prompt information when verification fails according to actual needs.
[0134] If you choose to configure the exception prompt information when the verification fails, the verification rules also include the exception prompt information when the verification fails. When the service request fails to pass the verification, the exception prompt information can be returned to the target service interface. That is, when it is determined according to the verification result that the service request has not passed the verification, the pre-verification device can terminate the service request and return the exception prompt information in the target verification rule to the target service interface. Among them, when the verification result is that there is at least one parameter value of the parameter to be verified that has not passed the verification, the pre-verification device can determine that the service request has not passed the verification.
[0135] If you do not choose to configure the exception prompt information when the verification fails, you can return according to the default prompt method of each verification method. For example, since regular expressions are not easy to read and write, you can set personalized text prompts through the following prompt method to improve the readability of the exception prompt information and facilitate the client that calls the business system to identify the cause of the exception.
[0136] For example, when using the regular expression ^(01|02|03)$ as the check value, you can set an exception prompt: the parameter value range is 01 / 02 / 03.
[0137] Because traditional data verification methods are rigid and inflexible, when using traditional data verification methods, once unknown anomalies occur during production applications, operators cannot respond and resolve them in a timely manner, and can only resolve them through code modification, version iteration, and application upgrade release. This will lead to a long problem repair and resolution cycle, which will continue to affect business operations and is not conducive to system operation and maintenance. From the perspective of system operation and maintenance, the business recovery time should be shortened as much as possible to achieve rapid response and resolution.
[0138] Based on this, in another applicable scenario provided by the present application, real-time adjustment of the verification rule configuration information can also be supported. For example, the pre-verification device receives an adjustment operation, and the adjustment operation is an operation to adjust the verification rule configuration information in real time on the visual management page. For example, if the operator finds that the parameters need to be strengthened or the verification method needs to be adjusted during the debugging and use process, the verification rule configuration information can be adjusted accordingly according to the real-time interface protocol parameters through the visual operation management page; the pre-verification device can respond to the adjustment operation and update the verification rule configuration information; and then hot load the updated verification rule configuration information into the cache.
[0139] In this application, by supporting real-time adjustment and hot loading of the verification rule configuration information, there is no need to upgrade and restart the real-time application system, which can achieve 7*24 hours of uninterrupted dynamic configuration adjustment and verification capability output. It can be dynamically adjusted according to the actual operation situation, reducing the iterative development of the application system, avoiding interface code modification and version release process, and ensuring the high concurrency and timeliness of subsequent verification rule access, so as to promptly solve the business anomalies caused by parameter verification problems during system operation, and shorten the business recovery time. At the same time, it can also achieve the effect of real-time configurable, adjustable, and visual operation and maintenance of the verification rule configuration information.
[0140] In summary, compared with the prior art, this application achieves the following effects:
[0141] Regularization: Supports parameter verification regularization, sets a general rule processing engine, and can dynamically expand rules to meet the flexibility requirements of operations.
[0142] Dynamic loading: supports cache hot loading and online modification of rule configuration, shortens the implementation cycle of business needs, and ensures uninterrupted system services.
[0143] Explicitness: Provides unified view of rules, including rule type, implementation method, judgment rule, rule description, etc.
[0144] Universality: The parameter validity check in this application is not only applicable to digital invoice projects, but can also be pushed to other real-time application systems.
[0145] Figure 2 FIG. 2 shows a structural block diagram of a pre-verification device according to an embodiment of the present application. Figure 2 As shown, the device may include:
[0146] The storage unit 210 is used to obtain the verification rule configuration information, which is configured on the visual management page according to the request parameters of any business interface; and load the verification rule configuration information into the cache;
[0147] The verification unit 220 is used to receive a business request sent by the target business interface of the business system; perform parameter validity verification on the business request according to the verification rule configuration information to obtain a verification result; after determining that the business request has passed the verification according to the verification result, forward the business request to the real-time application system.
[0148] In one implementation, the verification rule configuration information includes the interface name and verification rule of any service interface, and the verification rule includes a verification parameter path, a verification method and its corresponding verification value.
[0149] In one implementation, the verification unit 220 is specifically configured to:
[0150] According to the interface name of the target business interface, query the target verification rule of the target business interface from the verification rule configuration information in the cache;
[0151] According to the verification parameter path in the target verification rule, the request parameters of the business request are parsed, and each parameter to be verified and its parameter value to be verified are extracted from the request parameters;
[0152] According to the verification method and its corresponding verification value in the target verification rule, the legality of the parameter value of each parameter to be verified is verified one by one to obtain the verification result.
[0153] In one implementation, when the verification method is to verify the parameter length, the verification value corresponding to the verification method is the parameter length value;
[0154] When the verification method is the time format of the parameter, the verification value corresponding to the verification method is the time format value;
[0155] When the verification method is to verify the value range of the parameter, the verification value corresponding to the verification method is a regular expression;
[0156] When the verification method is to verify the dynamic value range of the parameter, the verification value corresponding to the verification method is the database table and field name;
[0157] When the verification method is to verify the logical expression of the parameter, the verification value corresponding to the verification method is the logical expression.
[0158] In one implementation, the verification unit 220 is specifically configured to:
[0159] According to the verification method in the target verification rule, determine the target verification method corresponding to the parameter value of each parameter to be verified one by one;
[0160] According to the target verification method corresponding to the parameter value of each parameter to be verified, verify whether the parameter value of each parameter to be verified meets the verification value corresponding to the target verification method, so as to determine whether the parameter value of each parameter to be verified passes the verification and obtain the verification result.
[0161] In one implementation, the verification unit 220 is specifically configured to: when the verification result is that the parameter values of each parameter to be verified have passed the verification, determine that the service request has passed the verification;
[0162] The verification rules also include abnormal prompt information when the verification fails. The verification unit 220 is also used to:
[0163] When the verification result is that there is at least one parameter value of the to-be-verified parameter that fails the verification, it is determined that the service request fails the verification, the service request is terminated, and the abnormal prompt information in the target verification rule is returned to the target service interface.
[0164] In one implementation, the verification unit 220 is further configured to:
[0165] An adjustment operation is received, where the adjustment operation is an operation of adjusting the verification rule configuration information in real time on the visual management page;
[0166] In response to the adjustment operation, updating the verification rule configuration information;
[0167] Hot load the updated validation rule configuration information into the cache.
[0168] The functions of each unit in each device in the embodiments of the present application can be found in the corresponding description in the above method, and will not be repeated here.
[0169] Figure 3 FIG. 2 shows a block diagram of a computer device according to an embodiment of the present application. Figure 3As shown, the computer device includes: a memory 310 and a processor 320. The memory 310 stores instructions, and the instructions are loaded and executed by the processor 320 to implement the pre-check method based on real-time service in the above embodiment. The number of the memory 310 and the processor 320 can be one or more.
[0170] The computer device also includes:
[0171] The communication interface 330 is used to communicate with external devices and perform data exchange transmission.
[0172] If the memory 310, the processor 320 and the communication interface 330 are implemented independently, the memory 310, the processor 320 and the communication interface 330 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 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.
[0173] Optionally, in a specific implementation, if the memory 310, the processor 320 and the communication interface 330 are integrated on a chip, the memory 310, the processor 320 and the communication interface 330 can communicate with each other through an internal interface.
[0174] An embodiment of the present application provides a computer-readable storage medium storing a computer program, which implements the method provided in the embodiment of the present application when the program is executed by a processor.
[0175] An embodiment of the present application also provides a chip, which includes a processor for calling and executing instructions stored in a memory, so that a communication device equipped with the chip executes the method provided by the embodiment of the present application.
[0176] An embodiment of the present application also provides a chip, including: an input interface, an output interface, a processor and a memory, wherein the input interface, the output interface, the processor and the memory are connected via an internal connection path, and the processor is used to execute the code in the memory. When the code is executed, the processor is used to execute the method provided in the embodiment of the application.
[0177] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. It is worth noting that the processor may be a processor supporting the advanced RISC machines (ARM) architecture.
[0178] Further, optionally, the above-mentioned memory may include a read-only memory and a random access memory, and may also include a non-volatile random access memory. The memory may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may include a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may include a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available. For example, static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct rambus RAM (DR RAM).
[0179] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of computer program cosmetics. Computer program cosmetics include one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium.
[0180] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification and the features of different embodiments or examples, unless they are contradictory.
[0181] In addition, 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 technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0182] Any process or method description in the flow chart or otherwise described herein can be understood to represent a module, fragment or portion of a code including one or more executable instructions for implementing the steps of a specific logical function or process. And the scope of the preferred embodiment of the present application includes other implementations, in which the functions may not be performed in the order shown or discussed, including in a substantially simultaneous manner or in a reverse order according to the functions involved.
[0183] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, which can be embodied in any computer-readable medium for use by an instruction execution system, apparatus or device (such as a computer-based system, a system including a processor or other system that can fetch instructions from an instruction execution system, apparatus or device and execute instructions), or used in combination with these instruction execution systems, apparatuses or devices.
[0184] It should be understood that the various parts of the present application can be implemented with hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented with software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the above embodiment method can be completed by instructing the relevant hardware through a program, which can be stored in a computer-readable storage medium, and when the program is executed, it includes one of the steps of the method embodiment or a combination thereof.
[0185] In addition, each functional unit in each embodiment of the present application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module. If the above-mentioned integrated module is implemented in the form of a software functional module and sold or used as an independent cosmetic, it can also be stored in a computer-readable storage medium. The storage medium can be a read-only memory, a disk or an optical disk, etc.
[0186] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A pre-verification method based on real-time service, characterized in that: include: Obtain verification rule configuration information, where the verification rule configuration information is configured on the visual management page according to the request parameters of any business interface; Loading the verification rule configuration information into a cache; Receive the business request sent by the target business interface of the business system; Performing parameter validity verification on the service request according to the verification rule configuration information to obtain a verification result; After determining that the service request passes the verification according to the verification result, the service request is forwarded to the real-time application system.
2. The method according to claim 1, characterized in that The verification rule configuration information includes the interface name and verification rule of any of the service interfaces, and the verification rule includes a verification parameter path, a verification method and its corresponding verification value.
3. The method according to claim 2, characterized in that According to the verification rule configuration information, the service request is subjected to parameter validity verification, and the verification result obtained includes: According to the interface name of the target service interface, query the target verification rule of the target service interface from the verification rule configuration information in the cache; According to the verification parameter path in the target verification rule, the request parameters of the business request are parsed, and each to-be-verified parameter and its parameter value that need to be verified are extracted from the request parameters; According to the verification method in the target verification rule and its corresponding verification value, the legality of the parameter value of each parameter to be verified is verified one by one to obtain the verification result.
4. The method according to claim 3, characterized in that When the verification method is to verify the parameter length, the verification value corresponding to the verification method is the parameter length value; When the verification method is to verify the time format of the parameter, the verification value corresponding to the verification method is the time format value; When the verification method is to verify the value range of the parameter, the verification value corresponding to the verification method is a regular expression; When the verification method is to verify the dynamic value range of the parameter, the verification value corresponding to the verification method is the database table and the field name; When the verification method is to verify the logical expression of the parameter, the verification value corresponding to the verification method is the logical expression.
5. The method according to claim 4, characterized in that According to the verification method and the corresponding verification value in the target verification rule, the legality of the parameter value of each parameter to be verified is verified one by one, and obtaining the verification result includes: According to the verification method in the target verification rule, determine the target verification method corresponding to the parameter value of each parameter to be verified one by one; According to the target verification method corresponding to the parameter value of each parameter to be verified, verify whether the parameter value of each parameter to be verified meets the verification value corresponding to the target verification method, so as to determine whether the parameter value of each parameter to be verified passes the verification and obtain the verification result.
6. The method according to claim 3, characterized in that Determining, according to the verification result, that the service request has passed the verification includes: when the verification result is that the parameter values of each of the parameters to be verified have passed the verification, determining that the service request has passed the verification; The verification rule also includes abnormal prompt information when the verification fails, and the method also includes: When the verification result is that at least one parameter value of the to-be-verified parameter fails the verification, it is determined that the service request fails the verification, the service request is terminated, and the abnormal prompt information in the target verification rule is returned to the target service interface.
7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: An adjustment operation is received, where the adjustment operation is an operation of adjusting the verification rule configuration information in real time on the visual management page; In response to the adjustment operation, updating the verification rule configuration information; The updated verification rule configuration information is hot loaded into the cache.
8. A pre-check device, characterized in that: include: A storage unit, used to obtain verification rule configuration information, wherein the verification rule configuration information is obtained by configuring on a visual management page according to request parameters of any business interface; and loading the verification rule configuration information into a cache; A verification unit, configured to receive a service request sent by a target service interface of a service system; perform parameter validity verification on the service request according to the verification rule configuration information to obtain a verification result; After determining that the service request passes the verification according to the verification result, the service request is forwarded to the real-time application system.
9. A computer device, characterized in that: include: A processor and a memory, wherein the memory stores instructions, and the instructions are loaded and executed by the processor to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed on a computer, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Self-adaptive data capturing method, equipment, storage medium and device
CN120892208A
Adaptive data capture methods, devices, storage media and apparatus
CN120892208B