CN117556809B - Parameter verification result generation method and device, verification platform and storage medium - Google Patents

Parameter verification result generation method and device, verification platform and storage medium Download PDF

Info

Publication number
CN117556809B
CN117556809B CN202410040435.2A CN202410040435A CN117556809B CN 117556809 B CN117556809 B CN 117556809B CN 202410040435 A CN202410040435 A CN 202410040435A CN 117556809 B CN117556809 B CN 117556809B
Authority
CN
China
Prior art keywords
request
module
error
verification
error code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202410040435.2A
Other languages
Chinese (zh)
Other versions
CN117556809A (en
Inventor
程康
单宏寅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ingeek Information Security Consulting Associates Co ltd
Original Assignee
Ingeek Information Security Consulting Associates Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ingeek Information Security Consulting Associates Co ltd filed Critical Ingeek Information Security Consulting Associates Co ltd
Priority to CN202410040435.2A priority Critical patent/CN117556809B/en
Publication of CN117556809A publication Critical patent/CN117556809A/en
Application granted granted Critical
Publication of CN117556809B publication Critical patent/CN117556809B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/226Validation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/541Client-server
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/549Remote execution

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the invention relates to the technical field of application parameter verification, and discloses a parameter verification result generation method and device, a verification platform and a storage medium. The method comprises the steps of receiving a request of calling a cloud application program interface API by a client; verifying the request based on the MVC verification framework and obtaining a verification result; when the checking result contains checking error information, searching corresponding target error code enumeration according to the checking error information and a preset error code enumeration list; each error code enumeration in the error code enumeration list includes: error codes and check error messages corresponding to the error codes; and (3) returning the requested error code and the check error message to the client according to the target error code enumeration, so that the corresponding error code and the check error message are automatically generated by binding the check rule, the check error message and the corresponding error code as the check failure result of each field, the availability of the check result when the check fails is increased, and the workload is small.

Description

Parameter verification result generation method and device, verification platform and storage medium
Technical Field
The embodiment of the invention relates to the technical field of application parameter verification, in particular to a parameter verification result generation method and device, a verification platform and a storage medium.
Background
The client often needs to perform parameter verification when calling the service of the server. Spring Validation is one of the currently used verification tools. Spring Validation the Hibernate Validator is packaged in another layer, and is convenient to use in Spring. Currently, when a verification result generated after verification failure contains message (message) of verification failure by using Spring Validation verification technology, error codes corresponding to the verification failure are absent, so that subsequent service logic distinction is inconvenient; and adding error codes for each verification failure result requires writing hard codes for each API (Application Programming Interface, application program interface) interface, exhausting each field to be verified, judging the verification failure result as binding error codes and error messages one by one, and the code writing and modifying workload is large.
Disclosure of Invention
The embodiment of the invention provides a parameter verification result generation method and device, a verification platform and a storage medium, which automatically generate corresponding error codes and verification error messages for verification failure results of each field by binding verification rules, verification error messages and corresponding error codes, thereby increasing the availability of the verification results when the verification fails, decoupling with service codes without hard coding and error code judgment on each interface, and greatly reducing the workload.
In a first aspect, an embodiment of the present invention provides a method for generating a parameter verification result, including: receiving a request of calling a cloud application program interface API by a client;
checking the request based on an MVC check frame and obtaining a check result;
when the checking result contains checking error information, searching corresponding target error code enumeration according to the checking error information and a preset error code enumeration list; wherein each error code enumeration in the error code enumeration list comprises: error codes and check error messages corresponding to the error codes;
and returning the error code of the request and checking error information to the client according to the target error code enumeration.
As an embodiment, the MVC check frame is a Spring MVC check frame, and the Spring MVC check frame includes: the system comprises a Request Mapping module, a Spring Validation module, a global exception handler, a Request Bean module and an error code enumeration module; the verification result comprises a verification error message;
the MVC-based verification framework verifies the request and obtains a verification result, and the method comprises the following steps:
the Request Mapping module obtains a Request object of the Request through the Request Bean module according to a Request path;
the Request Bean module obtains a model of the Request object according to the Request object and returns the model to the Request Mapping module, and the Request Mapping module obtains verification parameters of the model according to the model of the Request object and sends the verification parameters to the Spring Validation module;
the Spring Validation module performs verification according to the verification parameters of the model of the request object, and throws out verification abnormality information if verification is abnormal;
and the global processor captures the verification exception information and then extracts the verification error message of the request.
As an embodiment, the searching the corresponding target error code enumeration according to the checking error message and the preset error code enumeration list includes:
and the error code enumeration module receives the check error message of the request sent by the global exception handler, and searches the error code enumeration list according to the check error message to obtain the target error code enumeration.
As an embodiment, the Spring MVC check framework further includes: request Body Advice module; the returning the requested error code and checking error message to the client according to the target error code enumeration includes:
the error code enumeration module sends the target error code enumeration to the Request Body Advice module sequentially through the global exception handler and the API interface module;
the Request Body Advice module enumerates the target error codes to obtain the error codes of the request and checks the error messages and sends the error codes and the check error messages to the API interface module;
the API interface module returns the error code of the request to the client and checks the error message.
As an embodiment, the method further comprises:
the Spring Validation module sequentially sends a verification passing message to the Request Mapping module, the API interface module and the Request Body Advice module after the parameter verification of the Request is passed;
the Request Body Advice module assembles a request verification success message and then sends the request verification success message to the API interface module;
and the API interface module returns the request verification success message to the client.
In a second aspect, an embodiment of the present invention provides a parameter verification result generating apparatus, including:
the request receiving module is used for receiving a request of calling the cloud application program interface API by the client;
the verification module is used for verifying the request based on the MVC verification framework and obtaining a verification result;
the checking error searching module is used for searching a corresponding target error code enumeration according to the checking error message and a preset error code enumeration list when the checking result of the checking module comprises the checking error message; each error code enumeration in the error code enumeration list includes: error codes and check error messages corresponding to the error codes;
and the verification result returning module is used for returning the error code of the request and the verification error message to the client according to the target error code enumeration.
As an embodiment, the MVC check frame is a Spring MVC check frame, and the Spring MVC check frame includes: the system comprises a Request Mapping module, a Spring Validation module, a global exception handler, a Request Bean module and an error code enumeration module; the verification result comprises a verification error message;
the verification module comprises:
the Request object analysis sub-module is used for acquiring a Request object of the Request through the Request Bean module according to a Request path;
the parameter extraction sub-module is used for obtaining a model of the Request object according to the Request object and returning the model to the Request Mapping module, and the Request Mapping module is used for obtaining verification parameters of the model according to the model of the Request object and sending the verification parameters to the Spring Validation module;
the Spring verification sub-module is used for verifying according to the verification parameters of the model of the request object, and if verification is abnormal, verification abnormal information is thrown out;
and the verification error message capturing sub-module is used for extracting the verification error message of the request after the global exception handler captures the verification exception information.
As an embodiment, the checking error searching module includes: and the error code enumeration module receives the check error message of the request sent by the global exception handler, and searches the error code enumeration list according to the check error message to obtain the target error code enumeration.
In a third aspect, an embodiment of the present invention provides a verification platform, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements the method for generating a parameter verification result according to the first aspect when executing the program.
In a fourth aspect, an embodiment of the present invention provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor implements the method for generating a parameter verification result according to the first aspect.
Compared with the prior art, the technical scheme provided by the embodiment of the invention has at least the following positive effects:
according to the parameter verification result generation method, when the request is verified based on the MVC verification framework and the verification result contains the verification error message, the corresponding target error code enumeration is found according to the verification error message and the preset error code enumeration list, then the requested error code and the verification error message are returned to the client according to the target error code enumeration, and the verification result and the service code are decoupled by binding the verification rule with the error code and the error message, so that the corresponding error code and the verification error message can be output for the verification error of each field of each interface, the availability of the verification result is enhanced, hard coding and error code judgment are not needed, and the workload of coding and maintenance is reduced.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flow chart of a method for generating a parameter verification result according to a first embodiment of the present invention;
FIG. 2 is a schematic flow chart of a method for generating a parameter verification result according to a first embodiment of the present invention;
fig. 3 is a schematic structural diagram of a parameter verification result generating device according to a second embodiment of the present invention;
fig. 4 is a schematic structural diagram of a verification platform according to a third embodiment of the present invention.
Detailed Description
The invention is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present invention are shown in the drawings.
The inventor finds that when parameter verification is performed based on a Spring-verification framework in the prior art, after verification fails, a field error object is obtained from a BindingResult, so that a value of message set in a field to be verified is annotated, namely an error message when verification fails. Then, the error message is bound with a unified error code, that is, any field check fails, the generated error codes are the same, the check error messages of different parameters are different only in error message prompt, and at the moment, the request end cannot execute subsequent service logic according to the error code of the service. The inventor proposes a ingenious scheme, and by binding the check rule with the error message and the error code of the check annotation, the check error of each field can automatically generate the error code matched with the check rule, and the error code can be decoupled from the service code without hard coding and repeated judgment codes.
Fig. 1 is a flowchart of a method for generating a parameter verification result according to an embodiment of the present invention. The technical scheme of the embodiment is suitable for verification of the Web application request parameters. The method can be executed by the parameter verification result generating device provided by the embodiment of the invention, and the device can be realized in a software and/or hardware mode and is configured on a verification platform. The method specifically comprises the following steps:
step 101: and receiving a request of calling the cloud application program interface API by the client.
The client can call the cloud API to execute the required service based on the Web, for example, the service based on the digital key in the Internet of vehicles, and the embodiment of the invention does not particularly limit the actual service. The client can call an API of the cloud based on a Web page manufactured by the HTML5 specification.
Step 102: and verifying the request based on the MVC verification framework and obtaining a verification result.
The verification platform comprises: API interface module and Spring MVC check frame. The Spring MVC check framework includes: a Request Mapping module, a Spring Validation module, a global exception handler, a Request Bean module, a Request Body Advice module, and an error code enumeration module. The verification result comprises a verification success message and/or a verification error message.
Step 102 of verifying the request based on the MVC verification framework and obtaining the verification result may include: the Request Mapping module obtains a Request object of a Request through the Request Bean module according to a Request path, the Request Bean module obtains a model of the Request object according to the Request object and returns the model to the Request Mapping module, the Request Mapping module obtains verification parameters of the model according to the model of the Request object and sends the verification parameters to the Spring Validation module, the Spring Validation module verifies according to the verification parameters of the model of the Request object, if verification is abnormal, verification abnormality information is thrown out, and the global processor captures the verification abnormality information and then extracts the requested verification error information.
Step 103: when the checking result contains the checking error message, the corresponding target error code enumeration is found according to the checking error message and a preset error code enumeration list.
Wherein, each error code enumeration in the error code enumeration list comprises: error codes and check error messages corresponding to the error codes. The error code enumeration error codeenum list defines the error codes and check error messages of each API and each field of each parameter. Each error code enumeration in the error code enumeration error code enum is associated with a check error message, and the corresponding error code enumeration error code enum can be found according to the check error message.
Step 103 of searching for the corresponding target error code enumeration according to the checking error message and the preset error code enumeration list may include: and the error code enumeration module receives the check error message of the request sent by the global exception handler, and searches an error code enumeration list according to the check error message to obtain target error code enumeration.
Step 104: and returning the requested error code to the client according to the target error code enumeration and checking the error message.
And extracting the error code corresponding to the request from the target error code enumeration, and returning the error code to the client after checking the error message.
Step 104 of returning the requested error code to the client based on the target error code enumeration, and checking the error message, may include: the error code enumeration module sends the target error code enumeration to the Request Body Advice module sequentially through the global exception handler and the API interface module, the Request Body Advice module obtains the requested error code and the checking error message according to the target error code enumeration and sends the requested error code and the checking error message to the API interface module, and the API interface module returns the requested error code and the checking error message to the client.
When the verification results are that verification is successful, the Spring Validation module sequentially sends verification passing information to the Request Mapping module, the API interface module and the Request Body Advice module after the verification of the requested parameters is passed, the Request Body Advice module assembles the Request verification passing information and sends the Request verification passing information to the API interface module, and the API interface module returns the Request verification passing information to the client.
Fig. 2 is an exemplary flowchart of a parameter verification result generation method based on a Spring MVC verification framework, and the following details are described with reference to fig. 2 by taking the MVC verification framework as a Spring MVC verification framework as an example:
s201: the client calls a cloud API.
The client calls the cloud API through the Web, and the Spring MVC verification framework of the cloud can be used for parameter verification. An API interface (API Entry) module sends a Request to a Request Mapping module.
S202: the Request Mapping module obtains the Request object through the Request bean module.
Examples of Request objects are provided in Request Bean1, requestBean2, infra.
S203: the Request bean module returns the object model to the Request Mapping module.
S204: the Request Mapping module obtains the verification parameters of the object model according to the object model, and sends the verification parameters to the Spring Validation module for parameter verification.
S205: spring Validation mouldBlock and method for manufacturing the sameAnd performing parameter verification according to the verification parameters of the object model.
S206: after the verification is passed, the Spring Validation module sends the verification passing result to the API interface through the Request Mapping module.
S207: the API interface requests Request Body Advice module processes the verification result and returns the request data.
S208: the Request Body Advice module returns processed request data to the API interface.
The return data for which the parameters all pass the verification is, for example: { "code":0, "msg": "operation successful" }.
S209: the API interface returns the request data to the client.
S206-S209 are all cases that the parameters pass the verification, and the following steps 10-16 are the verification result return process of the parameter USERNAME_NULL (user name is NULL).
S210: when the parameter verification fails S205, the Spring Validation module throws out the verification failure exception.
S211: the global processor (Whole Exception Processor) captures the exception, fetches msg from the exception, msg is USER NAME NULL (USER NAME is NULL).
S212: the global processor sends a check error message msg to an error code enumeration module, which looks up the corresponding error code enum according to the check error message msg (msg=user_name_null).
S213: the error code enumeration module searches for target error code enumeration.
The target error code enumeration is USER_NAME_NULL { code:10000, msg: "USER NAME is NULL" }.
The error code enumeration module sequentially sends the target error code enumeration to the global exception handler and the API interface.
S214: the API interface request Request Body Advice enumerates the working return data according to the target error code.
S215: request Body Advice module processes the return data.
The returned data is: { "code":10000; "msg": "user name is null" }. The Request Body Advice module returns processed data to the API interface.
S216: the API interface returns interface request data to the client.
The returned request data contains: { "code":10000; "msg": "user name is null" }.
In S201-S216, the Spring MVC verification framework searches a corresponding Request method in a Controller from a Request Mapping according to a Request path, and then delivers the Request method to a Spring validation framework for verification according to an object to be verified defined in the method.
If the Username parameter is NULL, the Spring validation framework throws out one of the Bind Exception, method Argument Not Valid Exception, constraint Violation Exception according to the Username field usage @ NotNull (msg= "username_null") annotation defined in the Request Bean, then the global Exception handler captures the exceptions, after the Exception is obtained, the message is obtained from the Exception information, msg is username_null, then the username_null enumeration is found in the service error enumeration using username_null, and finally the data { "code":10000, "msg": "user name is NULL" } in the enumeration is returned to the client (APP/H5).
The embodiment of the invention decouples the generation of the error code from the service code by binding the verification rule, the verification error message and the error code, so that the generated verification result automatically contains the error code without hard coding and repeated judgment codes. The advantages of embodiments of the present invention compared to other schemes are described below in terms of pseudo code.
First, different schemes need to define the requested object and business error code. The request objects of the two interfaces, the corresponding fields to be checked and the corresponding service error codes are defined for different check result generation schemes.
Service error enumeration:
ErrorCodeEnum {
USERNAME_NULL {
code: 10000,
msg "user name is null"
},
PHONE_NO_NULL {
code: 10001,
msg, mobile phone number is empty.
},
PHONE_NO_WRONG_LENGTH {
code: 10002,
msg, that is, the length of the mobile phone number is incorrect "
},
VIN_NULL {
code: 10003,
msg "VIN is null"
},
VIN_WRONG_LENGTH {
code: 10004,
msg "VIN Length incorrect"
},
VALIDATE_ERROR {
code:99999
}
}
Comparative scheme 1: and checking each parameter in each interface by using a hard coding mode, then manually judging and identifying the field failing to check, and returning the corresponding error.
Request object:
RqusetBean1{
Username;
PhoneNo;
}
RequestBean2{
Username;
Vin;
}
where RequsetBean1 requires that the Username field cannot be empty, the PhoneNo field cannot be empty, and the length is 11 bits. RequestBean2 requires that the Username field cannot be null, the VinNo field cannot be null, and the length is 17 bits.
Interface 1: api/test1
test1(RequestBean1) {
if (RequsetBean1.Username == null)
return ErrorCodeEnum.USERNAME_NULL;
else if (RequestBean1.PhoneNo == null)
return ErrorCodeEnum.PHONE_NO_NULL;
else if ( RequestBean1.PhoneNo.length == 11)
return ErrorCodeEnum.PHONE_NO_WRONG_LENGTH;
}
Interface 2: api/test2
test2(RequestBean2) {
if (RequsetBean2.Username == null)
return ErrorCodeEnum.USERNAME_NULL;
else if (RequestBean2.Vin == null)
return ErrorCodeEnum.VIN_NULL;
else if (RequestBean2.Vin.length == 17)
return ErrorCodeEnum.VIN_WRONG_LENGTH;
}
Calling interface and interface response:
api/test1 { PhoneNo } = > { code:10001, msg: "user name is null" }
Api/test1 { Username } "Zhang San", phonNo } "123" } = > { code:10003, msg } "Mobile phone number Length incorrect" }
Api/test2 { Username } = > { code:10003, msg } "VIN length incorrect" }
As can be seen from the comparison scheme 1, the hard coding mode is adopted for each interface, each field to be checked in each interface needs to be written with a corresponding code, the complexity and the workload are great, the maintenance is inconvenient, and when one check field is changed, the code needs to be modified at multiple positions.
Comparison scheme 2: the Spring Validation framework is used and the return is judged in each interface method.
Request object:
RequestBean1{
NotNull (msg= "user name is empty')
Username;
NotNull (msg= "mobile phone number is empty')
@ Length (min=11, max=11, msg= "Mobile phone number Length incorrect")
PhoneNo;
}
RequestBean2{
NotNull (msg= "user name is empty')
Username;
NotNull (msg= "VIN is empty')
@ Length (min=17, max=17, msg= "VIN Length incorrect")
Vin;
}
Interface 1: api/test1
test1(@Valid ReuqsetBean1, BindResult) {
return {
code: ErrorCodeEnum.VALIDATE_ERROR.code,
msg: BindResult.msg
}
}
Interface 2: api/test2
test2(@Valid RequsetBean2, BindResult) {
return {
code: ErrorCodeEnum.VALIDATE_ERROR.code,
msg: BindResult.msg
}
}
Calling interface and interface response:
api/test1 { PhoneNo } = > { code:99999, msg: "user name is null" }
Api/test1 { Username } "Zhang San", phoneNo } "123" } = > { code:99999, msg } "Mobile phone number Length incorrect" }
Api/test2 { Username } = > { code:99999, msg: "VIN Length incorrect" }
It can be seen from the comparison scheme 2 that the return error code is required to be added in each interface method, and all check failures can only correspond to one error code (99999), if the client (APP/H5) executes the service logic according to the service error code, specific errors cannot be distinguished.
Comparison scheme 3: spring Validation framework and global exception handling are used.
Request object:
same as in comparative scheme 2
Interface 1: api/test1
test1(@Valid ReuqsetBean1);
Interface 2: api/test2
test2(@Valid RequestBean2);
Global exception handling:
WholeExceptionProcessor {
doException (BindException) {
return {
code: ErrorCodeEnum.VALIDATE_ERROR.code,
msg: BindException.errorField.msg
}
}
}
calling interface and interface response:
api/test1 { PhoneNo } = > { code:99999, msg: "user name is null" }
Api/test1 { Username } "Zhang San", phoneNo } "123" } = > { code:99999, msg } "Mobile phone number Length incorrect" }
Api/test2 { Username } = > { code:99999, msg: "VIN Length incorrect" }
Comparative scheme 3 is identical to comparative scheme 2 except that no error is required to be returned in each interface method, as compared to comparative scheme 2.
In the embodiment of the invention, the corresponding error code can be added for each check error message in the returned check result instead of a unified error code.
Scheme 4: embodiments of the invention
Request object:
RequestBean1{
@NotNull (msg = “USERNAME_NULL”)
Username;
@NotNull (msg = “PHONE_NO_NULL”)
@Length (min=11, max = 11, msg = “PHONE_NO_WRONG_LENGTH”)
PhoneNo;
}
RequestBean2{
@NotNull (msg = “USERNAME_NULL”)
Username;
@NotNull (msg = “VIN_NULL”)
@Length (min = 17, max = 17, msg =“VIN_WRONG_LENGTH”)
Vin;
}
interface 1: api/test1
test1(@Valid ReuqsetBean1);
Interface 2: api/test2
test2(@Valid RequestBean2);
WholeExceptionProcessor {
doException (BindException) {
return ErrorCodeEnum.find(BindException.errorField.msg);
}
}
Calling interface and interface response:
api/test1 { PhoneNo } = > { code:10001, msg: "user name is null" }
Api/test1 { Username } "Zhang San", phonNo } "123" } = > { code:10003, msg } "Mobile phone number Length incorrect" }
Api/test2 { Username } = > { code:10003, msg } "VIN length incorrect" }
The invention returns the error code corresponding to each check failure field, is decoupled from the service code, and only needs to bind the msg of the check rule and the check annotation with the error enumeration name when the interface and the field are changed, so that the code writing workload is small.
Compared with the prior art, the parameter check result generation method of the embodiment of the invention, when the request is checked based on the MVC check frame and the check result contains check error information, the corresponding target error code enumeration is found according to the check error information and the preset error code enumeration list, then the requested error code and the check error information are returned to the client according to the target error code enumeration, and the check result and the service code are decoupled by binding the check rule with the error code and the error information, so that the availability of the check result is enhanced, hard coding and error code judgment are not needed, and the workload of coding and maintenance is reduced.
The second embodiment of the invention provides a parameter verification result generating device which is configured on a verification platform, namely a cloud end. As shown in fig. 3, the parameter verification result generation apparatus 300 includes: a request receiving module 302, a verification module 304, a verification error finding module 306, and a verification result returning module 308.
The request receiving module 302 is configured to receive a request from a client to call a cloud application program interface API.
The verification module 304 is configured to verify the request based on the MVC verification framework and obtain a verification result.
The checking error searching module 306 is configured to, when the checking result of the checking module includes a checking error message, find a corresponding target error code enumeration according to the checking error message and a preset error code enumeration list. Each error code enumeration in the error code enumeration list includes: error codes and check error messages corresponding to the error codes.
The verification result returning module 308 is configured to return the requested error code and the verification error message to the client according to the target error code enumeration.
Optionally, the MVC check frame may be a Spring MVC check frame, where the Spring MVC check frame includes: the system comprises a Request Mapping module, a Spring Validation module, a global exception handler, a Request Bean module and an error code enumeration module. The check result comprises a check pass and/or a check error message.
The verification module comprises: the Request object analysis sub-module is used for acquiring a Request object of a Request through the Request Bean module according to a Request path; the Request Bean module obtains a model of the Request object according to the Request object and returns the model to the Request Mapping module, and the Request Mapping module obtains the verification parameters of the model according to the model of the Request object and sends the verification parameters to the Spring Validation module; the Spring verification sub-module Spring Validation module performs verification according to the verification parameters of the model of the request object, and throws out verification abnormality information if verification is abnormal; and the verification error message capturing sub-module is used for capturing verification abnormal information by the global abnormal processor and then extracting the requested verification error message.
The check error lookup module 306 includes: and the error code enumeration module receives the check error message of the request sent by the global exception handler, and searches an error code enumeration list according to the check error message to obtain target error code enumeration.
Optionally, the Spring MVC check framework includes further includes: request Body Advice module. The check result return module 308 includes: the error code enumeration module sends the target error code enumeration to the Request Body Advice module sequentially through the global exception handler and the API interface module; the Request Body Advice module enumerates the error codes according to the target error codes to obtain the requested error codes and sends the error messages to the API interface module after checking the error messages; the API interface module returns the requested error code to the client and verifies the error message.
Optionally, the verification result returning module 308 includes: the Spring Validation module sequentially sends verification passing information to the Request Mapping module, the API interface module and the Request Body Advice module after the requested parameter is verified; the Request Body Advice module assembles the request verification success message and then sends the request verification success message to the API interface module; and the API interface module returns a request verification success message to the client.
Compared with the prior art, when the request is checked based on the MVC check frame and the check result contains check error information, the parameter check result generating device searches the corresponding target error code enumeration according to the check error information and the preset error code enumeration list, then returns the requested error code and the check error information to the client according to the target error code enumeration, and the check result is decoupled from the service code by binding the check rule with the error code and the error information, so that the availability of the check result is enhanced, hard coding and error code judgment are not needed, and the workload of coding and maintenance is reduced.
The parameter verification result generating device provided by the embodiment can execute the parameter verification result generating method provided by the embodiment of the method, and has the corresponding functional modules and beneficial effects of the executing method. The implementation principle and technical effect of the present embodiment are similar to those of the above method embodiment, and are not described here again.
Fig. 4 is a schematic structural diagram of a verification platform according to a third embodiment of the present invention. The verification platform 40 comprises a memory 41, a processor 42 and a computer program stored in the memory 41 and capable of running on the processor 42, wherein the processor 42 implements the technical solution according to the first embodiment when executing the program.
A fourth embodiment of the present invention provides a computer-readable storage medium having stored thereon a computer program for performing the technical solutions of any of the method embodiments when executed by a computer processor.
From the above description of embodiments, it will be clear to a person skilled in the art that the present invention may be implemented by means of software and necessary general purpose hardware, but of course also by means of hardware, although in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, etc., including several instructions for causing a computer device (which may be a personal computer, a server, a grid device, etc.) to execute the method according to the embodiments of the present invention.
It should be noted that, in the embodiment of the apparatus, each unit and module included are only divided according to the functional logic, but not limited to the above-mentioned division, so long as the corresponding function can be implemented; in addition, the specific names of the functional units are also only for distinguishing from each other, and are not used to limit the protection scope of the present invention.
Note that the above is only a preferred embodiment of the present invention and the technical principle applied. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, while the invention has been described in connection with the above embodiments, the invention is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit or scope of the invention, which is set forth in the following claims.

Claims (6)

1. The method for generating the parameter verification result is characterized by comprising the following steps of:
receiving a request of calling a cloud application program interface API by a client;
checking the request based on an MVC check frame and obtaining a check result;
when the checking result contains checking error information, searching corresponding target error code enumeration according to the checking error information and a preset error code enumeration list; wherein each error code enumeration in the error code enumeration list comprises: error codes and check error messages corresponding to the error codes;
returning the error code of the request to the client according to the target error code enumeration and checking error information;
the MVC check frame is a Spring MVC check frame, and the Spring MVC check frame comprises: the system comprises a Request Mapping module, a Spring Validation module, a global exception handler, a Request Bean module and an error code enumeration module;
the MVC-based verification framework verifies the request and obtains a verification result, and the method comprises the following steps:
the Request Mapping module obtains a Request object of the Request through the Request Bean module according to a Request path;
the Request Bean module obtains a model of the Request object according to the Request object and returns the model to the Request Mapping module, and the Request Mapping module obtains verification parameters of the model according to the model of the Request object and sends the verification parameters to the Spring Validation module;
the Spring Validation module performs verification according to the verification parameters of the model of the request object, and throws out verification abnormality information if verification is abnormal;
the global exception handler captures the check exception information and then extracts the check error message of the request;
the searching the corresponding target error code enumeration according to the checking error message and the preset error code enumeration list comprises the following steps:
the error code enumeration module receives the check error message of the request sent by the global exception handler, and searches the error code enumeration list according to the check error message to obtain the target error code enumeration;
the Spring MVC check frame further includes: request Body Advice module; the returning the requested error code and checking error message to the client according to the target error code enumeration includes:
the error code enumeration module sends the target error code enumeration to the Request Body Advice module sequentially through the global exception handler and the API interface module;
the Request Body Advice module enumerates the target error codes to obtain the error codes of the request and checks the error messages and sends the error codes and the check error messages to the API interface module;
the API interface module returns the error code of the request to the client and checks the error message.
2. The method for generating a parameter verification result according to claim 1, further comprising:
the Spring Validation module sequentially sends a verification passing message to the Request Mapping module, the API interface module and the Request Body Advice module after the parameter verification of the Request is passed;
the Request Body Advice module assembles a request verification success message and then sends the request verification success message to the API interface module;
and the API interface module returns the request verification success message to the client.
3. A parameter verification result generating apparatus, comprising:
the request receiving module is used for receiving a request of calling the cloud application program interface API by the client;
the verification module is used for verifying the request based on the MVC verification framework and obtaining a verification result;
the checking error searching module is used for searching a corresponding target error code enumeration according to the checking error message and a preset error code enumeration list when the checking result of the checking module comprises the checking error message; each error code enumeration in the error code enumeration list includes: error codes and check error messages corresponding to the error codes;
the verification result returning module is used for returning the error code of the request and the verification error message to the client according to the target error code enumeration;
the MVC check frame is a Spring MVC check frame, and the Spring MVC check frame comprises: the system comprises a Request Mapping module, a Spring Validation module, a global exception handler, a Request Bean module and an error code enumeration module;
the verification module comprises:
the Request object analysis sub-module is used for acquiring a Request object of the Request through the Request Bean module according to a Request path;
the parameter extraction sub-module is used for obtaining a model of the Request object according to the Request object and returning the model to the Request Mapping module, and the Request Mapping module is used for obtaining verification parameters of the model according to the model of the Request object and sending the verification parameters to the Spring Validation module;
the Spring verification sub-module is used for verifying according to the verification parameters of the model of the request object, and if verification is abnormal, verification abnormal information is thrown out;
the verification error message capturing sub-module is used for extracting the verification error message of the request after the global exception handler captures the verification exception information;
the checking error searching module comprises: the error code enumeration module receives the check error message of the request sent by the global exception handler, and searches the error code enumeration list according to the check error message to obtain the target error code enumeration;
the Spring MVC check frame further includes: request Body Advice module;
the verification result return module comprises: the error code enumeration module sends the target error code enumeration to the Request Body Advice module sequentially through the global exception handler and the API interface module;
the Request Body Advice module enumerates the target error codes to obtain the error codes of the request and checks the error messages and sends the error codes and the check error messages to the API interface module;
the API interface module returns the error code of the request to the client and checks the error message.
4. The parameter verification result generation apparatus of claim 3, wherein the verification result return module further comprises: the Spring Validation module sequentially sends a verification passing message to the Request Mapping module, the API interface module and the Request Body Advice module after the parameter verification of the Request is passed;
the Request Body Advice module assembles a request verification success message and then sends the request verification success message to the API interface module;
and the API interface module returns the request verification success message to the client.
5. A verification platform comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the parameter verification result generation method of claim 1 or 2 when executing the program.
6. A computer-readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the parameter verification result generation method as claimed in claim 1 or 2.
CN202410040435.2A 2024-01-11 2024-01-11 Parameter verification result generation method and device, verification platform and storage medium Active CN117556809B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410040435.2A CN117556809B (en) 2024-01-11 2024-01-11 Parameter verification result generation method and device, verification platform and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410040435.2A CN117556809B (en) 2024-01-11 2024-01-11 Parameter verification result generation method and device, verification platform and storage medium

Publications (2)

Publication Number Publication Date
CN117556809A CN117556809A (en) 2024-02-13
CN117556809B true CN117556809B (en) 2024-03-29

Family

ID=89823587

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410040435.2A Active CN117556809B (en) 2024-01-11 2024-01-11 Parameter verification result generation method and device, verification platform and storage medium

Country Status (1)

Country Link
CN (1) CN117556809B (en)

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101234701B1 (en) * 2011-08-24 2013-02-19 주식회사 미니게이트 Error processing system for server platform
WO2014171950A1 (en) * 2013-04-19 2014-10-23 Hewlett-Packard Development Company, L.P. Unused parameters of application under test
KR20180039198A (en) * 2016-10-07 2018-04-18 주식회사 케이티 Methods for Generic Procedure of Receiver CSE and Apparatuses thereof
CN109408250A (en) * 2018-09-27 2019-03-01 天津字节跳动科技有限公司 Call application programming interface API approach, device, electronic equipment
CN110347560A (en) * 2019-07-19 2019-10-18 深圳前海微众银行股份有限公司 Abnormal prompt method, apparatus, system, equipment and the medium of big data product
CN110673838A (en) * 2019-09-10 2020-01-10 四川新网银行股份有限公司 Input checking method
US10628243B1 (en) * 2018-11-27 2020-04-21 International Business Machines Corporation Validation framework for runtime connected API systems
CN111858087A (en) * 2020-06-22 2020-10-30 中国平安财产保险股份有限公司 Data submission checking method, device, equipment and storage medium
CN112581659A (en) * 2020-12-04 2021-03-30 上海银基信息安全技术股份有限公司 Digital key user passing method, device, system and storage medium
CN113127108A (en) * 2021-04-22 2021-07-16 京东数科海益信息科技有限公司 Service request processing method and device, storage medium and electronic equipment
CN114115906A (en) * 2021-12-01 2022-03-01 中国建设银行股份有限公司 Transaction error code checking method and device, computer equipment and storage medium
CN115061851A (en) * 2022-06-08 2022-09-16 网易(杭州)网络有限公司 Data verification method and device, storage medium and electronic equipment

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7461385B2 (en) * 2003-05-06 2008-12-02 Qad Corporation Method for establishing a new user interface via an intermingled user interface
US7856623B2 (en) * 2006-05-05 2010-12-21 Sap Ag Method and system for providing an enumeration assistant
US9894185B2 (en) * 2014-12-16 2018-02-13 Software Ag System and method for condition-based application logic shifting between a client and a server

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101234701B1 (en) * 2011-08-24 2013-02-19 주식회사 미니게이트 Error processing system for server platform
WO2014171950A1 (en) * 2013-04-19 2014-10-23 Hewlett-Packard Development Company, L.P. Unused parameters of application under test
KR20180039198A (en) * 2016-10-07 2018-04-18 주식회사 케이티 Methods for Generic Procedure of Receiver CSE and Apparatuses thereof
CN109408250A (en) * 2018-09-27 2019-03-01 天津字节跳动科技有限公司 Call application programming interface API approach, device, electronic equipment
US10628243B1 (en) * 2018-11-27 2020-04-21 International Business Machines Corporation Validation framework for runtime connected API systems
CN110347560A (en) * 2019-07-19 2019-10-18 深圳前海微众银行股份有限公司 Abnormal prompt method, apparatus, system, equipment and the medium of big data product
CN110673838A (en) * 2019-09-10 2020-01-10 四川新网银行股份有限公司 Input checking method
CN111858087A (en) * 2020-06-22 2020-10-30 中国平安财产保险股份有限公司 Data submission checking method, device, equipment and storage medium
CN112581659A (en) * 2020-12-04 2021-03-30 上海银基信息安全技术股份有限公司 Digital key user passing method, device, system and storage medium
CN113127108A (en) * 2021-04-22 2021-07-16 京东数科海益信息科技有限公司 Service request processing method and device, storage medium and electronic equipment
CN114115906A (en) * 2021-12-01 2022-03-01 中国建设银行股份有限公司 Transaction error code checking method and device, computer equipment and storage medium
CN115061851A (en) * 2022-06-08 2022-09-16 网易(杭州)网络有限公司 Data verification method and device, storage medium and electronic equipment

Also Published As

Publication number Publication date
CN117556809A (en) 2024-02-13

Similar Documents

Publication Publication Date Title
US9594619B2 (en) Robust hardware fault management system, method and framework for enterprise devices
CN110058864B (en) Micro-service deployment method and device
KR102044046B1 (en) Telemetry file hash and conflict detection
CN112068902B (en) Plug-in calling method and device, electronic equipment and storage medium
CN107835228B (en) Instruction processing method and device based on dynamic generalized routing
CN110633160A (en) Interface calling method and device, computer equipment and storage medium
CN112835782B (en) Interface access test method and system
CN105743725A (en) Method and device for testing application programs
CN109240923B (en) Interface test script generation method and computer readable storage medium
CN117556809B (en) Parameter verification result generation method and device, verification platform and storage medium
CN116361793A (en) Code detection method, device, electronic equipment and storage medium
CN115373885A (en) Fault repairing method and device, storage medium and electronic equipment
CN115396221A (en) Authorization processing method, device and system, electronic equipment and storage medium
CN112181816B (en) Scene-based interface testing method and device, computer equipment and medium
CN114968822A (en) Interface testing method and device, computer equipment and storage medium
CN111597573B (en) Page embedding method and device, computer equipment and storage medium
CN109828752B (en) Project code automatic generation method, device, computer equipment and storage medium
CN112667323A (en) Application system page processing method and device, computer equipment and storage medium
CN111475400A (en) Verification method of service platform and related equipment
CN112286786A (en) Database testing method and device and server
CN111045937A (en) Interface calling test method, server and storage medium
CN115242625B (en) Service deployment method, device, computer equipment and readable storage medium
CN110012023B (en) Poison-throwing type anti-climbing method, system, terminal and medium
CN114416106B (en) Method, system, electronic device and storage medium for updating compiling count value
CN112685135A (en) Platform cluster deployment method, device and system and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant