Disclosure of Invention
An object of the present application is to provide a form submission method and apparatus, which can provide a simple and easy-to-use access method, no service code intrusion, high-multiplexing, stable and safe anti-replay service.
According to one aspect of the application, a form submission method is provided, which is applied to a server, wherein the method comprises the following steps:
creating a recombination-preventing part;
receiving a re-proof request sent by a client in response to the target form being opened, wherein the re-proof request comprises an identifier of the target form and an opening time;
the anti-duplication component generates anti-duplication information for the target form, and stores the opening time and the anti-duplication information of the target form;
returning the anti-duplication information of the target form to the client;
receiving a form submission request of the target form sent by the client, wherein the form submission request comprises the service data, the anti-duplication information and submission time;
the anti-recombination component acquires the opening time based on the anti-recombination information, and verifies whether the target form is repeatedly submitted or not based on the opening time and the submission time;
and if not, processing the service data and returning a service processing result of the target form to the client.
Further, in the above method, after checking whether the target form is repeatedly submitted based on the opening time and the submission time, the method further includes:
and if so, returning response information for indicating the repeated submission of the target form to the client.
Further, in the above method, the method further includes:
presetting a cache database, wherein the cache database is independent from the anti-recombination component;
wherein storing the open time and the anti-duplication information of the target form comprises:
storing the opening time and the anti-duplication information of the target form to the cache database;
wherein the anti-reassembly component acquires the open time based on the anti-duplication information, comprising:
the anti-reassembly component obtains the opening time corresponding to the anti-reassembly information from the cache database based on the anti-reassembly information.
Further, in the above method, the checking, by the anti-reassembly component, whether the target form is repeatedly submitted based on the opening time and the submission time includes:
inquiring and acquiring a target anti-duplication time length threshold corresponding to the target form;
calculating a time difference between the opening time and the commit time;
judging whether the time difference is larger than the target anti-weight duration threshold value or not,
if yes, indicating the target form to be repeatedly submitted;
if not, indicating that the target form is not repeatedly submitted.
Further, in the above method, the method further includes:
presetting anti-reconfiguration information, wherein the anti-reconfiguration information comprises at least one preset form and a first anti-reconfiguration time length threshold corresponding to each easily preset form;
wherein, the querying and obtaining the target anti-duplication duration threshold corresponding to the target form comprises:
inquiring whether a first anti-repeating time length threshold corresponding to the target form exists in the anti-reconfiguring information,
if the target form exists, determining a first anti-duplication time length threshold corresponding to the target form in the anti-reconfiguration information as the target anti-duplication time length threshold;
and if the target anti-duplication time length does not exist, determining a preset second anti-duplication time length threshold as the target anti-duplication time length threshold, wherein the second anti-duplication time length threshold is suitable for any form.
According to another aspect of the present application, there is also provided a form submission method applied to a client, where the method includes:
responding to the opening of a target form, and sending a re-protection request to a server, wherein the re-protection request comprises an identifier and an opening time of the target form, so that a re-protection component created in the server generates re-protection information for the target form and stores the opening time and the re-protection information of the target form;
receiving the anti-duplication information of the target form returned by the server;
acquiring the service data of the target form;
sending a form submission request to the server, wherein the form submission request comprises the business data, the anti-duplication information and submission time, so that the server checks whether the target form is repeatedly submitted or not based on the anti-duplication information, the opening time and the submission time;
and when the target form is not repeatedly submitted, receiving a service processing result of the target form returned by the server.
Further, in the above method, the method further includes:
and when the target form is repeatedly submitted, receiving response information returned by the server and used for indicating the repeated submission of the target form.
According to another aspect of the present application, there is also provided a non-volatile storage medium having computer readable instructions stored thereon, which, when executed by a processor, cause the processor to implement the form submission method as described above.
According to another aspect of the present application, there is also provided a server for form submission, wherein the server includes:
one or more processors;
a computer-readable medium for storing one or more computer-readable instructions,
when executed by the one or more processors, cause the one or more processors to implement a form submission method for a server as described above.
According to another aspect of the present application, there is also provided a client for form submission, wherein the client includes:
one or more processors;
a computer-readable medium for storing one or more computer-readable instructions,
when executed by the one or more processors, cause the one or more processors to implement a form submission method for a client as described above
Compared with the prior art, the client side sends the anti-replay request to the server side in response to the target form being opened, wherein the anti-replay request comprises the identifier and the opening time of the target form; a duplicate prevention component is created in a server, the duplicate prevention component generates duplicate prevention information for the target form, the opening time and the duplicate prevention information of the target form are stored, and the server returns the duplicate prevention information of the target form to the client; the client receives the anti-duplication information of the target form returned by the server, acquires the service data of the target form, and sends a form submission request to the server, wherein the form submission request comprises the service data, the anti-duplication information and submission time; and the server checks whether the target form is repeatedly submitted or not based on the anti-duplication information, the opening time and the submitting time, and if not, the server processes the business data and returns the business processing result of the target form to the client so that the client receives the business processing result of the target form returned by the server. The anti-duplication component is created by taking out the anti-duplication part for the form from the service, and the anti-duplication component is packaged into the independently deployed component system, so that a simple and easy-to-use access mode is provided, no service code is invaded, and the high-multiplexing and stable and safe anti-duplication service is provided.
Detailed Description
The present application is described in further detail below with reference to the attached figures.
In a typical configuration of the present application, the terminal, the device serving the network, and the trusted party each include one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory computer readable media (transient media), such as modulated data signals and carrier waves.
Fig. 1 shows an interaction flow diagram of a form submission method according to an aspect of the present application, where the method includes steps S11, S12, S13, S14, S15, and S16 executed by a client, and steps S21, S22, S23, S24, S25, S26, S27, and S28 executed by a server, and specifically includes the following steps:
at the server, in order to verify whether the form is submitted repeatedly, in step S21, the server creates an anti-reassembly component, so that the anti-reassembly component is independent from the business processes corresponding to the form, i.e., is extracted from the business processes of the form, thereby avoiding mutual interference and intrusion between the codes of the business processes and the anti-reassembly component submitted by the form.
Step S11, the client sends a request for preventing duplication to the server in response to the target form being opened, the request for preventing duplication includes the identifier and the opening time of the target form, so that a duplication preventing component created in the server generates duplication preventing information for the target form and stores the opening time and the duplication preventing information of the target form; as shown in fig. 2, when a client (corresponding to the front end in fig. 2) opens a target form, the client calls a server (corresponding to the background application in fig. 2) that creates an anti-duplication component.
Step S22, the server receives a request for preventing the re-sending of the client responding to the opening of the target form, the request for preventing the re-sending includes the identifier and the opening time of the target form; here, the opening time is used to indicate a corresponding real-time when the client opens the target form.
Step S23, the anti-reassembly component of the server generates anti-duplication information for the target form, and stores the opening time and the anti-duplication information of the target form. For example, after receiving a request for preventing duplication of a target form sent by a client, a server obtains, by means of an interface provided by a duplication prevention component and used for generating duplication prevention information, duplication prevention information generated by the duplication prevention component for the request for preventing duplication of the target form, where the duplication prevention information includes, but is not limited to, information for preventing duplication, such as a character string for preventing duplication, an duplication prevention code, and a duplication prevention password, in a preferred embodiment of the present application, the duplication prevention information is preferably a duplication prevention code, as shown in fig. 2.
And step S24, the server returns the anti-duplication information of the target form to the client.
Step S12, the client receives the anti-duplication information of the target form returned by the server.
Step S13, the client obtains the service data of the target form, and as shown in fig. 2, after obtaining the duplication prevention information of the target form, enters the service data of the target form.
Step S14, the client sends a form submission request to the server, where the form submission request includes the service data, the anti-duplication information and the submission time, so that the server checks whether the target form is repeatedly submitted based on the anti-duplication information, the opening time and the submission time; here, the anti-duplication information setting may be encapsulated in a request header of the form submission request, where a definition rule in the request header is: and the X-duplication-code is used for judging whether to pass or prevent the re-verification of the form submission request through the request header in the following process.
Step S25, the server receives a form submission request of the target form sent by the client, where the form submission request includes the service data, the duplication prevention information, and a submission time. Here, the server intercepts a form submission request sent by the client by using an interceptor of a spring framework, such as a component interceptor shown in fig. 3, where the component interceptor is defined in an SDK package provided by an accessed background system (corresponding to the server), and also provides an interception description and an interception configuration, so as to select various function configurations provided by the component according to the interception description and the interception configuration. For example, when the component interceptor intercepts, it first determines whether a request header exists in a form submission request, and if no request header exists, it indicates that the target form does not need to be subjected to anti-replay verification, and the anti-replay component does not perform any intervention on the form submission request, so that the server can directly pass the form submission request so as to enter a subsequent application interface, as shown in fig. 3; and if the form submission request carries a request header, performing anti-recheck on the form request.
Step S26, the server side obtains the opening time based on the anti-duplication information through the anti-duplication component, and verifies whether the target form is repeatedly submitted based on the opening time and the submission time;
if not, go to step S27; if yes, go to step S28.
In step S27, the server processes the service data and returns a service processing result of the target form to the client, that is, when the target form is not repeatedly submitted, the server can process the service data corresponding to the target form, as shown in fig. 2, and returns the service processing result of the target form to the client, so that the client performs step S15, receives the service processing result of the target form returned by the server, and implements service processing on the target form that is not repeatedly submitted.
In step S28, the server returns response information indicating that the target form is repeatedly submitted to the client, that is, when the target form is repeatedly submitted, the server cannot process the service data corresponding to the target form, and needs to return response information indicating that the target form is repeatedly submitted to the client, as shown in fig. 2, response information such as submission failure is returned to the client, so that the client performs step S16, receives the response information returned by the server and indicating that the target form is repeatedly submitted, and implements response processing on the repeatedly submitted target form, so that the client can know that the target form is repeatedly submitted in time through the response information.
Through the steps S11 to S16 and S21 to S28, the present application provides a simple and easy-to-use access method, and no service code intrusion, so that the anti-duplication service is provided with high multiplexing and stable security by extracting the anti-duplication for the form from the service, creating an anti-duplication component, and packaging the anti-duplication component into an independently deployed component system.
Further, a method for submitting a form of a server provided by an embodiment of the present application further includes:
presetting a cache database, wherein the cache database is independent from the anti-recombination component;
wherein storing the open time and the anti-duplication information of the target form comprises:
storing the opening time and the anti-duplication information of the target form to the cache database;
wherein the anti-reassembly component acquires the open time based on the anti-duplication information, comprising:
the anti-reassembly component obtains the opening time corresponding to the anti-reassembly information from the cache database based on the anti-reassembly information.
For example, at a server, in order to store the anti-duplication information for a form with an anti-duplication request, the server presets a cache database, such as a Redis cache database, etc., wherein the cache database and the anti-duplication component are independent from each other at the server; in step S23, the server stores the opening time of the target form and the duplication preventing information into the cache database in a form of a mapping relationship, that is, the duplication preventing information is used as a key, the opening time of the target form is used as a value, and the opening time of the target form is stored into the cache database in a (key, value) form, so that the opening time of the target form can be found through the duplication preventing information in the subsequent step; in step S26, after the service receives the form submission request, the anti-reassembly component obtains the opening time corresponding to the anti-reassembly information from the cache database based on the anti-reassembly information carried in the request header in the form submission request, and queries the opening time of the target form corresponding to the form submission request through the cache database and the anti-reassembly information.
Further, the S26 restructuring-prevention component checks whether the target form is repeatedly submitted based on the opening time and the submission time, specifically including:
inquiring and acquiring a target anti-duplication time length threshold corresponding to the target form;
calculating a time difference between the opening time and the commit time;
judging whether the time difference is larger than the target anti-weight duration threshold value or not,
if yes, indicating the target form to be repeatedly submitted;
if not, indicating that the target form is not repeatedly submitted.
For example, when a service segment performs a re-proof check on a target form, first obtaining a target re-proof duration threshold T corresponding to the target form a, and calculating a time difference T 'between an opening time T1 of the target form and a submission time T2 of the target form, to determine whether the time difference T' is greater than the target re-proof duration threshold T, if so, the re-proof check of the target form fails, and the re-proof check is used to indicate that the target form is submitted repeatedly; and if not, indicating that the anti-duplication verification of the target form is passed, and indicating that the target form is not repeatedly submitted to verify whether the form submission request of the target form is effective in anti-duplication.
Further, a method for submitting a form of a server provided by an embodiment of the present application further includes:
presetting anti-reconfiguration information, wherein the anti-reconfiguration information comprises at least one preset form and a first anti-reconfiguration time length threshold corresponding to each easily preset form;
wherein, the querying and obtaining the target anti-duplication duration threshold corresponding to the target form comprises:
inquiring whether a first anti-repeating time length threshold corresponding to the target form exists in the anti-reconfiguring information,
if the target form exists, determining a first anti-duplication time length threshold corresponding to the target form in the anti-reconfiguration information as the target anti-duplication time length threshold;
and if the target anti-duplication time length does not exist, determining a preset second anti-duplication time length threshold as the target anti-duplication time length threshold, wherein the second anti-duplication time length threshold is suitable for any form.
For example, anti-reconfiguration information is preset, and includes a first anti-duplication duration threshold corresponding to each form in one or more preset forms, when inquiring effective anti-duplication duration, first, whether a first anti-duplication duration threshold corresponding to the target form exists in the anti-reconfiguration information is inquired, and if yes, the first anti-duplication duration threshold corresponding to the target form in the anti-reconfiguration information is determined as the target anti-duplication duration threshold; and if the target form does not exist, determining the second anti-duplication time length threshold which is set by default by the system as the target anti-duplication time length threshold, and searching and determining the anti-duplication effective time length of the target form.
According to another aspect of the present application, there is also provided a non-volatile storage medium having computer readable instructions stored thereon, which, when executed by a processor, cause the processor to implement the form submission method as described above.
According to another aspect of the present application, there is also provided a server for form submission, wherein the server includes:
one or more processors;
a computer-readable medium for storing one or more computer-readable instructions,
when executed by the one or more processors, cause the one or more processors to implement the server-side form submission method described above.
Here, the details of each embodiment in the server for submitting the form may specifically refer to the corresponding part of the embodiment of the server form submitting method, and are not described herein again.
According to another aspect of the present application, there is also provided a client for form submission, wherein the client includes:
one or more processors;
a computer-readable medium for storing one or more computer-readable instructions,
when executed by the one or more processors, cause the one or more processors to implement a client form submission method as described above.
Here, the details of each embodiment in the client for form submission may specifically refer to the corresponding part of the embodiment of the client form submission method, and are not described herein again
In summary, the client side sends a repeat prevention request to the server side in response to the target form being opened, where the repeat prevention request includes an identifier of the target form and an opening time; a duplicate prevention component is created in a server, the duplicate prevention component generates duplicate prevention information for the target form, the opening time and the duplicate prevention information of the target form are stored, and the server returns the duplicate prevention information of the target form to the client; the client receives the anti-duplication information of the target form returned by the server, acquires the service data of the target form, and sends a form submission request to the server, wherein the form submission request comprises the service data, the anti-duplication information and submission time; and the server checks whether the target form is repeatedly submitted or not based on the anti-duplication information, the opening time and the submitting time, and if not, the server processes the business data and returns the business processing result of the target form to the client so that the client receives the business processing result of the target form returned by the server. The anti-duplication component is created by taking out the anti-duplication part for the form from the service, and the anti-duplication component is packaged into the independently deployed component system, so that a simple and easy-to-use access mode is provided, no service code is invaded, and the high-multiplexing and stable and safe anti-duplication service is provided.
It should be noted that the present application may be implemented in software and/or a combination of software and hardware, for example, implemented using Application Specific Integrated Circuits (ASICs), general purpose computers or any other similar hardware devices. In one embodiment, the software programs of the present application may be executed by a processor to implement the steps or functions described above. Likewise, the software programs (including associated data structures) of the present application may be stored in a computer readable recording medium, such as RAM memory, magnetic or optical drive or diskette and the like. Additionally, some of the steps or functions of the present application may be implemented in hardware, for example, as circuitry that cooperates with the processor to perform various steps or functions.
In addition, some of the present application may be implemented as a computer program product, such as computer program instructions, which when executed by a computer, may invoke or provide methods and/or techniques in accordance with the present application through the operation of the computer. Program instructions which invoke the methods of the present application may be stored on a fixed or removable recording medium and/or transmitted via a data stream on a broadcast or other signal-bearing medium and/or stored within a working memory of a computer device operating in accordance with the program instructions. An embodiment according to the present application comprises an apparatus comprising a memory for storing computer program instructions and a processor for executing the program instructions, wherein the computer program instructions, when executed by the processor, trigger the apparatus to perform a method and/or a solution according to the aforementioned embodiments of the present application.
It will be evident to those skilled in the art that the present application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the apparatus claims may also be implemented by one unit or means in software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.