Front-end display (IDEA) of Java User data integrity and java User Data
Collation
People who frequently access the Internet will be familiar with this topic today. What should I do? user information is some personal information that must be filled out by the registrant when we register a website, the personal information is encrypted and stored on different servers. So what is completeness? Obviously, completeness refers to the entries listed on the website and the contrast of the entries entered by the registrant. The number of entries entered by the user and the number of items not filled (only valid data here ). This completeness allows users to see at a glance and improve their user information.
Background
Let's briefly explain the background. In recent days, the company's design department has raised several new requirements. Of course, this is one of them (or else it will not be nonsense (* ^__^ *) hey ). At the beginning, the manager asked me to find out if there are any open-source components in this area, which can be used directly. After online research, I found that there are no ready-made open-source components, but there are many simple implementation ideas. This article briefly discusses these ideas, and the next article will introduce the detailed implementation.
Body
There are two solutions to the front-end display problem of user data integrity. The first solution is to request the backend server to find the information of a user and determine the information based on the query information, of course, you need to add the corresponding weight, which is set based on the company's needs and the specific weight of an attribute. Note that the sum of each attribute must be 100%. Otherwise, the completeness of user data is not true.
The second solution is to directly search the information you have filled in on the page without requesting the background server. Of course, this approach will be affected by some factors. For example, the user's main information is not all displayed on the page, or the page is loaded using a framework. The page to be displayed is not the same as the page to be searched, this situation is also restricted.
The two solutions are described in detail below.
Solution 1
First, you need to determine the search attributes and the weights corresponding to the attributes. Of course, this must be provided by the design department. Considering future changes, we can abstract them separately and put them in the configuration file. It is convenient to modify the weights in the future.
There are many solutions for front-end page display, depending on the company's requirements. Here I use the progress bar. The progress bar component of Bootstrap is not only convenient but also beautiful. Simply put, the background server is requested to calculate the data integrity of the logged-on user. For example, the calculated result is 50%, then return the 50% to the front-end Ajax function. The front-end Ajax function changes the display of the progress bar by setting the Div width and style.
After the front-end is finished, let's talk about the backend server. The backend server searches for the user information of the logged-on user. Of course, it may involve multiple tables and then queries the weights corresponding to the user information, and match it to calculate the matched weight value, and return the result to the front-end in Json format.
Solution 2
The second solution is actually very simple. It is to find the user information loaded to the page, read the weight of each information attribute, and calculate the completeness of the information, the progress bar is displayed by changing the Div width and style.
Obviously, this method is simple and does not need to request backend servers. However, this method has a lot of limitations, that is, if the page does not display all the information attributes, the Calculation of information integrity still requires the server. In addition, if the front-end uses a partial page loaded by the Framework, the page displaying user information and the page displaying information integrity are not in the same area, and thus the page cannot be searched, this is also a major limitation.
My Solutions
By comparing the above two solutions and the features of the existing system, I chose the first solution. I set the Attribute Weight flexibly and read the configuration file to obtain the weight. Then, the front end uses the progress bar component of Bootstrap.
Conclusion
Most of the time, we are all thinking about how to make it easier and how to save things. These seemingly easy-to-use components are actually a double-edged sword. Although we have used them, the functions have also been implemented, however, you still don't know how it works. You can only rely on components made by him. Therefore, when using these open-source components, we also need to ask how they are implemented. If it is me, how should I implement them.
Of course, if there are no ready-made components, we have to write them by ourselves. In fact, this is also a good thing. Although it is troublesome to some extent, we have understood the principle, it's much simpler.
All right, I 've talked a lot about it, and it's all dry. The next article is true...