Permission tree state display method and device
By creating the data structure and cache mechanism of the permission tree in the permission management system, the problem of incorrect display of permission status under permission sloth loading is solved, and the permission status is accurate and timely updated, improving the user experience.
Patent Information
- Application Number
- CN202510437538.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-09
- Publication Date
- 2025-05-09
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the permission management system, when the permission tree is displayed in a lazy loading mode, the administrator's update of the permission tree's lower-level permissions cannot be promptly reflected in the status display of the parent node, resulting in the incorrect display of the permission status and reducing the user experience.
By creating a data structure of the permission tree, including permission tree nodes, role permission relationships and cache structures, iterates through the child nodes of the permission tree parent node and user permission nodes, updates the intermediate result cache items, and calculates the status of the permission tree parent node according to the preset state calculation rules.
It improves the efficiency and reliability of the permission tree state display, ensures the accuracy and timely update of the permission state, and improves the user experience.
Smart Images

Figure CN119961958A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a method and device for displaying the status of a permission tree. Background Art
[0002] In the permission management system, permission tree is a common way to organize and manage permissions. The permission tree shows the hierarchical relationship between different permissions in a tree structure, which makes it easier for administrators to manage and allocate permissions in a unified manner. However, in actual applications, the permission tree system often faces some technical challenges.
[0003] When an administrator adds or deletes sub-permissions under the permission tree, if the permission tree is displayed in a lazy loading manner, that is, the sub-permission information of the node is loaded only when the user expands the node, then the permission status may be displayed incorrectly. Specifically, when all permissions under a role's permission tree are selected and the permission tree is in a lazy loading state, the permission tree displayed on the page is in a fully selected state, which is correct in itself. However, when the administrator adds a subordinate permission under the permission tree, the permission tree has not yet loaded the newly added permission node, so the role user still sees the fully selected state. However, when the user expands the node, the system immediately loads the newly added permission node, causing the node to change from a fully selected state to a half-selected state. This change in permission status can confuse users and reduce the user experience of the system.
[0004] Based on the above problems, a permission tree status display method is urgently needed to solve the problem of incorrect permission status display when the permission tree is lazy loaded, and improve the efficiency and reliability of permission tree status display. Summary of the invention
[0005] In response to the problems in the prior art, the present application provides a permission tree status display method and device, which can improve the efficiency and reliability of permission tree status display.
[0006] In order to solve at least one of the above problems, the present application provides the following technical solutions: In a first aspect, the present application provides a method for displaying the status of a permission tree, comprising: Creating a permission tree according to a preset data structure, wherein the data structure includes permission tree nodes, role permission relationships, and a cache structure, wherein the role permission relationship is used to represent the relationship between user roles and node permissions, and the cache structure includes a timestamp for recording the last update time of the cache item; Perform a child node traversal operation on the parent node in the permission tree node to determine the total number of corresponding child nodes, perform a user permission node traversal operation according to the parent node in the permission tree node and the user unique identifier in the role permission relationship to determine the total number of corresponding permission nodes, and perform an update operation on the cache structure of the parent node according to the total number of child nodes and the total number of permission nodes to determine the corresponding intermediate result cache item, wherein the intermediate result cache item includes the total number of child nodes, the total number of permission nodes, and a cache timestamp; Receive an administrator's update operation on a permission node of the permission tree, determine a corresponding updated permission node, perform an update operation on the intermediate result cache item according to the updated permission node, determine a corresponding updated intermediate result cache item, perform a state calculation operation on the updated intermediate result cache item according to a preset state calculation rule, and determine a corresponding permission tree parent node state, wherein the permission tree parent node state is fully selected, half selected, and unselected.
[0007] Further, the receiving an administrator's update operation on a permission node of the permission tree, determining a corresponding update permission node, performing an update operation on the intermediate result cache item according to the update permission node, and determining a corresponding updated intermediate result cache item, comprises: Receive an administrator's operation of adding a sub-authority node to the authority tree, and determine the corresponding number of incremental sub-authority nodes; An operation of adding the total number of child nodes and the total number of authority nodes is performed according to the number of incremental child authority nodes, and the cache timestamp is updated according to a time corresponding to the addition to determine an updated total number of child nodes, an updated total number of authority nodes, and an updated cache timestamp.
[0008] Further, the receiving an administrator's update operation on a permission node of the permission tree, determining a corresponding update permission node, performing an update operation on the intermediate result cache item according to the update permission node, and determining a corresponding updated intermediate result cache item, further includes: Receive an administrator's operation of deleting a sub-authority node of the authority tree, and determine the corresponding number of sub-authority nodes to be reduced; A number reduction operation is performed on the total number of child nodes and the total number of authority nodes according to the reduced number of sub-authority nodes, and the cache timestamp is updated according to a time corresponding to the reduction to determine an updated total number of child nodes, an updated total number of authority nodes, and an updated cache timestamp.
[0009] Further, the receiving an administrator's update operation on a permission node of the permission tree, determining a corresponding update permission node, performing an update operation on the intermediate result cache item according to the update permission node, and determining a corresponding updated intermediate result cache item, further includes: Receive an administrator's operation of modifying the permission status of the permission tree, and determine the corresponding number of changed sub-permission nodes; The total number of child nodes and the total number of authority nodes are changed according to the changed number of child authority nodes, and the cache timestamp is updated according to the time corresponding to the change to determine the updated total number of child nodes, the updated total number of authority nodes and the updated cache timestamp.
[0010] Further, performing a state calculation operation on the updated intermediate result cache item according to a preset state calculation rule to determine the corresponding permission tree parent node state includes: Determine whether the total number of child nodes in the updated intermediate result cache item is equal to the total number of authority nodes in the updated intermediate result cache item; If they are equal, it is determined that the corresponding permission tree parent node state is fully selected.
[0011] Furthermore, performing a state calculation operation on the updated intermediate result cache item according to a preset state calculation rule to determine the corresponding permission tree parent node state also includes: Determine whether the total number of child nodes in the updated intermediate result cache item is greater than the total number of authority nodes in the updated intermediate result cache item; If it is greater, determine whether the total number of permission nodes in the updated intermediate result cache item is greater than zero. If it is greater, determine that the corresponding permission tree parent node state is half-selected. If it is equal to zero, determine that the corresponding permission tree parent node state is unselected.
[0012] Furthermore, it also includes: Receive a user's access request to the permission tree, and determine whether a cache timestamp in the updated intermediate result cache item exceeds a preset time threshold; If it does not exceed, a state calculation operation is performed on the updated intermediate result cache item according to a preset state calculation rule to determine the state of the corresponding parent node of the permission tree.
[0013] In a second aspect, the present application provides a permission tree status display device, comprising: A permission tree structure framework building module, used to create a permission tree according to a preset data structure, wherein the data structure includes permission tree nodes, role permission relationships, and a cache structure, wherein the role permission relationship is used to represent the relationship between user roles and node permissions, and the cache structure contains a timestamp for recording the last update time of the cache item; The permission tree intermediate result cache module is used to perform a child node traversal operation on the parent node in the permission tree node to determine the total number of corresponding child nodes, perform a user permission node traversal operation according to the parent node in the permission tree node and the user unique identifier in the role permission relationship to determine the total number of corresponding permission nodes, update the cache structure of the parent node according to the total number of child nodes and the total number of permission nodes, and determine the corresponding intermediate result cache item, wherein the intermediate result cache item includes the total number of child nodes, the total number of permission nodes and the cache timestamp; A permission tree status display module is used to receive an administrator's update operation on a permission node of the permission tree, determine a corresponding updated permission node, perform an update operation on the intermediate result cache item according to the updated permission node, determine a corresponding updated intermediate result cache item, perform a status calculation operation on the updated intermediate result cache item according to a preset status calculation rule, and determine a corresponding permission tree parent node status, wherein the permission tree parent node status is fully selected, half selected, and unselected.
[0014] In a third aspect, the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the permission tree status display method when executing the program.
[0015] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the permission tree status display method.
[0016] In a fifth aspect, the present application provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the permission tree status display method.
[0017] It can be seen from the above technical scheme that the present application provides a method and device for displaying the status of a permission tree, by creating a permission tree according to the permission tree nodes, role permission relationships and cache structures, traversing all child nodes in the parent node of the permission tree to obtain the total number of child nodes, traversing the permission nodes belonging to the user in the parent node of the permission tree under the user role to obtain the total number of permission nodes, caching the total number of child nodes, the total number of permission nodes and the timestamp when the node is updated to obtain an intermediate result cache item, updating the intermediate result cache item according to the administrator's update content of the permission node of the permission tree, performing status calculation on the updated intermediate result cache item according to a preset status calculation rule to obtain the status of the parent node of the permission tree, wherein the status of the parent node of the permission tree is fully selected, half selected and unselected, thereby improving the efficiency and reliability of the permission tree status display. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0019] Figure 1 This is one of the flowcharts of the permission tree status display method in the embodiment of the present application; Figure 2 This is the second flow chart of the permission tree status display method in the embodiment of the present application; Figure 3 This is the third flow chart of the permission tree status display method in the embodiment of the present application; Figure 4 This is a fourth flow chart of the permission tree status display method in an embodiment of the present application; Figure 5 This is a fifth flow chart of the permission tree status display method in the embodiment of the present application; Figure 6 This is the sixth flow chart of the permission tree status display method in the embodiment of the present application; Figure 7 This is the seventh flow chart of the permission tree status display method in the embodiment of the present application; Figure 8 This is a structural diagram of a permission tree status display device in an embodiment of the present application; Fig. 9 It is a schematic diagram of the structure of an electronic device in an embodiment of the present application.
[0020] Reference numerals: Electronic device 9600, central processing unit 9100, memory 9140, communication module 9110, input unit 9120, audio processor 9130, display 9160, power supply 9170, buffer memory 9141, application / function storage unit 9142, data storage unit 9143, driver program storage unit 9144, antenna 9111, speaker 9131, microphone 9132. DETAILED DESCRIPTION
[0021] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0022] The acquisition, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.
[0023] Considering that when the existing permission tree uses lazy loading to display information, the administrator's update of the lower-level permissions of the permission tree cannot be reflected in the status display of the parent node, resulting in display errors and reducing the user experience. The present application provides a permission tree status display method and device, which creates a permission tree according to the permission tree node, role permission relationship and cache structure, traverses all child nodes in the parent node of the permission tree to obtain the total number of child nodes, traverses the user's permission nodes in the parent node of the permission tree under the user role, obtains the total number of permission nodes, caches the total number of child nodes, the total number of permission nodes and the timestamp when the node is updated, obtains the intermediate result cache item, updates the intermediate result cache item according to the administrator's permission node update content of the permission tree, and performs status calculation on the updated intermediate result cache item according to the preset status calculation rule to obtain the permission tree parent node status, wherein the permission tree parent node status is fully selected, half selected and unselected, thereby improving the efficiency and reliability of the permission tree status display.
[0024] In order to improve the efficiency and reliability of permission tree status display, the present application provides an embodiment of a permission tree status display method, see Figure 1 , the permission tree status display method specifically includes the following contents: Step S101: creating a permission tree according to a preset data structure, wherein the data structure includes permission tree nodes, role permission relationships, and a cache structure, wherein the role permission relationship is used to represent the relationship between user roles and node permissions, and the cache structure includes a timestamp for recording the last update time of the cache item; Optionally, in this embodiment, when all permissions under a role are selected and the permission tree is lazily loaded, the permission tree displayed on the page is in a fully selected state, and the status display is correct. However, when the administrator adds a subordinate permission under the permission tree and the permission tree is lazily loaded, the phenomenon seen by this role is that the permissions of this node are fully selected, but after expanding this node, this node immediately becomes half-selected. Therefore, this confusing phenomenon occurs. In order to solve this problem and enable the role user to see the correct state of this permission node without perception, this application combines the event-driven architecture and state calculation logic, introduces an intermediate result caching mechanism, and implements an algorithm for automatically refreshing the selected state of the node.
[0025] Optionally, first, create a permission tree data structure that includes permission tree nodes, role permission relationships, and cache structures. The permission tree nodes are used to store the hierarchical relationship information of permission nodes; the role permission relationships are used to store the association information between user roles and node permissions; and the cache structure includes a timestamp field to record the last update time of the cache item.
[0026] Specifically, the permission tree node structure: class PermissionNode { String nodeId; / / Node ID String parentId; / / Parent node ID List <string>children; / / child node ID list boolean isSelected; / / Is it selected (full / partial)} The node structure reflects the permission tree Specifically, the role permission relationship structure is: class RolePermission { String roleId; / / role ID String nodeId; / / Node ID boolean isSelected; / / Is it selected?} Specifically, the cache structure: class CacheItem { String nodeId; / / Node ID int totalChildren; / / Total number of child nodes int selectedChildren; / / The number of child node permissions that the role has long timestamp; / / Last updated timestamp} Secondly, after building the data structure of the permission tree, define three events: "AddSubPermission", "RemoveSubPermission", and "UpdatePermissionStatus", and set event capture points in the backend service of the permission tree. When the API for adding subpermissions is called, the "AddSubPermission" event is triggered; when the API for deleting subpermissions is called, the "DeleteSubPermission" event is triggered; when the API for modifying permission status is called, the "ModifyPermissionStatus" event is triggered.
[0027] Finally, create an event handler EventHandler, which contains three methods: handleAddSubPermission; handleRemoveSubPermission; handleUpdatePermissionStatus; Each method contains corresponding processing logic, which is used to handle events after listening to corresponding events. In the event handler, a permission tree state calculation algorithm is implemented, which determines the full or half selected state of the node based on the number of sub-permissions of the node and the number of permissions owned by the role.
[0028] It can be understood that this step constructs and defines a permission tree structure, laying a solid foundation for the implementation of subsequent algorithms.
[0029] Step S102: performing a child node traversal operation on the parent node in the permission tree node to determine the total number of corresponding child nodes, performing a user permission node traversal operation according to the parent node in the permission tree node and the user unique identifier in the role permission relationship to determine the total number of corresponding permission nodes, and updating the cache structure of the parent node according to the total number of child nodes and the total number of permission nodes to determine the corresponding intermediate result cache item, wherein the intermediate result cache item includes the total number of child nodes, the total number of permission nodes and a cache timestamp; Optionally, in the present embodiment, this step is the implementation process of the cache mechanism. First, the permission tree state is initialized, and the initial intermediate result cache item is obtained and stored in the cache structure. Later, when the administrator modifies the permission state or the user access permission tree, the correct node display state can be obtained directly by accessing the cache structure. At the same time, introducing a timestamp control mechanism in the cache mechanism can effectively improve computing efficiency, reduce system overhead, and improve user experience.
[0030] Specifically, the initial intermediate result cache item includes the total number of child nodes, the total number of permission nodes and the cache timestamp, wherein the total number of child nodes is obtained by traversing the number of all subordinate nodes contained under a parent node, and the total number of permission nodes is obtained by traversing the number of permission nodes contained in the user role under the parent node.
[0031] The cache timestamp is a key field in the intermediate result cache item, which records the last update time of the cache item, ensuring that the system uses the latest data when performing state calculations. Through the timestamp, the system can determine whether the cache item is expired and avoid using expired data for state calculations. At the same time, when the permission tree is dynamically updated, the cache timestamp can help the system identify which cache items need to be updated, ensuring that the cache data is consistent with the actual data in the database. By comparing the timestamp, the system can avoid repeatedly updating the latest cache items and reduce unnecessary computing overhead.
[0032] For example, suppose there is a permission tree structure as follows: Node A (parent node) Node B (child node) - user role authorization Node C (child node) - user role authorization Node D (child node) Embodiment 1: In the initial state, assuming that the cache timestamp is T1, when the user accesses, if the difference between the current time and the cache timestamp T1 is within the validity period, the system directly uses the cache item for state calculation. If the cache timestamp expires, the system re-traverses the permission tree and updates the cache item to ensure data timeliness.
[0033] Embodiment 2: In the initial state, assuming that the cache timestamp is T2, when the administrator updates the middle cache node of the permission tree, if the difference between the current time and the cache timestamp T2 is within the validity period, since the cache timestamp is the latest, the system directly uses the cache item to calculate the state of node A to support data consistency.
[0034] It is understandable that the cache timestamp ensures the timeliness and consistency of data in the permission tree state management by recording the last update time of the cache item. At the same time, by comparing the timestamp, unnecessary database queries and calculation operations are reduced, improving the performance of the system. On the other hand, in lazy loading mode, the cache timestamp helps the system determine which cache items need to be recalculated to ensure the accuracy of the permission tree state.
[0035] The design of introducing cache timestamp makes the state management of permission tree more efficient and accurate, especially in dynamic update and lazy loading mode, which can significantly improve the system response speed and user experience.
[0036] Step S103: Receive the administrator's update operation on the permission node of the permission tree, determine the corresponding updated permission node, perform an update operation on the intermediate result cache item according to the updated permission node, determine the corresponding updated intermediate result cache item, perform a state calculation operation on the updated intermediate result cache item according to a preset state calculation rule, and determine the corresponding permission tree parent node state, wherein the permission tree parent node state is fully selected, half selected, and unselected.
[0037] Optionally, in this embodiment, this step is a process of processing permission update and permission tree state calculation, which specifically involves the implementation process of the permission tree state calculation algorithm mentioned in step S101.
[0038] Specifically, the administrator's updates to the permission nodes of the permission tree include "adding sub-permissions", "deleting sub-permissions" and "modifying permission status".
[0039] Specifically, the cache update strategies include: When adding a child permission, update the subCount (number of child nodes) cache of the parent node; if the role has the newly added permission, update the roleCount cache (number of permission nodes) cache of the parent node (roleCount += 1).
[0040] When deleting a child permission, update the subCount cache of the parent node (subCount -= 1); if the role has the deleted permission, update the roleCount cache of the parent node.
[0041] When modifying the permission status, update the roleCount cache of the relevant node. For example, if the permission changes from "unchecked" to "checked", roleCount += 1; if the permission changes from "checked" to "unchecked", roleCount -= 1.
[0042] When the child nodes or role permissions of a node change, the relevant cache items are immediately invalidated.
[0043] For example, when adding or removing a child permission, invalidate the parent node's subCount and roleCount caches.
[0044] Use distributed locks (such as Redis's SETNX) to ensure the consistency of cache updates. When updating the cache, first acquire the lock, then release the lock after updating the cache to avoid data inconsistency caused by concurrent updates. At the same time, when the status of multiple nodes changes, use batch cache updates to reduce the number of cache operations. For example, merge the subCount and roleCount update requests of multiple nodes into one batch operation.
[0045] It is understandable that the introduction of a caching mechanism can significantly improve computing efficiency, especially in large-scale permission trees or high-concurrency scenarios. By caching intermediate results (the number of child nodes of each node and the number of permissions a role has under the node), repeated calculations can be reduced and the state update process can be optimized.
[0046] Specifically, the status calculation rules include obtaining the number of child nodes and the number of authority nodes from the cache: First, get the number of child nodes (subCount) of the current node from the cache; if it does not exist in the cache, query and update the cache from the database.
[0047] Then, the number of permissions that the role has under the current node (roleCount) is obtained from the cache; if it does not exist in the cache, the cache is queried from the database and updated.
[0048] Calculate the full or half selected state of a node based on subCount and roleCount: If roleCount == subCount, the node status is all selected.
[0049] If 0 < roleCount < subCount, the node status is half-selected.
[0050] If roleCount == 0, the node status is unselected.
[0051] Finally, recursively update the status of the parent node until the root node. When updating the parent node, subCount and roleCount are also obtained from the cache first to avoid repeated calculations.
[0052] Example description: Assume that there is a permission tree structure as follows: Node A (parent node) Node B (child node) Node C (child node) Node D (child node) In the initial state, the role user has the permissions for nodes B and C, and node D is not authorized. At this time, the status of node A is half-selected (because the role user has the permissions for some child nodes).
[0053] Embodiment 1: The administrator adds a new node E under node A, and the role user is not authorized to the new node E. The system records the ID of node A and updates the intermediate result cache item: Total number of child nodes: Updated from 3 to 4 (B, C, D, E).
[0054] Total number of authority nodes: remain at 2 (B, C).
[0055] Cache timestamp: Update to current time.
[0056] Based on the data in the cache item, the system calculates the status of node A: the total number of child nodes (4) ≠ the total number of authority nodes (2), so the status of node A is half-selected.
[0057] Recursively update the status of the parent node.
[0058] Embodiment 2: The administrator deletes node B under node A. The role user originally had the permission for node B. The system records the ID of node A and updates the intermediate result cache item: Total number of child nodes: Updated from 3 to 2 (C, D).
[0059] Total number of authority nodes: Updated from 2 to 1 (C).
[0060] Cache timestamp: Update to current time.
[0061] Based on the data in the cache item, the system calculates the status of node A: the total number of child nodes (2) ≠ the total number of authority nodes (1), so the status of node A is half-selected.
[0062] Recursively update the status of the parent node.
[0063] Embodiment three: The administrator authorizes node D to the role user, who originally did not have permission to access node D. The system records the ID of node A and updates the intermediate result cache item: Total number of child nodes: Keep to 3 (B, C, D).
[0064] Total number of authority nodes: updated from 2 to 3 (B, C, D).
[0065] Cache timestamp: Update to current time.
[0066] Based on the data in the cache item, the system calculates the status of node A: the total number of child nodes (3) = the total number of authority nodes (3), so the status of node A is fully selected.
[0067] Recursively update the status of the parent node.
[0068] It can be seen from the above embodiments that the intermediate result cache item plays a key role in the permission tree status calculation. By caching the total number of child nodes and the total number of permission nodes, the overhead of repeatedly traversing the permission tree is avoided; the timeliness of the data is ensured by the timestamp field to avoid using expired data for status calculation; dynamic updates are supported to ensure that the permission tree status can be updated in real time and remain consistent after adding, deleting or modifying operations, thereby improving the system's response speed and computing efficiency while reducing system overhead.
[0069] The design of introducing intermediate cache items makes the state management of the permission tree more efficient and accurate, especially in lazy loading mode, which can significantly improve the user experience.
[0070] This example demonstrates how this embodiment significantly improves the efficiency of the permission tree full / partial selection setting through event-driven architecture, state calculation logic, and the introduction of intermediate cache items.
[0071] From the above description, it can be seen that the permission tree status display method provided in the embodiment of the present application can create a permission tree based on the permission tree nodes, role permission relationships and cache structure, traverse all child nodes in the parent node of the permission tree to obtain the total number of child nodes, traverse the permission nodes belonging to the user in the parent node of the permission tree under the user role to obtain the total number of permission nodes, cache the total number of child nodes, the total number of permission nodes and the timestamp when the node is updated to obtain an intermediate result cache item, update the intermediate result cache item according to the administrator's update content of the permission node of the permission tree, perform status calculation on the updated intermediate result cache item according to the preset status calculation rules to obtain the status of the parent node of the permission tree, wherein the status of the parent node of the permission tree is fully selected, half selected and unselected, thereby improving the efficiency and reliability of the permission tree status display.
[0072] In one embodiment of the permission tree status display method of the present application, see Figure 2 , and can also include the following: Step S201: receiving an administrator's operation of adding a sub-authority node to the authority tree, and determining the corresponding number of incremental sub-authority nodes; Step S202: performing a quantity addition operation on the total number of child nodes and the total number of authority nodes according to the incremental number of child authority nodes, and updating the cache timestamp according to the corresponding time when adding, to determine the updated total number of child nodes, the updated total number of authority nodes and the updated cache timestamp.
[0073] Optionally, in this embodiment, this step is when the "add sub-permission" event is triggered, the event handler handles the processing logic of adding sub-permission event.
[0074] Specifically, first, obtain the ID of the parent node to which the child permission is added, then call the cache to query and update the number of all child permissions under the parent node, query and update the number of permissions that the role has under the parent node, call the status calculation algorithm to calculate the updated parent node status, and update the status records of the parent node in the database and cache.
[0075] For example: Assume that there is a permission tree structure as follows: Node A (parent node) Node B (child node) Node C (child node) Node D (child node) In the initial state, the role user has the permissions for nodes B and C, and node D is not authorized. At this time, the status of node A is half-selected (because the role user has the permissions for some child nodes).
[0076] The administrator adds a new node E under node A, and the role user is not authorized to the new node E. The system records the ID of node A and updates the intermediate result cache item: Total number of child nodes: Updated from 3 to 4 (B, C, D, E).
[0077] Total number of authority nodes: remain at 2 (B, C).
[0078] Cache timestamp: Update to current time.
[0079] Based on the data in the cache item, the system calculates the status of node A: the total number of child nodes (4) ≠ the total number of authority nodes (2), so the status of node A is half-selected.
[0080] Recursively update the status of the parent node.
[0081] Through step S202, this embodiment performs an event response according to the event of adding a sub-permission, and successfully changes the permission state of the permission tree when the administrator "adds a sub-permission" in combination with the cache item calling event processing logic.
[0082] In one embodiment of the permission tree status display method of the present application, see Figure 3 , and can also include the following: Step S301: receiving an administrator's operation of deleting a sub-authority node on the authority tree, and determining the corresponding number of sub-authority nodes to be reduced; Step S302: reducing the total number of child nodes and the total number of authority nodes according to the reduced number of sub-authority nodes, and updating the cache timestamp according to the time corresponding to the reduction, to determine the updated total number of child nodes, the updated total number of authority nodes, and the updated cache timestamp.
[0083] Optionally, in the present embodiment, this step is the processing logic of the event handler for processing the sub-permission deletion event when the "sub-permission deletion" event is triggered.
[0084] Specifically, first, obtain the parent node ID of the deleted child permission, then call the cache to query and update the number of all child permissions under the parent node, query and update the number of permissions that the role has under the parent node, call the status calculation algorithm to calculate the updated parent node status, and update the status records of the parent node in the database and cache.
[0085] For example: Assume that there is a permission tree structure as follows: Node A (parent node) Node B (child node) Node C (child node) Node D (child node) In the initial state, the role user has the permissions for nodes B and C, and node D is not authorized. At this time, the status of node A is half-selected (because the role user has the permissions for some child nodes).
[0086] The administrator deletes node B under node A. The role user originally had the permission for node B. The system records the ID of node A and updates the intermediate result cache item: Total number of child nodes: Updated from 3 to 2 (C, D).
[0087] Total number of authority nodes: Updated from 2 to 1 (C).
[0088] Cache timestamp: Update to current time.
[0089] Based on the data in the cache item, the system calculates the status of node A: the total number of child nodes (2) ≠ the total number of authority nodes (1), so the status of node A is half-selected.
[0090] Recursively update the status of the parent node.
[0091] Through step S302, this embodiment performs an event response based on the sub-permission deletion event, and successfully changes the permission state of the permission tree when the administrator "deletes sub-permissions" in combination with the cache item call event processing logic.
[0092] In one embodiment of the permission tree status display method of the present application, see Figure 4 , and can also include the following: Step S401: receiving an administrator's operation of modifying the permission status of the permission tree, and determining the corresponding number of changed sub-permission nodes; Step S402: performing a quantity change operation on the total number of child nodes and the total number of authority nodes according to the changed number of child authority nodes, and updating the cache timestamp according to the corresponding time when the change occurs, to determine the updated total number of child nodes, the updated total number of authority nodes, and the updated cache timestamp.
[0093] Optionally, in this embodiment, this step is the processing logic of the event handler processing the event of modifying the permission status when the event of "modify permission status" is triggered.
[0094] Specifically, first, obtain the parent node ID of the modified child permission, then call the cache to query and update the number of all child permissions under the parent node, query and update the number of permissions that the role has under the parent node, call the status calculation algorithm to calculate the updated parent node status, and update the status records of the parent node in the database and cache.
[0095] For example: Assume that there is a permission tree structure as follows: Node A (parent node) Node B (child node) Node C (child node) Node D (child node) In the initial state, the role user has the permissions for nodes B and C, and node D is not authorized. At this time, the status of node A is half-selected (because the role user has the permissions for some child nodes).
[0096] The administrator authorizes node D to the role user, who originally did not have permission to access node D. The system records the ID of node A and updates the intermediate result cache item: Total number of child nodes: Keep to 3 (B, C, D).
[0097] Total number of authority nodes: updated from 2 to 3 (B, C, D).
[0098] Cache timestamp: Update to current time.
[0099] Based on the data in the cache item, the system calculates the status of node A: the total number of child nodes (3) = the total number of authority nodes (3), so the status of node A is fully selected.
[0100] Recursively update the status of the parent node.
[0101] Through step S402, this embodiment performs an event response according to the permission status modification event, and successfully changes the permission status of the permission tree when the administrator "modifies the permission status" in combination with the cache item call event processing logic.
[0102] In one embodiment of the permission tree status display method of the present application, see Figure 5 , and can also include the following: Step S501: determining whether the total number of child nodes in the updated intermediate result cache item is equal to the total number of authority nodes in the updated intermediate result cache item; Step S502: If they are equal, determine that the corresponding permission tree parent node state is a fully selected state.
[0103] Optionally, in this embodiment, this step is the implementation logic of the state calculation algorithm.
[0104] Specifically, first, the number of child nodes (subCount) of the current node is obtained from the cache; if it does not exist in the cache, the cache is queried from the database and updated.
[0105] Then, the number of permissions that the role has under the current node (roleCount) is obtained from the cache; if it does not exist in the cache, the cache is queried from the database and updated.
[0106] Determine the quantitative relationship between the number of child nodes of the current node (subCount) and the number of permissions the role has under the current node (roleCount). If the two are equal, the node status is fully selected.
[0107] Through step S502, this embodiment successfully performs correct node status judgment according to the status calculation logic, laying a foundation for the subsequent display of the correct permission tree node status.
[0108] In one embodiment of the permission tree status display method of the present application, see Figure 6 , and can also include the following: Step S601: Determine whether the total number of child nodes in the updated intermediate result cache item is greater than the total number of authority nodes in the updated intermediate result cache item; Step S602: If it is greater than, determine whether the total number of permission nodes in the updated intermediate result cache item is greater than zero. If it is greater than, determine that the corresponding permission tree parent node state is half-selected. If it is equal to zero, determine that the corresponding permission tree parent node state is unselected.
[0109] Optionally, in this embodiment, this step is the implementation logic of the state calculation algorithm.
[0110] Specifically, first, the number of child nodes (subCount) of the current node is obtained from the cache; if it does not exist in the cache, the cache is queried from the database and updated.
[0111] Then, the number of permissions that the role has under the current node (roleCount) is obtained from the cache; if it does not exist in the cache, the cache is queried from the database and updated.
[0112] Determine the quantitative relationship between the number of child nodes (subCount) of the current node and the number of permissions (roleCount) that the role has under the current node. If the number of permissions that the role has under the current node = 0, the node status is unselected; if 0 < the number of permissions that the role has under the current node < the number of child nodes of the current node, the node status is half-selected.
[0113] Through step S602, this embodiment successfully performs correct node status judgment according to the status calculation logic, laying a foundation for the subsequent display of the correct permission tree node status.
[0114] In one embodiment of the permission tree status display method of the present application, see Figure 7 , and can also include the following: Step S701: receiving a user's access request to the permission tree, and determining whether the cache timestamp in the updated intermediate result cache item exceeds a preset time threshold; Step S702: If it does not exceed, a state calculation operation is performed on the updated intermediate result cache item according to a preset state calculation rule to determine the state of the corresponding parent node of the permission tree.
[0115] Optionally, this step combines the timestamp in the intermediate cache item with the state calculation to ensure that the state of the permission tree node is displayed correctly when the user accesses the node.
[0116] Specifically, for example, assume that there is a permission tree structure as follows: Node A (parent node) Node B (child node) Node C (child node) Node D (child node) In the initial state, the role user has the permissions for nodes B and C, and node D is not authorized. At this time, the status of node A is half-selected (because the role user has the permissions for some child nodes).
[0117] The administrator adds a new node E under node A, and the role user is not authorized to the new node E. The system records the ID of node A and updates the intermediate result cache item: Total number of child nodes: Updated from 3 to 4 (B, C, D, E).
[0118] Total number of authority nodes: remain at 2 (B, C).
[0119] Cache timestamp: T1.
[0120] The user initiates an access request to the permission tree. After receiving the request, the system performs the following steps: Step 1: Determine whether the cache timestamp exceeds the preset time threshold The system obtains the current time (assuming it is T2); Calculate the time difference between the current time T2 and the cached timestamp T1 (ΔT = T2 - T1); It is determined whether ΔT exceeds a preset time threshold (assuming that the preset time threshold is 5 minutes).
[0121] 1. If ΔT ≤ 5 minutes, it means that the cache item has not expired, and the system directly uses the cache item for status calculation.
[0122] 2. If ΔT > 5 minutes, it means that the cache item has expired and the system needs to re-traverse the permission tree and update the cache item.
[0123] Step 2: Calculate the state based on the cache item 1. Assuming ΔT = 3 minutes (not more than 5 minutes), the system directly uses the cache item for state calculation.
[0124] Cache item data: Total number of child nodes: 4 (B, C, D, E).
[0125] Total number of authority nodes: 2 (B, C).
[0126] Calculation rules based on preset status: If the total number of child nodes = the total number of permission nodes, the node status is all selected.
[0127] If the total number of authority nodes > 0 and < the total number of child nodes, the node status is half-elected.
[0128] If total number of authority nodes = 0, the node status is unchecked.
[0129] Calculation results: The total number of child nodes (4) ≠ the total number of authority nodes (2), so the status of node A is half-selected.
[0130] 2. Assuming ΔT = 6 minutes (more than 5 minutes), the system needs to re-traverse the permission tree and update the cache items.
[0131] The system requeries the total number of child nodes and authority nodes of node A: Total number of child nodes: 4 (B, C, D, E).
[0132] Total number of authority nodes: 2 (B, C).
[0133] Update the cache item: Total number of child nodes: 4.
[0134] Total number of authority nodes: 2.
[0135] Cache timestamp: Updated to the current time (T2).
[0136] Calculate the state based on the updated cache item: The total number of child nodes (4) ≠ the total number of authority nodes (2), so the status of node A is half-selected.
[0137] When the above two situations are displayed on the front end, the status of node A is correctly displayed as half-selected.
[0138] By determining whether the cache timestamp exceeds the preset time threshold, the system can decide whether to use the cache item directly for state calculation or re-traverse the permission tree to update the cache item. This approach ensures the timeliness and consistency of the data while reducing unnecessary computing overhead. If the cache item has not expired, the system can quickly respond to the user's access request and improve the user experience. If the cache item expires, the system re-traverses the permission tree to ensure the accuracy of the permission tree state.
[0139] Through step S702, this embodiment makes the permission tree state management more efficient and accurate by combining the cache timestamp with the state calculation rule.
[0140] In order to improve the efficiency and reliability of permission tree status display, the present application provides an embodiment of a permission tree status display device for implementing all or part of the content of the permission tree status display method, see Figure 8 The permission tree status display device specifically includes the following contents: The permission tree structure framework building module 10 is used to create a permission tree according to a preset data structure, wherein the data structure includes permission tree nodes, role permission relationships, and a cache structure, wherein the role permission relationship is used to represent the relationship between user roles and node permissions, and the cache structure includes a timestamp for recording the last update time of the cache item; The permission tree intermediate result cache module 20 is used to perform a child node traversal operation on the parent node in the permission tree node to determine the total number of corresponding child nodes, perform a user permission node traversal operation according to the parent node in the permission tree node and the user unique identifier in the role permission relationship to determine the total number of corresponding permission nodes, update the cache structure of the parent node according to the total number of child nodes and the total number of permission nodes, and determine the corresponding intermediate result cache item, wherein the intermediate result cache item includes the total number of child nodes, the total number of permission nodes and the cache timestamp; The permission tree status display module 30 is used to receive the administrator's permission node update operation on the permission tree, determine the corresponding updated permission node, update the intermediate result cache item according to the updated permission node, determine the corresponding updated intermediate result cache item, perform a status calculation operation on the updated intermediate result cache item according to a preset status calculation rule, and determine the corresponding permission tree parent node status, wherein the permission tree parent node status is fully selected, half selected, and unselected.
[0141] From the above description, it can be seen that the permission tree status display device provided in the embodiment of the present application can create a permission tree based on the permission tree nodes, role permission relationships and cache structure, traverse all child nodes in the parent node of the permission tree to obtain the total number of child nodes, traverse the permission nodes belonging to the user in the parent node of the permission tree under the user role to obtain the total number of permission nodes, cache the total number of child nodes, the total number of permission nodes and the timestamp when the node is updated to obtain an intermediate result cache item, update the intermediate result cache item according to the administrator's update content of the permission node of the permission tree, and perform status calculation on the updated intermediate result cache item according to the preset status calculation rules to obtain the status of the parent node of the permission tree, wherein the status of the parent node of the permission tree is fully selected, half selected and unselected, thereby improving the efficiency and reliability of the permission tree status display.
[0142] From a hardware perspective, in order to improve the efficiency and reliability of the permission tree status display, the present application provides an embodiment of an electronic device for implementing all or part of the content in the permission tree status display method, and the electronic device specifically includes the following content: Processor, memory, communication interface and bus; wherein the processor, memory and communication interface communicate with each other through the bus; the communication interface is used to realize information transmission between the permission tree status display method and related devices such as core business systems, user terminals and related databases; the logic controller can be a desktop computer, a tablet computer and a mobile terminal, etc., but the present embodiment is not limited thereto. In the present embodiment, the logic controller can be implemented with reference to the embodiment of the permission tree status display method in the embodiment, and the embodiment of the permission tree status display method, and the contents thereof are incorporated herein, and the repeated parts are not repeated.
[0143] It is understandable that the user terminal may include a smart phone, a tablet electronic device, a network set-top box, a portable computer, a desktop computer, a personal digital assistant (PDA), a vehicle-mounted device, a smart wearable device, etc. Among them, the smart wearable device may include smart glasses, a smart watch, a smart bracelet, etc.
[0144] In practical applications, part of the permission tree status display method can be executed on the electronic device side as described above, or all operations can be completed in the client device. The specific selection can be based on the processing capability of the client device and the limitations of the user's usage scenario. This application does not limit this. If all operations are completed in the client device, the client device may also include a processor.
[0145] The client device may have a communication module (i.e., a communication unit) that can communicate with a remote server to achieve data transmission with the server. The server may include a server on the task scheduling center side, and other implementation scenarios may also include a server on an intermediate platform, such as a server on a third-party server platform that has a communication link with the task scheduling center server. The server may include a single computer device, or a server cluster consisting of multiple servers, or a server structure of a distributed device.
[0146] Fig. 9 FIG. 9 is a schematic block diagram of the system structure of the electronic device 9600 according to an embodiment of the present application. Fig. 9 As shown, the electronic device 9600 may include a central processor 9100 and a memory 9140; the memory 9140 is coupled to the central processor 9100. It is worth noting that Fig. 9 is exemplary; other types of structures may also be used to supplement or replace this structure to implement telecommunication functions or other functions.
[0147] In one embodiment, the permission tree status display method function may be integrated into the central processing unit 9100. The central processing unit 9100 may be configured to perform the following control: Step S101: creating a permission tree according to a preset data structure, wherein the data structure includes permission tree nodes, role permission relationships, and a cache structure, wherein the role permission relationship is used to represent the relationship between user roles and node permissions, and the cache structure includes a timestamp for recording the last update time of the cache item; Step S102: performing a child node traversal operation on the parent node in the permission tree node to determine the total number of corresponding child nodes, performing a user permission node traversal operation according to the parent node in the permission tree node and the user unique identifier in the role permission relationship to determine the total number of corresponding permission nodes, and updating the cache structure of the parent node according to the total number of child nodes and the total number of permission nodes to determine the corresponding intermediate result cache item, wherein the intermediate result cache item includes the total number of child nodes, the total number of permission nodes and a cache timestamp; Step S103: Receive the administrator's update operation on the permission node of the permission tree, determine the corresponding updated permission node, perform an update operation on the intermediate result cache item according to the updated permission node, determine the corresponding updated intermediate result cache item, perform a state calculation operation on the updated intermediate result cache item according to a preset state calculation rule, and determine the corresponding permission tree parent node state, wherein the permission tree parent node state is fully selected, half selected, and unselected.
[0148] From the above description, it can be seen that the electronic device provided by the embodiment of the present application creates a permission tree based on the permission tree nodes, role permission relationships and cache structure, traverses all child nodes in the parent node of the permission tree to obtain the total number of child nodes, traverses the permission nodes belonging to the user in the parent node of the permission tree under the user role to obtain the total number of permission nodes, caches the total number of child nodes, the total number of permission nodes and the timestamp when the node is updated to obtain an intermediate result cache item, updates the intermediate result cache item according to the administrator's update content of the permission node of the permission tree, and performs status calculation on the updated intermediate result cache item according to the preset status calculation rule to obtain the status of the parent node of the permission tree, wherein the status of the parent node of the permission tree is fully selected, half selected and unselected, thereby improving the efficiency and reliability of the permission tree status display.
[0149] In another embodiment, the permission tree status display method can be configured separately from the central processing unit 9100. For example, the permission tree status display method can be configured as a chip connected to the central processing unit 9100, and the permission tree status display method function is implemented through the control of the central processing unit.
[0150] like Fig. 9 As shown, the electronic device 9600 may also include: a communication module 9110, an input unit 9120, an audio processor 9130, a display 9160, and a power supply 9170. It is worth noting that the electronic device 9600 does not necessarily have to include Fig. 9 In addition, the electronic device 9600 may also include Fig. 9 For components not shown, reference may be made to the prior art.
[0151] like Fig. 9 As shown, the central processing unit 9100 is sometimes also referred to as a controller or an operation control, and may include a microprocessor or other processor device and / or logic device. The central processing unit 9100 receives input and controls the operation of various components of the electronic device 9600.
[0152] The memory 9140 may be, for example, one or more of a cache, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory or other suitable devices. The above-mentioned information related to the failure may be stored, and a program for executing the relevant information may also be stored. The CPU 9100 may execute the program stored in the memory 9140 to implement information storage or processing, etc.
[0153] The input unit 9120 provides input to the central processing unit 9100. The input unit 9120 is, for example, a key or a touch input device. The power supply 9170 is used to provide power to the electronic device 9600. The display 9160 is used to display display objects such as images and texts. The display may be, for example, an LCD display, but is not limited thereto.
[0154] The memory 9140 may be a solid-state memory, such as a read-only memory (ROM), a random access memory (RAM), a SIM card, etc. It may also be a memory that saves information even when the power is off, can be selectively erased, and is provided with more data, examples of which are sometimes referred to as EPROMs, etc. The memory 9140 may also be some other type of device. The memory 9140 includes a buffer memory 9141 (sometimes referred to as a buffer). The memory 9140 may include an application / function storage unit 9142, which is used to store application programs and function programs or processes for executing the operation of the electronic device 9600 through the central processor 9100.
[0155] The memory 9140 may also include a data storage unit 9143 for storing data, such as contacts, digital data, pictures, sounds, and / or any other data used by the electronic device. The driver storage unit 9144 of the memory 9140 may include various drivers for communication functions of the electronic device and / or for executing other functions of the electronic device (such as messaging applications, address book applications, etc.).
[0156] The communication module 9110 is a transmitter / receiver that sends and receives signals via the antenna 9111. The communication module 9110 is coupled to the central processor 9100 to provide input signals and receive output signals, which may be the same as the case of a conventional mobile communication terminal.
[0157] Based on different communication technologies, multiple communication modules 9110 may be provided in the same electronic device, such as a cellular network module, a Bluetooth module and / or a wireless local area network module, etc. The communication module 9110 is also coupled to a speaker 9131 and a microphone 9132 via an audio processor 9130 to provide an audio output via the speaker 9131 and receive an audio input from the microphone 9132, thereby realizing a common telecommunication function. The audio processor 9130 may include any suitable buffer, decoder, amplifier, etc. In addition, the audio processor 9130 is also coupled to the central processor 9100, so that recording can be performed on the machine through the microphone 9132, and the sound stored on the machine can be played through the speaker 9131.
[0158] The embodiments of the present application also provide a computer-readable storage medium capable of implementing all the steps of the method for displaying the status of a permission tree in the above embodiment, where the execution subject is a server or a client. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, all the steps of the method for displaying the status of a permission tree in the above embodiment are implemented, where the execution subject is a server or a client. For example, when the processor executes the computer program, the following steps are implemented: Step S101: creating a permission tree according to a preset data structure, wherein the data structure includes permission tree nodes, role permission relationships, and a cache structure, wherein the role permission relationship is used to represent the relationship between user roles and node permissions, and the cache structure includes a timestamp for recording the last update time of the cache item; Step S102: performing a child node traversal operation on the parent node in the permission tree node to determine the total number of corresponding child nodes, performing a user permission node traversal operation according to the parent node in the permission tree node and the user unique identifier in the role permission relationship to determine the total number of corresponding permission nodes, and updating the cache structure of the parent node according to the total number of child nodes and the total number of permission nodes to determine the corresponding intermediate result cache item, wherein the intermediate result cache item includes the total number of child nodes, the total number of permission nodes and a cache timestamp; Step S103: Receive the administrator's update operation on the permission node of the permission tree, determine the corresponding updated permission node, perform an update operation on the intermediate result cache item according to the updated permission node, determine the corresponding updated intermediate result cache item, perform a state calculation operation on the updated intermediate result cache item according to a preset state calculation rule, and determine the corresponding permission tree parent node state, wherein the permission tree parent node state is fully selected, half selected, and unselected.
[0159] From the above description, it can be seen that the computer-readable storage medium provided in the embodiment of the present application creates a permission tree based on the permission tree nodes, role permission relationships and cache structure, traverses all child nodes in the parent node of the permission tree to obtain the total number of child nodes, traverses the permission nodes belonging to the user in the parent node of the permission tree under the user role to obtain the total number of permission nodes, caches the total number of child nodes, the total number of permission nodes and the timestamp when the node is updated to obtain an intermediate result cache item, updates the intermediate result cache item according to the administrator's update content of the permission node of the permission tree, and performs status calculation on the updated intermediate result cache item according to the preset status calculation rules to obtain the status of the parent node of the permission tree, wherein the status of the parent node of the permission tree is fully selected, half selected and unselected, thereby improving the efficiency and reliability of the permission tree status display.
[0160] The embodiments of the present application also provide a computer program product capable of implementing all the steps of the permission tree status display method in the above embodiments, where the execution subject is a server or a client. When the computer program / instruction is executed by a processor, the steps of the permission tree status display method are implemented. For example, the computer program / instruction implements the following steps: Step S101: creating a permission tree according to a preset data structure, wherein the data structure includes permission tree nodes, role permission relationships, and a cache structure, wherein the role permission relationship is used to represent the relationship between user roles and node permissions, and the cache structure includes a timestamp for recording the last update time of the cache item; Step S102: performing a child node traversal operation on the parent node in the permission tree node to determine the total number of corresponding child nodes, performing a user permission node traversal operation according to the parent node in the permission tree node and the user unique identifier in the role permission relationship to determine the total number of corresponding permission nodes, and updating the cache structure of the parent node according to the total number of child nodes and the total number of permission nodes to determine the corresponding intermediate result cache item, wherein the intermediate result cache item includes the total number of child nodes, the total number of permission nodes and a cache timestamp; Step S103: Receive the administrator's update operation on the permission node of the permission tree, determine the corresponding updated permission node, perform an update operation on the intermediate result cache item according to the updated permission node, determine the corresponding updated intermediate result cache item, perform a state calculation operation on the updated intermediate result cache item according to a preset state calculation rule, and determine the corresponding permission tree parent node state, wherein the permission tree parent node state is fully selected, half selected, and unselected.
[0161] From the above description, it can be seen that the computer program product provided by the embodiment of the present application creates a permission tree based on permission tree nodes, role permission relationships and cache structures, traverses all child nodes in the parent node of the permission tree to obtain the total number of child nodes, traverses the permission nodes belonging to the user in the parent node of the permission tree under the user role to obtain the total number of permission nodes, caches the total number of child nodes, the total number of permission nodes and the timestamp when the node is updated to obtain an intermediate result cache item, updates the intermediate result cache item according to the administrator's update content of the permission node of the permission tree, and performs status calculation on the updated intermediate result cache item according to a preset status calculation rule to obtain the status of the parent node of the permission tree, wherein the status of the parent node of the permission tree is fully selected, half selected and unselected, thereby improving the efficiency and reliability of the permission tree status display.
[0162] It should be understood by those skilled in the art that embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0163] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (apparatus), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0164] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0165] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0166] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.< / string>
Claims
1. A method for displaying the status of a permission tree, characterized in that: The method comprises: Creating a permission tree according to a preset data structure, wherein the data structure includes permission tree nodes, role permission relationships, and a cache structure, wherein the role permission relationship is used to represent the relationship between user roles and node permissions, and the cache structure includes a timestamp for recording the last update time of the cache item; Perform a child node traversal operation on the parent node in the permission tree node to determine the total number of corresponding child nodes, perform a user permission node traversal operation according to the parent node in the permission tree node and the user unique identifier in the role permission relationship to determine the total number of corresponding permission nodes, and perform an update operation on the cache structure of the parent node according to the total number of child nodes and the total number of permission nodes to determine the corresponding intermediate result cache item, wherein the intermediate result cache item includes the total number of child nodes, the total number of permission nodes, and a cache timestamp; Receive an administrator's update operation on a permission node of the permission tree, determine a corresponding updated permission node, perform an update operation on the intermediate result cache item according to the updated permission node, determine a corresponding updated intermediate result cache item, perform a state calculation operation on the updated intermediate result cache item according to a preset state calculation rule, and determine a corresponding permission tree parent node state, wherein the permission tree parent node state is fully selected, half selected, and unselected.
2. The permission tree status display method according to claim 1 is characterized in that: The receiving an administrator's update operation on a permission node of the permission tree, determining a corresponding update permission node, performing an update operation on the intermediate result cache item according to the update permission node, and determining a corresponding updated intermediate result cache item, comprises: Receive an administrator's operation of adding a sub-authority node to the authority tree, and determine the corresponding number of incremental sub-authority nodes; An operation of adding the total number of child nodes and the total number of authority nodes is performed according to the number of incremental child authority nodes, and the cache timestamp is updated according to a time corresponding to the addition to determine an updated total number of child nodes, an updated total number of authority nodes, and an updated cache timestamp.
3. The permission tree status display method according to claim 1 is characterized in that: The receiving an administrator's update operation on a permission node of the permission tree, determining a corresponding update permission node, performing an update operation on the intermediate result cache item according to the update permission node, and determining a corresponding updated intermediate result cache item, further comprising: Receive an administrator's operation of deleting a sub-authority node of the authority tree, and determine the corresponding number of sub-authority nodes to be reduced; A number reduction operation is performed on the total number of child nodes and the total number of authority nodes according to the reduced number of sub-authority nodes, and the cache timestamp is updated according to a time corresponding to the reduction to determine an updated total number of child nodes, an updated total number of authority nodes, and an updated cache timestamp.
4. The permission tree status display method according to claim 1 is characterized in that: The receiving an administrator's update operation on a permission node of the permission tree, determining a corresponding update permission node, performing an update operation on the intermediate result cache item according to the update permission node, and determining a corresponding updated intermediate result cache item, further comprising: Receive an administrator's operation of modifying the permission status of the permission tree, and determine the corresponding number of changed sub-permission nodes; The total number of child nodes and the total number of authority nodes are changed according to the changed number of child authority nodes, and the cache timestamp is updated according to the time corresponding to the change to determine the updated total number of child nodes, the updated total number of authority nodes and the updated cache timestamp.
5. The permission tree status display method according to claim 1, characterized in that: The performing a state calculation operation on the updated intermediate result cache item according to a preset state calculation rule to determine the corresponding permission tree parent node state includes: Determine whether the total number of child nodes in the updated intermediate result cache item is equal to the total number of authority nodes in the updated intermediate result cache item; If they are equal, it is determined that the corresponding permission tree parent node state is fully selected.
6. The permission tree status display method according to claim 1, characterized in that: The performing a state calculation operation on the updated intermediate result cache item according to a preset state calculation rule to determine the corresponding permission tree parent node state also includes: Determine whether the total number of child nodes in the updated intermediate result cache item is greater than the total number of authority nodes in the updated intermediate result cache item; If it is greater, determine whether the total number of permission nodes in the updated intermediate result cache item is greater than zero. If it is greater, determine that the corresponding permission tree parent node state is half-selected. If it is equal to zero, determine that the corresponding permission tree parent node state is unselected.
7. The permission tree status display method according to claim 1, characterized in that: Also includes: Receive a user's access request to the permission tree, and determine whether a cache timestamp in the updated intermediate result cache item exceeds a preset time threshold; If it does not exceed, a state calculation operation is performed on the updated intermediate result cache item according to a preset state calculation rule to determine the state of the corresponding parent node of the permission tree.
8. A permission tree status display device, characterized in that: The device comprises: A permission tree structure framework building module, used to create a permission tree according to a preset data structure, wherein the data structure includes permission tree nodes, role permission relationships, and a cache structure, wherein the role permission relationship is used to represent the relationship between user roles and node permissions, and the cache structure contains a timestamp for recording the last update time of the cache item; The permission tree intermediate result cache module is used to perform a child node traversal operation on the parent node in the permission tree node to determine the total number of corresponding child nodes, perform a user permission node traversal operation according to the parent node in the permission tree node and the user unique identifier in the role permission relationship to determine the total number of corresponding permission nodes, update the cache structure of the parent node according to the total number of child nodes and the total number of permission nodes, and determine the corresponding intermediate result cache item, wherein the intermediate result cache item includes the total number of child nodes, the total number of permission nodes and the cache timestamp; A permission tree status display module is used to receive an administrator's update operation on a permission node of the permission tree, determine a corresponding updated permission node, perform an update operation on the intermediate result cache item according to the updated permission node, determine a corresponding updated intermediate result cache item, perform a status calculation operation on the updated intermediate result cache item according to a preset status calculation rule, and determine a corresponding permission tree parent node status, wherein the permission tree parent node status is fully selected, half selected, and unselected.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the permission tree status display method described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the permission tree status display method described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Service request response method, apparatus, computer device, and storage medium
CN109492019A
Tree structure data processing method, electronic equipment and storage medium
CN114880041A
Permission tree management method and device, computer equipment and storage medium
CN118364484A
Tree structure data dynamic management method based on node hierarchical attributes and recursive updating
CN119719048A
Concurrency control for B-trees with node deletion
US20050171960A1
Cited By
Multi-feature interaction screening method, device and equipment for educational resource management platform
CN121722286A