Previously, the access permission was obtained. The user logs in and determines the identity of the user. Based on the identity permission, the corresponding content is displayed. However, there is a drawback that the permission is written to death.Program. This is certainly not desirable for systems with high flexibility. Therefore, we need to change the permission control to compile for runtime.
Let's talk about theme. The following figure shows the table structure logic that implements this permission management function. Group system users, organize functions, and match the group with the function. As long as the user belongs to the group, the user can access the interface corresponding to the group. Strictly speaking, this permission management is also a page access control permission management.
Insert test data to the database table as follows:Create three views for the five tables according to the actual situation. The v_group_url view can be used to query all webpages that a user group can view (that is, webpages with access permissions ).
The v_user_group view can be used to view which user groups the user belongs. V_user_url: combines two views to display pages accessible to a user.In this way, you can use the v_user_url view to determine which interfaces the user has access permissions. In this way, we can manage the permissions of these tables. In fact, in the final analysis, we only separated users from functions, decoupled them, and established associations between user groups and functions to control users' access to this page.