Resource tree permission-based resource statistics method and device, medium and electronic equipment

By constructing a resource tree and querying the smallest unweighted subtree or the smallest weighted subtree, nodes with or without permissions are skipped, solving the problems of high computational load and low efficiency in existing technologies, and achieving efficient resource statistics.

CN114691671BActive Publication Date: 2026-02-24ZHEJIANG UNIVIEW TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011608688.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-30
Publication Date
2026-02-24
Estimated Expiration
2040-12-30

AI Technical Summary

Technical Problem

Existing technologies require permission verification for each node when performing statistics on camera resources in a resource tree, resulting in high computational load and low efficiency.

Method used

By constructing a resource tree, determining the user's permissions on the root node, querying the smallest unweighted subtree or the smallest weighted subtree, and skipping nodes that do not require permissions or nodes that have permissions, the number of traversals is reduced.

Benefits of technology

This reduces the amount of computation required for resource statistics and improves statistical efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114691671B_ABST
    Figure CN114691671B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a resource statistics method and device based on resource tree permissions, a medium and an electronic device. A resource tree composed of organization nodes and camera nodes is constructed according to the self ID and parent node ID of a resource; whether a user has permission to a root node of the resource tree is judged according to at least one role allocated to the user; if the user has the permission, a minimum unauthorized sub-tree is queried in the resource tree; in a statistical analysis process, if a current analysis node of the resource tree is a root node of the minimum unauthorized sub-tree, all nodes of the minimum unauthorized sub-tree are skipped to obtain a resource statistics result. By using the present solution, when camera resources in the resource tree are counted, the configured permissions can reduce the nodes and levels to be traversed, and the permission identification does not need to be performed again during the traversal, thereby reducing the calculation amount required for resource statistics, and improving the statistical efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a resource statistics method, apparatus, medium and electronic device based on resource tree permissions. Background Technology

[0002] A tree structure is a finite set of one or more nodes. Each node represents a resource, and the edges connecting nodes represent the connection between parent and child nodes; these can be file transfer paths or representations of management relationships between nodes. In the security industry, when a resource access control system stores all resources in memory in a tree structure, the descendant nodes under a given node typically represent camera resources.

[0003] When performing statistics on camera resources in the resource tree, it is generally done by traversing each node and performing permission verification on each node.

[0004] When using this method to authenticate nodes, it is necessary to traverse each node from the leaf node to the root node and perform permission verification on each node. At the same time, different users may have different permissions for different nodes. Therefore, it is necessary to check the user's permission allocation for each node, which results in a large amount of computation required for resource statistics and low statistical efficiency. Summary of the Invention

[0005] This application provides a resource statistics method, apparatus, medium, and electronic device based on resource tree permissions. When performing statistics on camera resources in the resource tree, the configured permissions can reduce the number of nodes and levels traversed. At the same time, permission authentication is not required again during traversal, which reduces the amount of computation required for resource statistics and improves the efficiency of statistics.

[0006] In a first aspect, embodiments of this application provide a resource statistics method based on resource tree permissions, the method comprising:

[0007] Construct a resource tree consisting of organization nodes and camera nodes based on the resource's own ID and parent node ID;

[0008] Based on at least one role assigned to the user, determine whether the user has permission to the root node of the resource tree;

[0009] If permission is granted, then query the smallest unweighted subtree in the resource tree;

[0010] During the statistical analysis, if the current analysis node of the resource tree is the root node of the smallest unweighted subtree, then all nodes of the smallest unweighted subtree are skipped to obtain the resource statistics results.

[0011] Secondly, embodiments of this application provide a resource statistics device based on resource tree permissions, the device comprising:

[0012] The resource tree construction module is used to construct a resource tree consisting of organization nodes and camera nodes based on the resource's own ID and parent node ID.

[0013] The root node permission determination module is used to determine whether a user has permission to the root node of the resource tree based on at least one role assigned to the user.

[0014] The minimum unweighted subtree query module is used to query the minimum unweighted subtree in the resource tree if permissions are available.

[0015] The resource statistics result acquisition module is used in the statistical analysis process. If the current analysis node of the resource tree is the root node of the smallest unweighted subtree, then all nodes of the smallest unweighted subtree are skipped to obtain the resource statistics result.

[0016] Thirdly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the resource statistics method based on resource tree permissions as described in embodiments of this application.

[0017] Fourthly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the resource statistics method based on resource tree permissions as described in embodiments of this application.

[0018] The technical solution provided in this application constructs a resource tree consisting of organization nodes and camera nodes based on the resource's own ID and parent node ID. It determines whether the user has permission to the root node of the resource tree based on at least one role assigned to the user. If permission is granted, the system queries the smallest unweighted subtree in the resource tree. During statistical analysis, if the current analysis node of the resource tree is the root node of the smallest unweighted subtree, all nodes in that smallest unweighted subtree are skipped to obtain the resource statistics results. The technical solution provided in this application, when performing statistics on camera resources in the resource tree, reduces the number of nodes and levels traversed through configured permissions. Furthermore, it eliminates the need for further permission verification during traversal, reducing the computational load required for resource statistics and improving statistical efficiency. Attached Figure Description

[0019] Figure 1 This is a flowchart of the resource statistics method based on resource tree permissions provided in Embodiment 1 of this application;

[0020] Figure 2 This is a flowchart of the query for the minimum unweighted subtree provided in Embodiment 1 of this application;

[0021] Figure 3 This is a schematic diagram of the resource statistics process based on resource tree permissions provided in Embodiment 2 of this application;

[0022] Figure 4 This is a flowchart of querying the minimum weighted subtree provided in Embodiment 2 of this application;

[0023] Figure 5 This is a schematic diagram of the resource statistics device based on resource tree permissions provided in Embodiment 3 of this application;

[0024] Figure 6 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of this application. Detailed Implementation

[0025] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the application and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present application, not the entire structure.

[0026] Before discussing the exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the steps as sequential processes, many of these steps can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the steps can be rearranged. The process can be terminated when its operation is complete, but may also have additional steps not included in the figures. The process can correspond to a method, function, procedure, subroutine, subroutine, etc.

[0027] Figure 1 This is a flowchart of a resource statistics method based on resource tree permissions provided in Embodiment 1 of this application. This embodiment is applicable to the situation of statistics on resources based on tree structure. The method can be executed by the resource statistics device based on resource tree permissions provided in this embodiment. The device can be implemented by software and / or hardware and can be integrated into a computer device.

[0028] like Figure 1 As shown, the resource statistics method based on resource tree permissions includes:

[0029] S110. Based on the resource's own ID and parent node ID, construct a resource tree consisting of organization nodes and camera nodes.

[0030] In this embodiment, the resource tree is tree-shaped and used to display the hierarchical structure of resources. It is constructed according to the resource ID, and each resource has a parent node ID attribute, except for the root node. The root node is a child node of the resource identified by the corresponding parent node ID. Resource trees are generally added under an organization, and after successful addition, the parent node ID of the resource becomes the node ID of the organization.

[0031] In this context, a resource can refer to all resources stored within the system. A resource's ID can be its address. A parent node can be the node above a resource in the resource tree. Understanding this, an organization node can be the parent node of the resource tree, and a camera node can be a child node of the resource tree; the resource tree is composed of organization nodes and camera nodes.

[0032] S120. Based on at least one role assigned to the user, determine whether the user has permission to the root node of the resource tree.

[0033] Roles can be used to store permissions for any resource node. Different permissions can be configured for each node. Permission information includes whether permissions are configured, no permissions are configured, or no permissions are configured. A user can have one or more roles, and the permissions they possess are the combined permissions of all roles.

[0034] In this embodiment, the root node is a component of the tree, also called the tree root. Every non-empty binary tree has one and only one root node. It is the ancestor of all nodes in the same tree except itself, and has no parent node. The root node has a depth of 1. The root node's permission information includes whether it has permissions or not.

[0035] In this solution, the user-role binding relationship is stored in the database, while the role-permission binding relationship is stored in the memory of RAS (Random Access Storage). Based on the user's assigned role, the root node of the resource tree can be retrieved from the RAS database to determine if it has the necessary permissions. RAS is a resource permission system that stores all system resources and their corresponding resource permission information in its memory. It provides relevant operation interfaces for resource permissions to the outside world through the resource tree storage.

[0036] In this technical solution, optionally, determining whether a user has permission to the root node of the resource tree based on at least one role assigned to the user includes:

[0037] Read at least one role assigned to the user from the database;

[0038] The resource permission information of the roles is read from the resource permission system to determine whether all assigned roles have permissions to the root node of the resource tree.

[0039] Understandably, by reading the user's assigned role from the database and determining the role, and then reading the role's permission information for resources from the resource permission system, it is possible to determine whether the user has permission to the root node of the resource tree.

[0040] By retrieving user roles and their resource permissions from different databases, it is possible to determine whether the root node of the resource tree has permissions, thus coarsening the granularity of permissions and providing support for subsequent resource queries in the resource tree.

[0041] S130. If permission is available, query the smallest unweighted subtree in the resource tree.

[0042] In this embodiment, a subtree can be any node and all its descendant nodes. An unweighted subtree means that every node in the subtree has no permissions. The smallest unweighted subtree can be a subtree containing descendant nodes of the current node, or a subtree containing only the current node. For example, if the parent node Organization 7 is configured with no permissions, the child node Camera 11 is configured with no permissions, and the child node Camera 12 is an inheriting node, then Organization 7, Camera 11, and Camera 12 form the smallest unweighted subtree. If the child node Camera 4 is configured with no permissions and has no parent node, then Camera 4 forms the smallest unweighted subtree.

[0043] Understandably, if the root node of the resource tree has permissions, then due to the permission inheritance principle in the permission rules, all subtrees or child nodes of that resource tree will also have permissions. Only a few nodes will be configured without permissions, and the smallest unauthorized subtree will be queried in the resource tree. The permission inheritance principle refers to child nodes inheriting the permissions of their parent nodes.

[0044] Specifically, querying the smallest unweighted subtree in the resource tree can be done using both the unweighted list and the weighted list. The unweighted list is traversed, and then the weighted list is checked to see if the current node has a descendant node. If a descendant node exists, all subtrees of the current node are traversed. If a subtree is the smallest unweighted subtree, the root node of the smallest unweighted subtree replaces the current node in the unweighted list. If no unweighted subtree exists, the unweighted node is directly removed from the unweighted list. The unweighted list can be a list of the root nodes of all unweighted subtrees. The weighted list can be a list of the root nodes of all weighted subtrees. For example, if organization 2 is configured with no permissions, organization 6 with permissions, organization 8 with no permissions, and camera 14 with permissions, then the unweighted list consists of organizations 2 and 8, and the weighted list consists of organizations 6 and camera 14.

[0045] Optionally, in this technical solution, querying the minimum unweighted subtree in the resource tree includes:

[0046] Retrieve nodes in the resource tree that are configured to have no permissions, and obtain a list of nodes with no permissions; and retrieve nodes in the resource tree that are configured to have permissions, and obtain a list of nodes with permissions.

[0047] For a node in the unweighted list, determine whether there is a node in the weighted list in the subtree of that node;

[0048] If it exists, traverse all subtrees of the current node in the unweighted list to obtain the smallest unweighted subtree, and replace the current node in the unweighted list with the root node of the smallest unweighted subtree.

[0049] Traverse all nodes in the unweighted list to obtain the smallest unweighted subtree in the resource tree.

[0050] For example, Figure 2 This is a flowchart of the query for the minimum unweighted subtree provided in Embodiment 1 of this application. For example... Figure 2 As shown, a solid square represents an organization with permissions, a solid rhombus represents an organization without permissions, a right triangle represents a camera without permissions, a solid equilateral triangle represents a camera with permissions, a hollow circle represents an organization whose permissions are inherited from the parent node, and a hollow equilateral triangle represents a camera whose permissions are inherited from the parent node.

[0051] Retrieve all nodes under the specified statistical nodes for the role that lack permissions, resulting in a list of unauthorized nodes. The unauthorized list includes Organization 2, Organization 8, Organization 9, Camera 11, and Camera 4. Also, retrieve all nodes under the specified statistical nodes for the role that have permissions, resulting in a list of authorized nodes. The authorized list includes Organization 1, Organization 6, Organization 14, Camera 17, and Camera 16.

[0052] Traverse the unweighted list, then check if its descendant node exists in the weighted list. If a descendant node exists, traverse all subtrees of the current node. If the subtree is the smallest unweighted subtree, replace the current node in the unweighted list with the root node of the smallest unweighted subtree. If there is no unweighted subtree, remove the unweighted node directly from the unweighted list. For example, if organization 6 in the weighted list is a descendant of organization 2 in the unweighted list, then we need to traverse the next level of children of organization 2 to find the smallest unweighted subtree. The steps are as follows:

[0053] Organizations 2 and 8 in the unauthorized list have descendant nodes, so remove them from the unauthorized list.

[0054] Traverse the next level of nodes in organization 2 to obtain camera 5, organization 6, organization 7, and organization 8.

[0055] Camera 5 is a camera, and it forms the smallest unweighted subtree. For organization 7, traversing all weighted lists, no node is a descendant of organization 7, so organization 7 and its descendant nodes are also the smallest unweighted subtree. For organization 8, camera 14 is a child node of organization 8, so continuing the search for the smallest unweighted subtree, we find that organization 13 is the smallest unweighted subtree.

[0056] The smallest unweighted subtrees were finally determined to be camera 5, organization 7, and organization 13. These three unweighted subtrees were added to the unweighted list, while organization 2 and organization 8 were removed.

[0057] By traversing all nodes in the unweighted list in this manner, we obtain the smallest unweighted subtrees in the resource tree. The final unweighted list is then: Camera 5, Organization 7, Camera 11, Organization 13, Camera 15, and Camera 4.

[0058] By traversing all nodes in the unweighted list, the smallest unweighted subtrees in the resource tree are obtained. When performing statistics on camera resources in the resource tree, the configured permissions can reduce the number of nodes and levels traversed. Furthermore, permission authentication is not required during traversal, reducing the computational load for resource statistics and improving efficiency.

[0059] In this technical solution, optionally, the minimum unweighted subtree includes at least one node;

[0060] If the least unweighted subtree contains at least two nodes, then all nodes in the least unweighted subtree include nodes configured with no permissions, or inherited nodes without configured permissions.

[0061] In this scheme, all nodes in the smallest unweighted subtree have the same permissions: no permissions. If the smallest unweighted subtree includes at least two nodes, then all nodes in the smallest unweighted subtree include nodes configured with no permissions or inheriting nodes without configured permissions. For example, the smallest unweighted subtree consists of a parent node organization 7, child nodes camera 11 and camera 12. The parent node organization 7 is configured with no permissions, camera 11 is configured with no permissions, camera 12 is configured as an inheriting node without configured permissions, and child node camera 12 inherits the no-permission status of parent node organization 7.

[0062] By determining the permissions of nodes in the smallest unweighted subtree, the smallest unweighted subtree can be identified. When performing statistics on camera resources in the resource tree, the configured permissions can reduce the number of nodes and levels traversed. At the same time, permission authentication is not required again during traversal, reducing the amount of computation required for resource statistics and improving statistical efficiency.

[0063] S140. During the statistical analysis, if the current analysis node of the resource tree is the root node of the smallest unweighted subtree, then all nodes of the smallest unweighted subtree are skipped to obtain the resource statistics results.

[0064] Understandably, when the analysis node of the resource tree is the root node of the smallest unweighted subtree, all nodes in that smallest unweighted subtree can be skipped during the statistical analysis. For example, if the parent node is Organization 7, and the child nodes are Camera 11 and Camera 12, with Organization 7 and Camera 11 configured with no permissions, and Camera 12 inheriting the no-permission setting from Organization 7, the smallest unweighted subtree is formed by the parent node 7, child nodes 11 and 12, and the parent node 7 is the root node of this smallest unweighted subtree. During the statistical analysis, only Organization 7 needs to be analyzed; child nodes 11 and 12 of this smallest unweighted subtree can be skipped to obtain the resource statistics results.

[0065] For example, such as Figure 2 As shown, this method retrieves all nodes without permissions under a specified statistical node for a given role, resulting in an unauthorized list. The unauthorized list includes Organization 2, Organization 8, Organization 9, Camera 11, and Camera 4. Conversely, the authorized list includes Organization 1, Organization 6, Organization 14, Camera 17, and Camera 16. Since the root node of the resource tree is authorized, the method queries the smallest unauthorized subtree within the resource tree. During the statistical process, the analysis node of the resource tree is the root node of the smallest unauthorized subtree. During the statistical process, nodes Organization 13 and Camera 18 within the smallest unauthorized subtree Organization 8, as well as child nodes Camera 11 and Child nodes Camera 12 within the smallest unauthorized subtree Organization 7, can be skipped. The statistics yield the number of online cameras (i.e., authorized cameras) and the total number of cameras (including both authorized and unauthorized cameras).

[0066] The technical solution provided in this application constructs a resource tree consisting of organization nodes and camera nodes based on the resource's own ID and parent node ID. It determines whether the user has permission to the root node of the resource tree based on at least one role assigned to the user. If permission is granted, the system queries the smallest unweighted subtree in the resource tree. During statistical analysis, if the current analysis node of the resource tree is the root node of the smallest unweighted subtree, all nodes in that smallest unweighted subtree are skipped to obtain the resource statistics results. By implementing this technical solution, when performing statistics on camera resources in the resource tree, the configured permissions can reduce the number of traversed nodes and levels. Furthermore, permission authentication is not required again during traversal, reducing the computational load required for resource statistics and improving statistical efficiency.

[0067] Example 2

[0068] Figure 3This is a schematic diagram of the resource statistics process based on resource tree permissions provided in Embodiment 2 of this application. Embodiment 2 is a further optimization based on Embodiment 1. Specifically, the optimization is as follows: after determining whether a user has permissions to the root node of the resource tree based on at least one role assigned to the user, the method further includes: if no permissions are granted, querying the least weighted subtree in the resource tree; during the statistics process, if the analysis node of the resource tree is the root node of the least weighted subtree, then all nodes of the least weighted subtree are skipped to obtain the resource statistics result. For details not described in this embodiment, please refer to Embodiment 1. Figure 3 As shown, the method includes the following steps:

[0069] S310. Based on the resource's own ID and parent node ID, construct a resource tree consisting of organization nodes and camera nodes.

[0070] S320. Based on at least one role assigned to the user, determine whether the user has permission to the root node of the resource tree.

[0071] S330. If no permission is granted, query the least weighted subtree in the resource tree.

[0072] In a weighted subtree, every node in the subtree that has permissions is considered a weighted subtree. The minimum weighted subtree can be a subtree containing only the current node's descendant nodes, or a subtree containing only the current node. For example, if the parent node Organization 10 has permissions and the child node Camera 17 is an inheriting node, then Organization 10 and Camera 17 form the minimum weighted subtree. Similarly, if the child node Camera 14 has permissions but no parent node, then Camera 14 forms the minimum weighted subtree.

[0073] Understandably, if the root node of the resource tree is configured to have no permissions, due to the permission inheritance principle in the permission rules, then the subtrees or child nodes of the resource tree will all have no permissions, and only a few nodes will be configured to have permissions. In this case, the minimum authorized subtree will be queried in the resource tree.

[0074] Specifically, querying the minimum weighted subtree in the resource tree can be done using both the unweighted list and the weighted list. The weighted list is traversed, and the unweighted list is checked to see if the current node has a descendant node. If a descendant node exists, all subtrees of the current node are traversed. If a subtree is the minimum weighted subtree, the root node of the minimum weighted subtree replaces the current node in the weighted list. If no weighted subtree exists, the weighted node is directly removed from the weighted list.

[0075] Optionally, in this technical solution, querying the minimum weighted subtree in the resource tree includes:

[0076] Retrieve nodes in the resource tree that are configured to have no permissions, and obtain a list of nodes with no permissions; and retrieve nodes in the resource tree that are configured to have permissions, and obtain a list of nodes with permissions.

[0077] For each node in the weighted list, determine whether there is a node in the unweighted list in the subtree of that node;

[0078] If it exists, traverse all subtrees of the current node in the weighted list to obtain the minimum weighted subtree, and replace the current node in the weighted list with the root node of the minimum weighted subtree;

[0079] Traverse all nodes in the weighted list to obtain all the smallest weighted subtrees in the resource tree.

[0080] For example, Figure 4 This is a flowchart of the query minimum weighted subtree provided in Embodiment 2 of this application. For example... Figure 4 As shown, a solid square represents an organization with permissions, a solid rhombus represents an organization without permissions, a right triangle represents a camera without permissions, a solid equilateral triangle represents a camera with permissions, a hollow circle represents an organization whose permissions are inherited from the parent node, and a hollow equilateral triangle represents a camera whose permissions are inherited from the parent node.

[0081] Retrieve all nodes configured with no permissions for this user under the specified statistical nodes, resulting in a list of nodes with no permissions: Camera 5, Organization 7, Organization 8, Camera 14, Organization 9, and Camera 19. Also, retrieve all nodes configured with permissions for this user under the specified statistical nodes, resulting in a list of nodes with permissions: Organization 2, Organization 10, Organization 13, Organization 16, and Camera 4.

[0082] Traverse the weighted list, checking the unweighted list for descendant nodes of the current node. If a descendant node exists, traverse the subtrees under that weighted node. If the subtree is the least weighted subtree, add it to the weighted list and remove the current weighted node from the list. If there is no weighted subtree, remove the node directly from the weighted list. For example, if camera 5 is a descendant node of organization 2 in the unweighted list, then it is necessary to traverse the next level of children of organization 2 to find the least weighted subtree. The steps are as follows:

[0083] Traverse the next level of nodes in organization 2 to obtain camera 5, organization 6, organization 7 and organization 8.

[0084] For organization 6, traversing the unweighted list, no node is a descendant of organization 6, therefore organization 6 is the least weighted subtree. For organization 8, organization 13 is a descendant of organization 8. Traversing the unweighted list, find the least weighted subtree under organization 8, and organization 13 is the least weighted subtree.

[0085] The final result shows that organization 6 and organization 13 are the minimum weighted subtrees, and organization 2 needs to be removed from the weighted list.

[0086] This process continues until all the weighted lists are obtained, with the weighted subtrees being Organization 6, Organization 13, Camera 20, and Camera 4.

[0087] By traversing all nodes in the weighted list, all minimum weighted subtrees in the resource tree are obtained. When performing statistics on camera resources in the resource tree, the configured permissions can reduce the number of nodes and levels traversed. Furthermore, permission authentication is not required during traversal, reducing the computational load for resource statistics and improving efficiency.

[0088] In this technical solution, optionally, the least weighted subtree includes at least one node;

[0089] If the least weighted subtree contains at least two nodes, then all nodes in the least weighted subtree include nodes configured with permissions, or inherited nodes without configured permissions.

[0090] In this embodiment, all nodes in the least weighted subtree have the same permissions. If the least weighted subtree includes two nodes, then the nodes in the least weighted subtree include either the node configured with permissions or the inheriting node without configured permissions. For example, if the least weighted subtree consists of Organization 2, Camera 5, and Organization 6, with parent node Organization 2 configured with permissions, child node Camera 5 configured with permissions, and child node Organization 6 without configured permissions, then child node Organization 6 can be determined as an inheriting node, inheriting the permissions of parent node Organization 2.

[0091] Determining the nodes in the least weighted subtree can reduce the number of nodes and levels traversed. At the same time, permission authentication is not required again during traversal, which reduces the amount of computation required for resource statistics and improves statistical efficiency.

[0092] S340. During the statistical process, if the analysis node of the resource tree is the root node of the least weighted subtree, then all nodes of the least weighted subtree are skipped in the statistics to obtain the resource statistics results.

[0093] Understandably, when the analysis node of the resource tree is the root node of the least weighted subtree, all nodes in that least weighted subtree can be skipped during the statistical process. For example, if the parent node Organization 10 is configured as having permissions and the child node Camera 17 is configured as an inheriting node, Organization 10 and Camera 17 constitute the least weighted node. During the statistical process, Camera 17 can be skipped, and only Organization 10 needs to be counted to obtain the final resource statistics result.

[0094] For example, such as Figure 4As shown, this method retrieves all nodes configured with no permissions under the specified statistical nodes for this user, resulting in the list of no-permission cameras: Camera 5, Organization 7, Organization 8, Camera 14, Organization 9, and Camera 19. The list of authorized cameras is as follows: Organization 2, Organization 10, Organization 13, Organization 16, and Camera 4. The root node of the resource tree has no permissions. Therefore, the method queries the minimum-weighted subtree within the resource tree. During the statistical process, the analysis node of the resource tree is the root node of the minimum-weighted subtree. During the statistical process, nodes Organization 10 and Camera 17 in the minimum-weighted subtree Organization 6, and node Camera 10 in the minimum-weighted subtree Organization 13, can be skipped. The method then calculates the number of authorized cameras and the total number of both authorized and non-authorized cameras.

[0095] The technical solution provided in this application constructs a resource tree consisting of organization nodes and camera nodes based on the resource's own ID and parent node ID. It determines whether the user has permission to the root node of the resource tree based on at least one role assigned to the user. If no permission is granted, the least weighted subtree is queried within the resource tree. During the statistical process, if the analysis node of the resource tree is the root node of the least weighted subtree, all nodes in that least weighted subtree are skipped to obtain the resource statistics result. By implementing this technical solution, when performing statistics on camera resources in the resource tree, the configured permissions can reduce the number of traversed nodes and levels. Furthermore, permission authentication is not required again during traversal, reducing the computational load required for resource statistics and improving statistical efficiency.

[0096] Example 3

[0097] Figure 5 This is a schematic diagram of the resource statistics device based on resource tree permissions provided in Embodiment 3 of this application, as shown below. Figure 5 As shown, the resource statistics device based on resource tree permissions includes:

[0098] The resource tree construction module 510 is used to construct a resource tree consisting of organization nodes and camera nodes based on the resource's own ID and parent node ID.

[0099] The root node permission determination module 520 is used to determine whether a user has permission to the root node of the resource tree based on at least one role assigned to the user.

[0100] The minimum unweighted subtree query module 530 is used to query the minimum unweighted subtree in the resource tree if permissions are available.

[0101] The resource statistics result acquisition module 540 is used in the statistical analysis process. If the current analysis node of the resource tree is the root node of the smallest unweighted subtree, then all nodes of the smallest unweighted subtree are skipped to obtain the resource statistics result.

[0102] Optionally, in this technical solution, the device further includes:

[0103] The minimum weighted subtree query module is used to query the minimum weighted subtree in the resource tree if no permission is granted.

[0104] The minimum weighted subtree node statistics module is used to, during the statistics process, if the analysis node of the resource tree is the root node of the minimum weighted subtree, then skip all nodes of the minimum weighted subtree to obtain the resource statistics results.

[0105] In this technical solution, the optional root node permission judgment module 520 includes:

[0106] A role reading unit is used to read at least one role assigned to a user from the database;

[0107] The root node permission determination unit of the resource tree is used to read the permission information of roles for resources from the resource permission system in order to determine whether all assigned roles have permissions for the root node of the resource tree.

[0108] In this technical solution, the optional minimum unweighted subtree query module 530 includes:

[0109] The list retrieval unit is used to retrieve nodes in the resource tree that are configured to have no permissions, thus obtaining a list of nodes with no permissions; and to retrieve nodes in the resource tree that are configured to have permissions, thus obtaining a list of nodes with permissions.

[0110] The node determination unit in the weighted list is used to determine whether there are any nodes in the weighted list in the subtree of a node in the unweighted list.

[0111] The current node replacement unit in the unweighted list is used to traverse all subtrees of the current node in the unweighted list if it exists, obtain the smallest unweighted subtree, and replace the current node in the unweighted list with the root node of the smallest unweighted subtree.

[0112] The smallest unweighted subtree is obtained by traversing all nodes in the unweighted list to obtain all the smallest unweighted subtrees in the resource tree.

[0113] In this technical solution, optionally, the minimum unweighted subtree includes at least one node;

[0114] If the least unweighted subtree contains at least two nodes, then all nodes in the least unweighted subtree include nodes configured with no permissions, or inherited nodes without configured permissions.

[0115] In this technical solution, the optional least weighted subtree query module includes:

[0116] The list retrieval unit is used to retrieve nodes in the resource tree that are configured to have no permissions, thus obtaining a list of nodes with no permissions; and to retrieve nodes in the resource tree that are configured to have permissions, thus obtaining a list of nodes with permissions.

[0117] The node determination unit in the unweighted list is used to determine whether there are any nodes in the unweighted list in the subtree of a node in the weighted list.

[0118] The current node replacement unit in the weighted list is used to traverse all subtrees of the current node in the weighted list if it exists, obtain the minimum weighted subtree, and replace the current node in the weighted list with the root node of the minimum weighted subtree.

[0119] The minimum weighted subtree is used to traverse all nodes in the weighted list to obtain all minimum weighted subtrees in the resource tree.

[0120] In this technical solution, optionally, the least weighted subtree includes at least one node;

[0121] If the least weighted subtree contains at least two nodes, then all nodes in the least weighted subtree include nodes configured with permissions, or inherited nodes without configured permissions.

[0122] The above-mentioned products can perform the methods provided in the embodiments of this application, and have the corresponding functional modules and beneficial effects of performing the methods.

[0123] Example 4

[0124] Embodiment 4 of this application also provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform a resource statistics method based on resource tree permissions. The method includes:

[0125] Construct a resource tree consisting of organization nodes and camera nodes based on the resource's own ID and parent node ID;

[0126] Based on at least one role assigned to the user, determine whether the user has permission to the root node of the resource tree;

[0127] If permission is granted, then query the smallest unweighted subtree in the resource tree;

[0128] During the statistical analysis, if the current analysis node of the resource tree is the root node of the smallest unweighted subtree, then all nodes of the smallest unweighted subtree are skipped to obtain the resource statistics results.

[0129] Storage medium refers to any type of memory electronic device or storage electronic device. The term "storage medium" is intended to include: mounting media, such as CD-ROMs, floppy disks, or magnetic tape devices; computer system memory or random access memory, such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media (e.g., hard disks or optical storage); registers or other similar types of memory elements. Storage medium may also include other types of memory or combinations thereof. Furthermore, storage medium may reside in a computer system in which a program is executed, or it may reside in a different second computer system connected to the computer system via a network (such as the Internet). The second computer system can provide program instructions to the computer for execution. The term "storage medium" can include two or more storage media that may reside in different unknowns (e.g., in different computer systems connected via a network). Storage medium may store program instructions (e.g., specifically implemented as a computer program) that can be executed by one or more processors.

[0130] Of course, the computer-executable instructions provided in the embodiments of this application are not limited to the resource statistics method operation based on resource tree permissions as described above, but can also execute related operations in the resource statistics method based on resource tree permissions provided in any embodiment of this application.

[0131] Example 5

[0132] This application provides an electronic device that can integrate the resource statistics device based on resource tree permissions provided in this application. The electronic device can be configured within the system or can be a device that performs some or all of the functions within the system. Figure 6 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of this application. Figure 6 As shown, this embodiment provides an electronic device 600, which includes: one or more processors 620; and a storage device 610 for storing one or more programs. When the one or more programs are executed by the one or more processors 620, the one or more processors 620 implement the resource statistics method based on resource tree permissions provided in this application embodiment. The method includes:

[0133] Construct a resource tree consisting of organization nodes and camera nodes based on the resource's own ID and parent node ID;

[0134] Based on at least one role assigned to the user, determine whether the user has permission to the root node of the resource tree;

[0135] If permission is granted, then query the smallest unweighted subtree in the resource tree;

[0136] During the statistical analysis, if the current analysis node of the resource tree is the root node of the smallest unweighted subtree, then all nodes of the smallest unweighted subtree are skipped to obtain the resource statistics results.

[0137] Of course, those skilled in the art will understand that the processor 620 also implements the technical solution of the resource statistics method based on resource tree permissions provided in any embodiment of this application.

[0138] Figure 6 The electronic device 600 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0139] like Figure 6 As shown, the electronic device 600 includes a processor 620, a storage device 610, an input device 630, and an output device 640; the number of processors 620 in the electronic device can be one or more. Figure 6 Taking a processor 620 as an example; the processor 620, storage device 610, input device 630, and output device 640 in the electronic device can be connected via a bus or other means. Figure 6 Taking the connection between China and Israel via bus 650 as an example.

[0140] Storage device 610, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and module units, such as the program instructions corresponding to the resource statistics method based on resource tree permissions in the embodiments of this application.

[0141] Storage device 610 may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a function; the data storage area may store data created based on terminal usage. Furthermore, storage device 610 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, storage device 610 may further include memory remotely located relative to processor 620, and these remote memories can be connected via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0142] Input device 630 can be used to receive input digital, character, or voice information, and to generate key signal inputs related to user settings and function control of the electronic device. Output device 640 may include electronic devices such as a display screen and a speaker.

[0143] The electronic device provided in this application embodiment can reduce the number of nodes and levels traversed, and at the same time, it does not need to perform permission judgment again during traversal, thereby reducing the calculation required for resource statistics and improving statistical efficiency.

[0144] The resource statistics device, medium, and electronic device based on resource tree permissions provided in the above embodiments can execute the resource statistics method based on resource tree permissions provided in any embodiment of this application, and have the corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in the above embodiments can be found in the resource statistics method based on resource tree permissions provided in any embodiment of this application.

[0145] Note that the above are merely preferred embodiments and the technical principles employed in this application. Those skilled in the art will understand that this application is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of this application. Therefore, although this application has been described in detail through the above embodiments, this application is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of this application, the scope of which is determined by the scope of the appended claims.

Claims

1. A method for resource statistics based on resource tree permissions, characterized in that, The method comprises: According to the self ID and the parent node ID of the resource, a resource tree composed of organization nodes and camera nodes is constructed; According to at least one role assigned to the user, it is judged whether the user has the right to the root node of the resource tree; If there is the right, the minimum unauthorized subtree in the resource tree is queried; In the statistical analysis process, if the current analysis node of the resource tree is the root node of the minimum unauthorized subtree, all nodes of the minimum unauthorized subtree are skipped to obtain the resource statistical result; Wherein, the self ID of the resource is the address of the resource, and the parent node is the upper level of the resource in the resource tree; Wherein, the minimum unauthorized subtree in the resource tree is queried, including: Obtain the nodes configured as unauthorized in the resource tree to obtain the unauthorized list; and obtain the nodes configured as authorized in the resource tree to obtain the authorized list; For the nodes in the unauthorized list, it is judged whether there are nodes in the authorized list in the subtree of the node; If there is, all subtrees of the current node in the unauthorized list are traversed to obtain the minimum unauthorized subtree, and the root node of the minimum unauthorized subtree is replaced with the current node in the unauthorized list; All nodes in the unauthorized list are traversed to obtain all minimum unauthorized subtrees in the resource tree.

2. The method of claim 1, wherein, After judging whether the user has the right to the root node of the resource tree according to at least one role assigned to the user, the method further comprises: If there is no right, the minimum authorized subtree in the resource tree is queried; In the statistical process, if the analysis node of the resource tree is the root node of the minimum authorized subtree, all nodes of the minimum authorized subtree are skipped to obtain the resource statistical result.

3. The method of claim 2, wherein, The minimum authorized subtree in the resource tree is queried, including: Obtain the nodes configured as unauthorized in the resource tree to obtain the unauthorized list; and obtain the nodes configured as authorized in the resource tree to obtain the authorized list; For the nodes in the authorized list, it is judged whether there are nodes in the unauthorized list in the subtree of the node; If there is, all subtrees of the current node in the authorized list are traversed to obtain the minimum authorized subtree, and the root node of the minimum authorized subtree is replaced with the current node in the authorized list; All nodes in the authorized list are traversed to obtain all minimum authorized subtrees in the resource tree.

4. The method of claim 3, wherein, The minimum authorized subtree comprises at least one node; If the minimum authorized subtree comprises at least two nodes, all nodes in the minimum authorized subtree comprise nodes configured as authorized or nodes without configured authorization.

5. The method of claim 1, wherein, According to at least one role assigned to the user, it is judged whether the user has the right to the root node of the resource tree, including: Read at least one role assigned to the user from the database; Read the authorization information of the role to the resource from the resource authorization system to determine whether all assigned roles have the right to the root node of the resource tree.

6. The method of claim 1, wherein, The minimum unauthorized subtree comprises at least one node; If the minimum unauthorized subtree comprises at least two nodes, all nodes in the minimum unauthorized subtree comprise nodes configured as unauthorized or nodes without configured authorization.

7. A resource statistics device based on resource tree permissions, characterized by, The device comprises: The resource tree construction module is configured to construct a resource tree composed of organization nodes and camera nodes according to the self ID and the parent node ID of the resource. The root node permission judgment module is configured to judge whether the user has permission to the root node of the resource tree according to at least one role assigned to the user. The minimum powerless subtree query module is configured to query a minimum powerless subtree in the resource tree if the user has permission. The resource statistical result obtaining module is configured to skip all nodes of the minimum powerless subtree if the current analysis node of the resource tree is the root node of the minimum powerless subtree during the statistical analysis process, so as to obtain a resource statistical result. The self ID of the resource is an address of the resource, and the parent node is an upper level of the resource in the resource tree. The minimum powerless subtree query module includes: A list obtaining unit is configured to obtain nodes configured as powerless in the resource tree to obtain a powerless list, and obtain nodes configured as powerful in the resource tree to obtain a powerful list. A node judgment unit in the powerful list is configured to judge whether there is a node in the powerful list in the subtree of a node in the powerless list. A current node replacement unit in the powerless list is configured to traverse all subtrees of the current node in the powerless list to obtain a minimum powerless subtree and replace the current node in the powerless list with the root node of the minimum powerless subtree if there is. A minimum powerless subtree obtaining unit is configured to traverse all nodes in the powerless list to obtain all minimum powerless subtrees in the resource tree.

8. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the resource statistical method based on the resource tree permission according to any one of claims 1-6.

9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to implement the resource statistical method based on the resource tree permission according to any one of claims 1-6.

Citation Information

Patent Citations

  • Method and system for displaying webpage, and server

    CN102411575A