A kind of front and back end separation method, device and terminal device
Technical field
The invention belongs to field of communication technology more particularly to a kind of front and back end separation methods, device and terminal device.
Background technique
Currently, web framework based on the front and back end vue and springboot separate using more and more extensive, in general, in order to drop
The coupling that front end is disposed in low rear end, people, which need to provide in front end, a kind of allows users to the public of flexible configuration page permissions
Method.
But in existing scheme, the operation for returning to the control of front end permission in real time by back-end code causes a large amount of networks
Expense causes system performance to reduce, and reduces the resource utilization of client.
Summary of the invention
In view of this, the embodiment of the invention provides a kind of front and back end separation method, device and terminal device, it is existing to solve
Have in technology and a large amount of network overheads are caused by the operation that back-end code returns to the control of front end permission in real time, leads to system performance
The problem of reducing, and reducing the resource utilization of client.
The first aspect of the embodiment of the present invention provides a kind of front and back end separation method, including:
The request of user's input is obtained, and judges whether the request is specific URL request;
If the request is not specific URL request, judge whether authority information meets preset condition;
If the authority information does not meet the preset condition, obtains and stepped on described in the log-on message of the user and verifying
Whether correct record information;
If the log-on message verifying is correct, the default access and caching of user are obtained.
Optionally, if the request is not that specific URL request is also wrapped after whether authority information meets preset condition
It includes:
If the authority information meets the preset condition, the solicited message of user is obtained;
Obtain data corresponding with the solicited message of the user.
Optionally, the request for obtaining user's input, and after judging whether the request is specific URL request, also
Including:
If the request is specific URL request, checking request is sent to the rear end;
It receives checking request that the rear end is sent and passes through information and data corresponding with the specific URL request.
Optionally, if the request is specific URL request, after sending checking request to the rear end, further include:
If receiving the exception information that the rear end is sent, abnormal prompt information is shown to the user.
The second aspect of the embodiment of the present invention provides a kind of front and back end separator, including:
First obtains module, for obtaining the request of user's input, and judges whether the request is specific URL request;
It is default to judge whether authority information meets if not being specific URL request for the request for first judgment module
Condition;
Login module obtains the login letter of the user if not meeting the preset condition for the authority information
It ceases and whether verify the log-on message correct;
Second obtains module, if correct for log-on message verifying, obtains the default access and caching of user.
The third aspect of the embodiment of the present invention provides a kind of terminal device, including:It memory, processor and is stored in
In the memory and the computer program that can run on the processor, when the processor executes the computer program
It realizes such as the step of the above method.
The fourth aspect of the embodiment of the present invention provides a kind of computer readable storage medium, the computer-readable storage
Media storage has computer program, realizes when the computer program is executed by processor such as the step of the above method.
The embodiment of the present invention passes through the type for judging the request of user, and further judges whether the authority information of user accords with
Preset condition is closed, the corresponding correlative weight of User ID can be obtained from backstage when login passes through obtaining user login information and verifying
Front end is limited and be buffered in, when enabling to user is subsequent to need to obtain the corresponding data of permission, is obtained without repeating to send to backstage
Request is taken, the corresponding data of permission can be directly obtained.
Detailed description of the invention
It to describe the technical solutions in the embodiments of the present invention more clearly, below will be to embodiment or description of the prior art
Needed in attached drawing be briefly described, it should be apparent that, the accompanying drawings in the following description is only of the invention some
Embodiment for those of ordinary skill in the art without any creative labor, can also be according to these
Attached drawing obtains other attached drawings.
Fig. 1 is the flow diagram for the front and back end separation method that the embodiment of the present invention one provides;
Fig. 2 is the flow diagram of front and back end separation method provided by Embodiment 2 of the present invention;
Fig. 3 is the structural schematic diagram for the front and back end separator that the embodiment of the present invention three provides;
Fig. 4 is the structural schematic diagram for the front and back end separator that the embodiment of the present invention four provides;
Fig. 5 is the schematic diagram for the terminal device that the embodiment of the present invention five provides.
Specific embodiment
In order to enable those skilled in the art to better understand the solution of the present invention, below in conjunction in the embodiment of the present invention
Attached drawing, technical solution in the embodiment of the present invention are explicitly described, it is clear that described embodiment is the present invention one
The embodiment divided, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art are not doing
Every other embodiment obtained under the premise of creative work out, should fall within the scope of the present invention.
Description and claims of this specification and term " includes " and their any deformations in above-mentioned attached drawing, meaning
Figure, which is to cover, non-exclusive includes.Such as process, method or system comprising a series of steps or units, product or equipment do not have
It is defined in listed step or unit, but optionally further comprising the step of not listing or unit, or optionally also wrap
Include the other step or units intrinsic for these process, methods, product or equipment.In addition, term " first ", " second " and
" third " etc. is for distinguishing different objects, not for description particular order.
In order to illustrate technical solutions according to the invention, the following is a description of specific embodiments.
Embodiment one
As shown in Figure 1, this method can be applied to such as PC, mobile phone the present embodiment provides a kind of front and back end separation method
Terminal device.Front and back end separation method provided by the present embodiment, including:
S101, the request for obtaining user's input, and judge whether the request is specific URL request.
In a particular application, the front end based on VUE obtains the request of user's input, and front controller judges user's input
Request is specific URL request, to determine a need for obtaining the associated rights of user from rear end.
If S102, the request are not specific URL requests, judge whether authority information meets preset condition.
In a particular application, if the request of user's input is not specific URL request, need to detect ID pairs of active user
Whether the authority information answered legal and not out of date (judges the corresponding authority information of User ID when current at current time
Carve and whether meet preset condition), to determine whether user needs to reacquire authority information.It should be noted that can basis
Actual conditions set preset condition.Such as, setting preset condition may include other for judging the corresponding permission of active user ID
The whether effective condition of information, is not construed as limiting this.
If S103, the authority information do not meet the preset condition, the log-on message of the user and verifying are obtained
Whether the log-on message is correct.
In a particular application, if the corresponding authority information of current time User ID is expired or active user ID
Corresponding authority information is illegal, then needs to jump login page, obtains the log-on message of the user and verifies the user
Whether the log-on message of input is correct, judges that user's success logs in.
If the verifying of S104, the log-on message is correct, the default access and caching of user are obtained.
In a particular application, if the log-on message of user's input is by verifying, according to the log-on message of user from rear end
The corresponding associated rights of User ID are obtained, and presets the corresponding data of associated rights that will be obtained from rear end and is cached by JS
Into cookie.When the corresponding data acquisition request of subsequently received user input associated rights, data relevant to permission
It can directly be obtained from above-mentioned cookie, avoid repeating to send data acquisition request to the back-end.Wherein, the corresponding correlation of User ID
Permission control can carry out dynamic configuration according to the actual situation, including but not limited to:Permission, menu setting power is arranged in user role
Permission is arranged in limit, function setting permission, data setting permission and specific request.
In one embodiment, after the step S101, further include:
If the request is specific URL request, checking request is sent to the rear end;
It receives checking request that the rear end is sent and passes through information and data corresponding with the specific URL request.
In a particular application, if the request of user's input is specific URL request, related active user ID is sent to the back-end
The whether legal verification information of corresponding permission, if Back End Authentication passes through, the corresponding permission of active user ID can be legal
The corresponding data of above-mentioned specific URL request are obtained, at this point, can receive the corresponding data of specific URL request sent to rear end.
In one embodiment, if the request is specific URL request, after sending checking request to the rear end,
Further include:
If receiving the exception information that the rear end is sent, abnormal prompt information is shown to the user.
In a particular application, if receiving the exception information of rear end transmission, illustrate that Back End Authentication result is active user
The corresponding permission of ID is simultaneously illegal, and front end need to show the corresponding illegal abnormal prompt information of permission of User ID to user, just
It is further operated in user.
The present embodiment passes through the type for judging the request of user, and it is pre- further to judge whether the authority information of user meets
If condition, the corresponding associated rights of User ID can be obtained simultaneously from backstage when login passes through obtaining user login information and verifying
It is buffered in front end, when enabling to user is subsequent to need to obtain the corresponding data of permission, is asked without repeating to send to obtain to backstage
It asks, the corresponding data of permission can be directly obtained.
Embodiment two
As shown in Fig. 2, the present embodiment is the further explanation to the method and step in embodiment one.In the present embodiment,
Further include after step S102:
If S1021, the authority information meet the preset condition, the solicited message of user is obtained.
In a particular application, it if the corresponding authority information of current time User ID meets preset condition, is obtained from rear end
The corresponding associated rights data of User ID has been buffered in front end, obtains the data of the related solicited message of user.
S1022, data corresponding with the solicited message of the user are obtained.
In a particular application, the solicited message according to user in relation to data obtains corresponding data from front end, in this implementation
In example, data related with User ID corresponding authority are cached by JS to the end cookie, are sent data acquisition without rear end and are asked
It asks.
The present embodiment is by judging whether the corresponding authority information of User ID meets preset condition, whether to judge user
It ensure that the restriction to user right and the safety of data by then obtaining from rear end with the corresponding data of authority acquiring.
It should be understood that the size of the serial number of each step is not meant that the order of the execution order in above-described embodiment, each process
Execution sequence should be determined by its function and internal logic, the implementation process without coping with the embodiment of the present invention constitutes any limit
It is fixed.
Embodiment three
As shown in figure 3, the present embodiment provides a kind of front and back end separators 100, for executing the method in embodiment one
Step.Front and back end separator 100 provided in this embodiment, including:
First obtains module 101, for obtaining the request of user's input, and judges whether the request is that specific URL is asked
It asks;
First judgment module 102 judges whether authority information meets if not being specific URL request for the request
Preset condition;
Login module 103 obtains the login of the user if not meeting the preset condition for the authority information
Information and whether verify the log-on message correct;
Second obtains module 104, if correct for log-on message verifying, obtain the default access of user and delays
It deposits.
In one embodiment, described device 100 further include:
Authentication module sends checking request to the rear end if being specific URL request for the request;
First receiving module is asked for receiving checking request that the rear end is sent by information and with the specific URL
Seek corresponding data.
In one embodiment, described device 100 further include:
Second receiving module is shown abnormal if the exception information sent for receiving the rear end to the user
Prompt information.
The present embodiment passes through the type for judging the request of user, and it is pre- further to judge whether the authority information of user meets
If condition, the corresponding associated rights of User ID can be obtained simultaneously from backstage when login passes through obtaining user login information and verifying
It is buffered in front end, when enabling to user is subsequent to need to obtain the corresponding data of permission, is asked without repeating to send to obtain to backstage
It asks, the corresponding data of permission can be directly obtained.
Example IV
As shown in figure 4, in the present embodiment, the front and back end separator 100 in example IV, further includes for executing reality
Apply method and step in example two with flowering structure:
Third obtains module 1021 and obtains the request of user if meeting the preset condition for the authority information
Information;
4th obtains module 1022, for obtaining data corresponding with the solicited message of the user.
The present embodiment is by judging whether the corresponding authority information of User ID meets preset condition, whether to judge user
It ensure that the restriction to user right and the safety of data by then obtaining from rear end with the corresponding data of authority acquiring.
Embodiment five
Fig. 5 is the schematic diagram for the terminal device that one embodiment of the invention provides.As shown in figure 5, the terminal of the embodiment is set
Standby 5 include:Processor 50, memory 51 and it is stored in the meter that can be run in the memory 51 and on the processor 50
Calculation machine program 52, such as front and back end separate program.The processor 50 is realized above-mentioned each when executing the computer program 52
Step in the separation method embodiment of front and back end, such as step S101 to S104 shown in FIG. 1.Alternatively, the processor 50 is held
The function of each module/unit in above-mentioned each Installation practice, such as module shown in Fig. 3 are realized when the row computer program 52
101 to 104 function.
Illustratively, the computer program 52 can be divided into one or more module/units, it is one or
Multiple module/units are stored in the memory 51, and are executed by the processor 50, to complete the present invention.Described one
A or multiple module/units can be the series of computation machine program instruction section that can complete specific function, which is used for
Implementation procedure of the computer program 52 in the terminal device 5 is described.For example, the computer program 52 can be divided
It is cut into the first acquisition module, first judgment module, login module and second and obtains module, each module concrete function is as follows:
First obtains module, for obtaining the request of user's input, and judges whether the request is specific URL request;
It is default to judge whether authority information meets if not being specific URL request for the request for first judgment module
Condition;
Login module obtains the login letter of the user if not meeting the preset condition for the authority information
It ceases and whether verify the log-on message correct;
Second obtains module, if correct for log-on message verifying, obtains the default access and caching of user.
The terminal device 5 can be the calculating such as desktop PC, notebook, palm PC and cloud server and set
It is standby.The terminal device may include, but be not limited only to, processor 50, memory 51.It will be understood by those skilled in the art that Fig. 5
The only example of terminal device 5 does not constitute the restriction to terminal device 5, may include than illustrating more or fewer portions
Part perhaps combines certain components or different components, such as the terminal device can also include input-output equipment, net
Network access device, bus etc..
Alleged processor 50 can be central processing unit (Central Processing Unit, CPU), can also be
Other general processors, digital signal processor (Digital Signal Processor, DSP), specific integrated circuit
(Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field-
Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or transistor logic,
Discrete hardware components etc..General processor can be microprocessor or the processor is also possible to any conventional processor
Deng.
The memory 51 can be the internal storage unit of the terminal device 5, such as the hard disk or interior of terminal device 5
It deposits.The memory 51 is also possible to the External memory equipment of the terminal device 5, such as be equipped on the terminal device 5
Plug-in type hard disk, intelligent memory card (Smart Media Card, SMC), safe digital card (Secure Digital, SD) dodge
Deposit card (Flash Card) etc..Further, the memory 51 can also both include the storage inside list of the terminal device 5
Member also includes External memory equipment.The memory 51 is for storing needed for the computer program and the terminal device
Other programs and data.The memory 51 can be also used for temporarily storing the data that has exported or will export.
It is apparent to those skilled in the art that for convenience of description and succinctly, only with above-mentioned each function
Can unit, module division progress for example, in practical application, can according to need and by above-mentioned function distribution by different
Functional unit, module are completed, i.e., the internal structure of described device is divided into different functional unit or module, more than completing
The all or part of function of description.Each functional unit in embodiment, module can integrate in one processing unit, can also
To be that each unit physically exists alone, can also be integrated in one unit with two or more units, it is above-mentioned integrated
Unit both can take the form of hardware realization, can also realize in the form of software functional units.In addition, each function list
Member, the specific name of module are also only for convenience of distinguishing each other, the protection scope being not intended to limit this application.Above system
The specific work process of middle unit, module, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In the above-described embodiments, it all emphasizes particularly on different fields to the description of each embodiment, is not described in detail or remembers in some embodiment
The part of load may refer to the associated description of other embodiments.
Those of ordinary skill in the art may be aware that list described in conjunction with the examples disclosed in the embodiments of the present disclosure
Member and algorithm steps can be realized with the combination of electronic hardware or computer software and electronic hardware.These functions are actually
It is implemented in hardware or software, the specific application and design constraint depending on technical solution.Professional technician
Each specific application can be used different methods to achieve the described function, but this realization is it is not considered that exceed
The scope of the present invention.
In embodiment provided by the present invention, it should be understood that disclosed device/terminal device and method, it can be with
It realizes by another way.For example, device described above/terminal device embodiment is only schematical, for example, institute
The division of module or unit is stated, only a kind of logical function partition, there may be another division manner in actual implementation, such as
Multiple units or components can be combined or can be integrated into another system, or some features can be ignored or not executed.Separately
A bit, shown or discussed mutual coupling or direct-coupling or communication connection can be through some interfaces, device
Or the INDIRECT COUPLING or communication connection of unit, it can be electrical property, mechanical or other forms.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit
The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple
In network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme
's.
It, can also be in addition, the functional units in various embodiments of the present invention may be integrated into one processing unit
It is that each unit physically exists alone, can also be integrated in one unit with two or more units.Above-mentioned integrated list
Member both can take the form of hardware realization, can also realize in the form of software functional units.
If the integrated module/unit be realized in the form of SFU software functional unit and as independent product sale or
In use, can store in a computer readable storage medium.Based on this understanding, the present invention realizes above-mentioned implementation
All or part of the process in example method, can also instruct relevant hardware to complete, the meter by computer program
Calculation machine program can be stored in a computer readable storage medium, the computer program when being executed by processor, it can be achieved that on
The step of stating each embodiment of the method.Wherein, the computer program includes computer program code, the computer program generation
Code can be source code form, object identification code form, executable file or certain intermediate forms etc..The computer-readable medium
May include:Any entity or device, recording medium, USB flash disk, mobile hard disk, magnetic of the computer program code can be carried
Dish, CD, computer storage, read-only memory (ROM, Read-Only Memory), random access memory (RAM,
Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium etc..It should be noted that described
The content that computer-readable medium includes can carry out increasing appropriate according to the requirement made laws in jurisdiction with patent practice
Subtract, such as does not include electric carrier signal and electricity according to legislation and patent practice, computer-readable medium in certain jurisdictions
Believe signal.
Embodiment described above is merely illustrative of the technical solution of the present invention, rather than its limitations;Although referring to aforementioned reality
Applying example, invention is explained in detail, those skilled in the art should understand that:It still can be to aforementioned each
Technical solution documented by embodiment is modified or equivalent replacement of some of the technical features;And these are modified
Or replacement, the spirit and scope for technical solution of various embodiments of the present invention that it does not separate the essence of the corresponding technical solution should all
It is included within protection scope of the present invention.