Role authority configuration method, device, equipment and storage medium
By identifying and reorganizing the target nodes in the menu tree in the permission management system and combining it with the matching of the role permission tree, the problem of low efficiency in role permission configuration after menu reconstruction is solved, and intelligent updating and efficient configuration are achieved.
Patent Information
- Application Number
- CN202411171973.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2044-08-23
AI Technical Summary
When the menu function module of the existing permission management system is reconstructed, the role permission configuration efficiency is low, and the permissions of each role need to be manually changed, resulting in low configuration efficiency.
By obtaining the first menu tree before reconstruction and the second menu tree after reconstruction, the modified target child nodes and target leaf nodes are identified, and the first menu tree is reorganized based on these nodes to generate a third menu tree. Then, the third menu tree is matched from bottom to top according to the leaf nodes in the first role permission tree to generate a second role permission tree.
It realizes intelligent update of role permission tree after menu tree reconstruction, simplifies role permission configuration operation, greatly improves configuration efficiency, and avoids manual changes of permissions for each role.
Smart Images

Figure CN119128842B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data updating, and in particular to a method, apparatus, device and storage medium for configuring role permissions. Background Art
[0002] Currently, updates to the permissions management system are closely tied to company personnel changes. Personnel changes within different departments and positions require the isolation and updating of user permissions within the permissions management system. In the current permissions management system, reclassifying and refactoring menu functional modules requires manually changing the permissions of each role to reflect the new menu permissions, resulting in inefficient configuration. Therefore, improving the efficiency of role-based permissions configuration is a pressing issue. Summary of the Invention
[0003] The main purpose of this application is to provide a role authority configuration method, device, equipment and storage medium, aiming to improve the configuration efficiency of role authority.
[0004] In a first aspect, the present application provides a method for configuring role permissions, comprising:
[0005] Acquire a first menu tree and a second menu tree; wherein the first menu tree is the original menu tree before reconstruction, and the second menu tree is the desired menu tree after reconstruction;
[0006] Matching the first menu tree with the second menu tree to identify target child nodes and target leaf nodes where modifications are made;
[0007] Based on the target child node and the target leaf node, the first menu tree is reorganized to obtain a third menu tree;
[0008] Obtaining a first role permission tree, where the first role permission tree is used to represent the original permissions of the set role before the first menu tree is reconstructed, and the first role permission tree includes some child nodes and some leaf nodes in the first menu tree;
[0009] According to the leaf nodes in the first role permission tree, the third menu tree is matched from bottom to top to obtain the second role permission tree; the second role permission tree is used to represent the target permissions of the set role after the first menu tree is reconstructed, and the second role permission tree includes some child nodes and some leaf nodes in the third menu tree.
[0010] In a second aspect, the present application further provides a role authority configuration device, the role authority configuration device comprising:
[0011] An acquisition module, configured to acquire a first menu tree and a second menu tree; wherein the first menu tree is the original menu tree before reconstruction, and the second menu tree is the desired menu tree after reconstruction;
[0012] a matching module, configured to match the first menu tree with the second menu tree to identify target child nodes and target leaf nodes that have been modified;
[0013] a reorganization module, configured to reorganize the first menu tree based on the target child node and the target leaf node to obtain a third menu tree;
[0014] The acquisition module is further configured to acquire a first role permission tree, wherein the first role permission tree is used to represent the original permissions of the set role before the first menu tree is reconstructed, and the first role permission tree includes some child nodes and some leaf nodes in the first menu tree;
[0015] The matching module is also used to match the third menu tree from bottom to top according to the leaf nodes in the first role permission tree to obtain a second role permission tree; the second role permission tree is used to represent the target permissions of the set role after the first menu tree is reconstructed, and the second role permission tree includes some child nodes and some leaf nodes in the third menu tree.
[0016] In a third aspect, the present application also provides a computer device comprising a processor, a memory, and a computer program stored on the memory and executable by the processor, wherein when the computer program is executed by the processor, the role authority configuration method as described in the embodiment of the present application is implemented.
[0017] In a fourth aspect, the present application also provides a computer-readable storage medium, on which a computer program is stored, wherein when the computer program is executed by a processor, the role authority configuration method as described in the embodiment of the present application is implemented.
[0018] The present application provides a role permission configuration method, which matches the first menu tree before reconstruction with the second menu tree after reconstruction to identify the target child node and target leaf node that have been modified; then the first menu tree is reorganized based on the target child node and the target leaf node to obtain a third menu tree; then the first role permission tree for characterizing the original permissions of the set role before reconstruction is obtained, and the third menu tree is matched from bottom to top according to the leaf nodes in the first role permission tree to obtain a second role permission tree for characterizing the set role after reconstruction, wherein the second role permission tree includes some child nodes and some leaf nodes in the third menu tree. Therefore, the present application can intelligently implement the update of the role permission tree after the menu tree is reconstructed, thereby simplifying the configuration operation of the role permissions. At the same time, there is no need to manually change the permissions of each role corresponding to the permissions of the new menu, thereby greatly improving the configuration efficiency of the role permissions. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the description of the embodiments. 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 any creative work.
[0020] Figure 1 A schematic diagram of the steps of a role authority configuration method provided in an embodiment of the present application;
[0021] Figure 2 A schematic diagram of a first menu tree provided in an embodiment of the present application;
[0022] Figure 3 A schematic diagram of a second menu tree provided in an embodiment of the present application;
[0023] Figure 4 A schematic diagram of a fourth menu tree provided in an embodiment of the present application;
[0024] Figure 5 A schematic block diagram of a device for configuring role permissions provided in an embodiment of the present application;
[0025] Figure 6 A schematic block diagram of another device for configuring role permissions provided in an embodiment of the present application;
[0026] Figure 7 A schematic block diagram of the structure of a computer device provided in an embodiment of the present application.
[0027] The realization of the objectives, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0029] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, combined, or partially merged, so the actual execution order may vary depending on the actual situation.
[0030] The embodiments of the present application provide a method, apparatus, device, and storage medium for configuring role permissions. The method can be applied to a terminal device or server. The terminal device can be an electronic device such as a mobile phone, tablet computer, laptop computer, desktop computer, personal digital assistant, or wearable device. The server can be a single server or a server cluster consisting of multiple servers. The following explanation will be given using the application of the method to a server as an example.
[0031] The following describes some embodiments of the present application in detail with reference to the accompanying drawings. In the absence of conflict, the following embodiments and features therein may be combined with each other.
[0032] Please refer to Figure 1 , Figure 1 A flowchart illustrating the steps of a method for configuring role permissions provided in an embodiment of the present application.
[0033] like Figure 1 As shown, the role authority configuration method includes steps S101 to S105.
[0034] Step S101: Acquire a first menu tree and a second menu tree; wherein the first menu tree is the original menu tree before reconstruction, and the second menu tree is the desired menu tree after reconstruction.
[0035] Among them, the first menu tree and the second menu tree are tree structure data, and the first menu tree and the second menu tree both include multiple child nodes (Branch Node) and multiple leaf nodes (Leaf Node). A child node refers to a node whose degree is not 0, also called a non-terminal node or an internal node. A leaf node refers to a node whose degree is 0, also called a terminal node. For the permission management system, the child nodes and leaf nodes in the first menu tree and the second menu tree are respectively used to represent permissions at different levels.
[0036] It should be noted that the second menu tree is obtained by the user reconstructing the child nodes and leaf nodes in the first menu tree. The first menu tree and the second menu tree can be exported from the rights management system using a dedicated tool. The data format of the exported first menu tree and the second menu tree can be Excel, YAML (YAML Ain't Markup Language, another markup language), etc.
[0037] In some cases, users need to restructure the menu's functional modules. This restructure includes changing the hierarchy, renaming, deleting, or adding child or leaf nodes. Therefore, the original menu tree refers to the menu tree configured before the restructure, and the expected menu tree refers to the menu tree expected to be configured after the restructure.
[0038] In one embodiment, a first menu tree is displayed, comprising a plurality of child nodes and a plurality of leaf nodes. A second menu tree is obtained based on a user's reconfiguration of the child nodes and leaf nodes in the first menu tree. The reconfiguration operation includes modifying the hierarchy, renaming, deleting, or adding new child nodes or leaf nodes. Therefore, the user only needs to configure the desired second menu tree based on the first menu tree, thereby conveniently modifying the original menu tree according to actual needs, thereby converting the original menu tree into the desired menu tree.
[0039] For example, Figure 2 As shown, Figure 2 This is a schematic diagram of the first menu tree before reconstruction. The first menu tree includes multiple child nodes or multiple leaf nodes corresponding to the three levels of authority. Among them, the child node corresponding to the first-level authority is "Homepage". The child nodes corresponding to the second-level authority are "Institutional Risk Profile", "Warning Rating" and "Industry Risk Profile". The leaf nodes corresponding to the third-level authority include "Risk Profile" and "Indicator Management" corresponding to "Institutional Risk Profile", "Indicator Management" corresponding to "Warning Rating", and "Risk Profile" and "Indicator Management" corresponding to "Industry Risk Profile".
[0040] For example, Figure 3 As shown, Figure 3 The following is a schematic diagram of the reconstructed second menu tree. The second menu tree includes multiple sub-nodes or leaf nodes corresponding to the three levels of permissions. The sub-node corresponding to the first-level permission is "Home." The sub-nodes corresponding to the second-level permission are "Organization Profile," "Special Risk," and "Warning Profile." The leaf nodes corresponding to the third-level permission include "Risk Profile" and "Indicator Management" for "Organization Profile," "Reputation Risk Profile" for "Special Risk," and "Warning Rating" and "Indicator Management" for "Warning Profile."
[0041] Step S102: Match the first menu tree with the second menu tree to identify target child nodes and target leaf nodes that have been modified.
[0042] The first menu tree and the second menu tree each include a plurality of child nodes and a plurality of leaf nodes, and the second menu tree may be obtained by reconstructing the child nodes and leaf nodes in the first menu tree. Therefore, matching the first menu tree with the second menu tree may be performed by matching the plurality of child nodes and leaf nodes in the first menu tree with the plurality of child nodes and leaf nodes in the second menu tree, thereby obtaining target child nodes and target leaf nodes that are modified compared to the first menu tree.
[0043] In one embodiment, the first menu tree is matched with the second menu tree to identify modified target child nodes and target leaf nodes, including: matching multiple child nodes and leaf nodes in the first menu tree and the second menu tree to obtain matching results; obtaining newly added, modified, renamed, and deleted child nodes as target child nodes based on the matching results, and obtaining newly added, modified, renamed, and deleted leaf nodes as target leaf nodes based on the matching results.
[0044] The matching method between child nodes and leaf nodes can be based on unique identification numbers, corresponding permission names, or the level at which the nodes are located, which is not specifically limited in the embodiments of the present application. The matching results may include the same unique identification numbers, different unique identification numbers, the same permission names, different permission names, the same level, different levels, etc.
[0045] It should be noted that, based on the matching results, subnodes and leaf nodes that have been modified, renamed, or deleted can be identified and determined as target subnodes and target leaf nodes that have been modified. For example, subnodes or leaf nodes with the same unique identification number but different levels are the target subnodes and target leaf nodes that have been modified, respectively; subnodes or leaf nodes with the same unique identification number but inconsistent permission names are the target subnodes and target leaf nodes that have been renamed, respectively.
[0046] Exemplarily, there may be multiple matching results, and the newly added and deleted target child nodes and target leaf nodes may be determined based on the multiple matching results. Specifically, it may be determined based on the multiple matching results whether a certain unique identification number exists in the first menu tree, and whether a certain unique identification number exists in the second menu tree, thereby determining the newly added and deleted target child nodes and target leaf nodes. In some cases, a child node or leaf node having a certain unique identification number in the first menu tree and not in the second menu tree is the deleted target child node and target leaf node, respectively. A child node or leaf node having a certain unique identification number that does not exist in the first menu tree and exists in the second menu tree is the added target child node and target leaf node, respectively.
[0047] In one embodiment, the first menu tree is matched with the second menu tree to identify modified target child nodes and target leaf nodes, including: matching each child node in the first menu tree with multiple child nodes and leaf nodes in the second menu tree to obtain modified, renamed, and deleted target child nodes and unmodified child nodes; and matching each leaf node in the first menu tree with multiple child nodes and leaf nodes in the second menu tree to obtain modified, renamed, and deleted target leaf nodes and unmodified leaf nodes; based on the target child nodes, unmodified child nodes, target leaf nodes, and unmodified leaf nodes, newly added target child nodes and newly added target leaf nodes are determined from multiple child nodes and multiple leaf nodes in the second menu tree.
[0048] It should be noted that each child node in the first menu tree is matched with multiple child nodes and leaf nodes in the second menu tree, and each leaf node in the first menu tree is matched with multiple child nodes and leaf nodes in the second menu tree, so as to identify the target child nodes with modified levels, renamed, deleted and unmodified child nodes, and identify the target leaf nodes with modified levels, renamed, deleted and unmodified leaf nodes. After determining that there are modified target child nodes, target leaf nodes and unmodified child nodes and unmodified leaf nodes, the remaining child nodes in the second menu tree are newly added target child nodes, and the remaining leaf nodes in the second menu tree are newly added target leaf nodes. In this way, the target child nodes and target leaf nodes with modified levels can be accurately identified.
[0049] Exemplarily, each child node in the first menu tree is matched with multiple child nodes and leaf nodes in the second menu tree to obtain a target child node to be renamed, including: obtaining the first permission name and first identification number of each child node in the first menu tree, and obtaining the second permission name and second identification number of multiple child nodes and leaf nodes in the second menu tree; matching the first identification number of each child node in the first menu tree with multiple second identification numbers in the second menu tree to determine a target identification number from each first identification number, and matching the target identification number with the second identification number; comparing the first permission name corresponding to the target identification number with the second permission name, and determining each child node corresponding to the target identification number that is inconsistent in the comparison as the target child node to be renamed.
[0050] It should be noted that when matching the first menu tree with the second menu tree, the matching can be based on the unique identification number, permission name, hierarchy and other features of each child node and each leaf node. For example, when identifying the target child node to be renamed, the first identification number of each child node in the first menu tree can be matched with multiple second identification numbers in the second menu tree, so as to identify the target identification number that matches the second identification number from each first identification number, and determine the child node whose first permission name of the target identification number is inconsistent with the second permission name as the target child node to be renamed. In this way, the target child node that has been renamed can be accurately identified.
[0051] It can be understood that the relevant steps of "matching each leaf node in the first menu tree with multiple sub-nodes and leaf nodes in the second menu tree to obtain the target leaf node to be renamed" in the above embodiment can refer to the corresponding process of the relevant examples to accurately identify the target leaf node to be renamed, and the embodiments of the present application will not go into details about this.
[0052] In one embodiment, the first menu tree is matched with the second menu tree to identify modified target child nodes and target leaf nodes, including: matching each child node in the second menu tree with multiple child nodes and leaf nodes in the first menu tree to obtain modified, renamed, and newly added target child nodes and unmodified child nodes; and matching each leaf node in the second menu tree with multiple child nodes and leaf nodes in the first menu tree to obtain modified, renamed, and newly added target leaf nodes and unmodified leaf nodes; determining the deleted target child nodes and deleted target leaf nodes from multiple child nodes and multiple leaf nodes in the first menu tree based on the target child nodes, unmodified child nodes, target leaf nodes, and unmodified leaf nodes.
[0053] It should be noted that each child node in the second menu tree is matched with multiple child nodes and leaf nodes in the first menu tree, and each leaf node in the second menu tree is matched with multiple child nodes and leaf nodes in the first menu tree, so that the target child nodes with modified levels, renamed, and newly added, as well as the unmodified child nodes, can be identified, as well as the target leaf nodes with modified levels, renamed, and newly added, as well as the unmodified leaf nodes. After determining that there are modified target child nodes, target leaf nodes, and unmodified child nodes and unmodified leaf nodes, the remaining child nodes in the first menu tree are the target child nodes to be deleted, and the remaining leaf nodes in the first menu tree are the target leaf nodes to be deleted. In this way, the target child nodes and target leaf nodes that have been modified can be accurately identified.
[0054] In one embodiment, when matching the first menu tree with the second menu tree, it is checked whether there are child nodes or leaf nodes that cannot be uniquely determined; if so, an abnormal prompt message is generated and output, which is used to prompt the administrator to specify a unique child node or leaf node.
[0055] Among them, the uniquely determined child node or leaf node can refer to a child node or leaf node with the same permission name but no unique identification number, or can also refer to a child node or leaf node that cannot be uniquely locked according to the hierarchy. The embodiments of the present application do not make specific restrictions on this. Through the abnormal prompt information, when an abnormality occurs in a child node or leaf node, it can be uniformly handled, greatly improving the processing efficiency of the permission configuration process.
[0056] Step S103: reorganize the first menu tree based on the target child node and the target leaf node to obtain a third menu tree.
[0057] Since the target child nodes and target leaf nodes are modified child nodes and leaf nodes obtained by reconstruction based on the first menu tree, in order to subsequently clarify the relationship between the role authority-related nodes before and after the reconstruction, it is necessary to reorganize the first menu tree based on the target child nodes and target leaf nodes, thereby obtaining a third menu tree that can represent the node changes before and after the reconstruction of the first menu tree.
[0058] It should be noted that when the first menu tree is reorganized, it can be based on a set logic. The set logic can, for example, be to add, then rename and relevel, and finally delete, thereby obtaining a reorganized third menu tree. This third menu tree is used to associate the subsequent first role permission tree and second role permission tree, so that the original permissions of the set role before the reconstruction can be converted into the target permissions after the reconstruction.
[0059] In one embodiment, the first menu tree is reorganized based on the target sub-nodes and target leaf nodes to obtain a third menu tree, including: adding newly added target sub-nodes and target leaf nodes to the first menu tree to obtain a first sub-expected menu tree; based on the target sub-nodes and target leaf nodes of the modified hierarchy, hierarchical modification is performed on the corresponding nodes in the first sub-expected menu tree to obtain a second sub-expected menu tree; based on the renamed target sub-nodes and target leaf nodes, the corresponding nodes in the second sub-expected menu tree are renamed to obtain a third sub-expected menu tree; based on the deleted target sub-nodes and target leaf nodes, a deletion operation is performed on the corresponding nodes in the third sub-expected menu tree to obtain a third menu tree.
[0060] It should be noted that the first menu tree is reorganized based on the set logic, that is, multiple child nodes and leaf nodes in the first menu tree are added, the level is modified, the name is changed, and the deletion operation is performed, so as to obtain the third menu tree. In some cases, the set logic can be flexibly adjusted, for example, the name can be changed first, the level can be modified, and then the addition and deletion operations can be performed. The embodiment of the present application does not make specific limitations on this. It is understandable that by reorganizing the first menu tree with the set logic of adding, modifying the level, changing the name, and deleting operations, the generation efficiency of the third menu tree can be improved.
[0061] In one embodiment, the role permission configuration method further includes: based on the target child node and the target leaf node, identifying the first menu tree to obtain a fourth menu tree, and displaying the fourth menu tree. Specifically, in the first menu tree, newly added, modified, renamed, or deleted target child nodes and target leaf nodes are all identified.
[0062] The identification methods of each newly added, level-modified, renamed, or deleted target child node and target leaf node can be different and flexibly set, and then the fourth menu tree is displayed. By clearly identifying the newly added, level-modified, renamed, or deleted nodes, it is convenient for the administrator to confirm whether the reconstructed expected menu tree is the desired effect. The administrator can clearly compare the new and old menus to confirm which nodes have been changed, prevent misoperation, and thus improve accuracy.
[0063] For example, Figure 4 As shown, Figure 4 This is a diagram of the fourth menu tree. The blue background (the darkest background in the diagram) indicates the newly added target sub-node, the yellow background (the darkest background in the diagram) indicates the renamed target sub-node, the original permission name is in [], the bold font indicates that the level has changed, and the unique identification number is in brackets. Figure 2 、 Figure 3 The new and old menu trees are compared. Figure 4The fourth menu tree shown is very intuitive, allowing users to clearly understand their modifications and avoid omissions.
[0064] Step S104: Obtain a first role permission tree, where the first role permission tree is used to represent the original permissions of the set role before the first menu tree is reconstructed.
[0065] Among them, the first role permission tree includes some child nodes and some leaf nodes in the first menu tree, that is, the first role permission tree belongs to the part of the first menu tree. It can be understood that multiple role permission trees for set roles can be set in the permission management system, and the first role permission tree can be the role permission tree of any set role among the multiple set roles.
[0066] In one embodiment, after obtaining the first role permission tree, it also includes: parsing whether there are missing leaf nodes in the first role permission tree; when there are missing leaf nodes in the first role permission tree, clearing the child nodes corresponding to the missing leaf nodes.
[0067] It should be noted that in the first role permission tree, if there is a missing leaf node, it means that the child node corresponding to the missing leaf node is invalid data and needs to be cleared, so as to prevent the permission that has not been set or revoked by the role from being granted in subsequent steps.
[0068] Step S105: Match the third menu tree from bottom to top according to the leaf nodes in the first role permission tree to obtain a second role permission tree; the second role permission tree is used to represent the target permission of the set role after the first menu tree is reconstructed.
[0069] Among them, the second role permission tree includes some child nodes and some leaf nodes in the third menu tree, that is, the second role permission tree belongs to the part of the third menu tree. Bottom-up matching refers to the matching order from the leaf nodes of the third menu tree to the child nodes corresponding to the leaf nodes. After the original menu tree is reconstructed, it indicates that some child nodes and some leaf nodes in the first menu tree and the second menu tree have been modified. At this time, there are usually differences between the second role permission tree and some child nodes and some leaf nodes in the first role permission tree.
[0070] Therefore, based on the leaf nodes in the first role permission tree, the third menu tree is matched from bottom to top to obtain the second role permission tree. This intelligently updates the role permission tree for the set role, simplifying the configuration of role permissions. At the same time, there is no need to manually change the permissions of each role to correspond to the permissions of the new menu, thus greatly improving the efficiency of role permission configuration.
[0071] It can be understood that when there are multiple set roles, the embodiment of the present application supports batch modification of the role permission tree of different set roles, thereby intelligently realizing the permission change of multiple set roles, without the need to manually change the permission of each role corresponding to the permission modification of the new menu tree, thereby greatly improving the configuration efficiency of role permissions.
[0072] In one embodiment, the third menu tree is matched from bottom to top based on the leaf nodes in the first role permission tree to obtain the second role permission tree, including: matching each leaf node in the first role permission tree with each leaf node in the third menu tree, thereby determining a candidate leaf node in the third menu tree, and the candidate leaf node matches the child node in the first role permission tree; determining in the third menu tree the candidate child node corresponding to the candidate leaf node in the third menu tree; and determining the second role permission tree based on the candidate leaf nodes and candidate child nodes in the third menu tree.
[0073] It should be noted that after obtaining the first role permission tree, the leaf nodes in the first role permission tree are matched with the leaf nodes in the third menu tree, and the permissions of the set role in the third menu tree are determined from bottom to top to obtain the second role permission tree, so that the role permission tree can be updated intelligently without manually changing the permissions of each role to correspond to the permissions of the new menu, which simplifies the configuration operation of role permissions and greatly improves the configuration efficiency of role permissions.
[0074] In one embodiment, the method also includes: obtaining a first personalized permission tree, the first personalized permission tree is used to represent the original permissions of the set character before the first menu tree is reconstructed, and the first personalized permission tree includes some child nodes and some leaf nodes in the first role permission tree; according to the leaf nodes in the first personalized permission tree, the third menu tree is matched from bottom to top to obtain a second personalized permission tree; the second personalized permission tree is used to represent the target permissions of the set character after the first menu tree is reconstructed, and the second personalized permission tree includes some child nodes and some leaf nodes in the third menu tree.
[0075] The "set persona" is a specific person within the set role. The set role can refer to a job role, and the "set persona" can be a specific person within the job role. The permissions of the set persona and the set role can be the same or different, so the personalized permission tree for the set persona and the role permission tree for the set role can also be the same or different. In some cases, the personalized permission tree for the set persona and the role permission tree for the set role are different. Therefore, after configuring the role permission tree, you also need to configure the personalized permission tree.
[0076] It should be noted that the first personalized permission tree includes some child nodes and some leaf nodes in the first role permission tree, and the second personalized permission tree includes some child nodes and some leaf nodes in the third menu tree. By performing a bottom-up matching of the third menu tree according to the leaf nodes in the first personalized permission tree, the second personalized permission tree can be accurately and quickly obtained. The bottom-up matching process can refer to the corresponding process of generating the second role permission tree, and the embodiments of the present application do not specifically limit this.
[0077] In one embodiment, after obtaining the second role permission tree, a refresh system operation is performed to clear the system cache so that the second role permission tree can take effect immediately, thereby improving the reliability of the role permission configuration operation.
[0078] In one embodiment, the first menu tree is backed up so that when the user is not satisfied with the second menu tree or the second role permission tree, the first menu tree can still be rolled back, thereby improving the security of the configuration operation of the role permission.
[0079] It should be noted that in order to further ensure the privacy and security of the above-mentioned first role permission tree, second role permission tree and other related information, the above-mentioned first role permission tree, second role permission tree and other related information can also be stored in a node of a blockchain. The technical solution of this application can also be applied to adding other data files stored on the blockchain. The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
[0080] The role permission configuration method provided by the above embodiment matches the first menu tree before reconstruction with the second menu tree after reconstruction, thereby identifying the target child node and target leaf node that have been modified; then the first menu tree is reorganized based on the target child node and the target leaf node to obtain a third menu tree; then the first role permission tree for characterizing the original permissions of the set role before reconstruction is obtained, and the third menu tree is matched from bottom to top according to the leaf nodes in the first role permission tree to obtain a second role permission tree for characterizing the set role after reconstruction, wherein the second role permission tree includes some child nodes and some leaf nodes in the third menu tree. Therefore, the present application can intelligently implement the update of the role permission tree after the menu tree is reconstructed, thereby simplifying the configuration operation of the role permissions. At the same time, there is no need to manually change the permissions of each role corresponding to the permissions of the new menu, thereby greatly improving the configuration efficiency of the role permissions.
[0081] Please refer to Figure 5 , Figure 5 A schematic block diagram of a role authority configuration device provided in an embodiment of the present application.
[0082] like Figure 5As shown, the role authority configuration device 200 includes:
[0083] An acquisition module 201 is configured to acquire a first menu tree and a second menu tree; wherein the first menu tree is the original menu tree before reconstruction, and the second menu tree is the desired menu tree after reconstruction;
[0084] A matching module 202 is configured to match the first menu tree with the second menu tree to identify target child nodes and target leaf nodes that have been modified;
[0085] A reorganization module 203 is configured to reorganize the first menu tree based on the target child node and the target leaf node to obtain a third menu tree;
[0086] The acquisition module 201 is further configured to acquire a first role permission tree, wherein the first role permission tree is used to represent the original permissions of the set role before the first menu tree is reconstructed, and the first role permission tree includes some child nodes and some leaf nodes in the first menu tree;
[0087] The matching module 202 is also used to match the third menu tree from bottom to top according to the leaf nodes in the first role permission tree to obtain a second role permission tree; the second role permission tree is used to represent the target permissions of the set role after the first menu tree is reconstructed, and the second role permission tree includes some child nodes and some leaf nodes in the third menu tree.
[0088] In one embodiment, the matching module 202 is further configured to:
[0089] Matching the first menu tree with the plurality of child nodes and leaf nodes in the second menu tree to obtain a matching result;
[0090] According to the matching result, the newly added, modified, renamed, and deleted child nodes are obtained as the target child nodes, and the newly added, modified, renamed, and deleted leaf nodes are obtained according to the matching result as the target leaf nodes.
[0091] In one embodiment, the matching module 202 is further configured to:
[0092] Matching each child node in the first menu tree with multiple child nodes and leaf nodes in the second menu tree to obtain target child nodes with modified levels, renamed, or deleted, as well as unmodified child nodes; and
[0093] Matching each leaf node in the first menu tree with multiple child nodes and leaf nodes in the second menu tree to obtain target leaf nodes that have been modified in level, renamed, or deleted, as well as unmodified leaf nodes;
[0094] According to the target child node, the unmodified child node, the target leaf node and the unmodified leaf node, a newly added target child node and a newly added target leaf node are determined from multiple child nodes and multiple leaf nodes in the second menu tree.
[0095] In one embodiment, the matching module 202 is further configured to:
[0096] Obtaining a first permission name and a first identification number of each child node in the first menu tree, and obtaining a second permission name and a second identification number of multiple child nodes and leaf nodes in the second menu tree;
[0097] matching the first identification number of each child node in the first menu tree with a plurality of second identification numbers in the second menu tree to determine a target identification number from each first identification number, the target identification number matching the second identification number;
[0098] The first permission name corresponding to the target identification number is compared with the second permission name, and each sub-node corresponding to the target identification number that is inconsistent with the comparison is determined as a target sub-node to be renamed.
[0099] In one embodiment, the reassembly module 203 is further configured to:
[0100] Adding a newly added target child node and target leaf node to the first menu tree to obtain a first desired sub-menu tree;
[0101] Based on the target child node and the target leaf node of the modified hierarchy, the corresponding nodes in the first sub-desired menu tree are hierarchically modified to obtain a second sub-desired menu tree;
[0102] Based on the renamed target child node and target leaf node, renaming the corresponding nodes in the second desired sub-menu tree to obtain a third desired sub-menu tree;
[0103] Based on the target child node and target leaf node to be deleted, a deletion operation is performed on the corresponding nodes in the third desired sub-menu tree to obtain the third menu tree.
[0104] In one embodiment, Figure 6 As shown, the role authority configuration device 200 further includes a parsing module 204, which is further configured to:
[0105] Analyze whether there are any missing leaf nodes in the first role permission tree;
[0106] When there is a missing leaf node in the first role permission tree, the child nodes corresponding to the missing leaf node are cleared.
[0107] In one embodiment, the matching module 202 is further configured to:
[0108] Obtaining a first personalized permission tree, where the first personalized permission tree is used to represent the original permissions of the set character before the first menu tree is reconstructed, and the first personalized permission tree includes some child nodes and some leaf nodes in the first role permission tree;
[0109] According to the leaf nodes in the first personalized permission tree, the third menu tree is matched from bottom to top to obtain a second personalized permission tree; the second personalized permission tree is used to represent the target permissions of the set character after the first menu tree is reconstructed, and the second personalized permission tree includes some child nodes and some leaf nodes in the third menu tree.
[0110] It should be noted that technical personnel in the relevant field can clearly understand that for the convenience and conciseness of description, the specific working processes of the above-described devices and modules and units can refer to the corresponding processes in the aforementioned role authority configuration method embodiment, and will not be repeated here.
[0111] The apparatus provided in the above embodiment can be implemented in the form of a computer program. The computer program can be used in Figure 7 Runs on the computer device shown.
[0112] See also Figure 7 , Figure 7 A schematic block diagram of the structure of a computer device provided in an embodiment of the present application.
[0113] like Figure 7 As shown, the computer device includes a processor, a memory and a network interface connected through a system bus, wherein the memory may include a storage medium and an internal memory, and the storage medium may be non-volatile or volatile.
[0114] The storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any one of the role permission configuration methods.
[0115] The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
[0116] The internal memory provides an environment for the operation of the computer program in the storage medium. When the computer program is executed by the processor, the processor can execute any role authority configuration method.
[0117] The network interface is used for network communication, such as sending assigned tasks, etc. Those skilled in the art will understand that Figure 7The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0118] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0119] In one embodiment, the processor is configured to execute a computer program stored in the memory to implement the following steps:
[0120] Acquire a first menu tree and a second menu tree; wherein the first menu tree is the original menu tree before reconstruction, and the second menu tree is the desired menu tree after reconstruction;
[0121] Matching the first menu tree with the second menu tree to identify target child nodes and target leaf nodes where modifications are made;
[0122] Based on the target child node and the target leaf node, the first menu tree is reorganized to obtain a third menu tree;
[0123] Obtaining a first role permission tree, where the first role permission tree is used to represent the original permissions of the set role before the first menu tree is reconstructed, and the first role permission tree includes some child nodes and some leaf nodes in the first menu tree;
[0124] According to the leaf nodes in the first role permission tree, the third menu tree is matched from bottom to top to obtain the second role permission tree; the second role permission tree is used to represent the target permissions of the set role after the first menu tree is reconstructed, and the second role permission tree includes some child nodes and some leaf nodes in the third menu tree.
[0125] In one embodiment, when implementing the matching of the first menu tree with the second menu tree to identify the target child node and the target leaf node that have been modified, the processor is configured to implement:
[0126] Matching the first menu tree with the plurality of child nodes and leaf nodes in the second menu tree to obtain a matching result;
[0127] According to the matching result, the newly added, modified, renamed, and deleted child nodes are obtained as the target child nodes, and the newly added, modified, renamed, and deleted leaf nodes are obtained according to the matching result as the target leaf nodes.
[0128] In one embodiment, when implementing the matching of the first menu tree with the second menu tree to identify the target child node and the target leaf node that have been modified, the processor is configured to implement:
[0129] Matching each child node in the first menu tree with multiple child nodes and leaf nodes in the second menu tree to obtain target child nodes with modified levels, renamed, or deleted, as well as unmodified child nodes; and
[0130] Matching each leaf node in the first menu tree with multiple child nodes and leaf nodes in the second menu tree to obtain target leaf nodes that have been modified in level, renamed, or deleted, as well as unmodified leaf nodes;
[0131] According to the target child node, the unmodified child node, the target leaf node and the unmodified leaf node, a newly added target child node and a newly added target leaf node are determined from multiple child nodes and multiple leaf nodes in the second menu tree.
[0132] In one embodiment, when matching each child node in the first menu tree with multiple child nodes and leaf nodes in the second menu tree to obtain a target child node to be renamed, the processor is configured to implement:
[0133] Obtaining a first permission name and a first identification number of each child node in the first menu tree, and obtaining a second permission name and a second identification number of multiple child nodes and leaf nodes in the second menu tree;
[0134] matching the first identification number of each child node in the first menu tree with a plurality of second identification numbers in the second menu tree to determine a target identification number from each first identification number, the target identification number matching the second identification number;
[0135] The first permission name corresponding to the target identification number is compared with the second permission name, and each sub-node corresponding to the target identification number that is inconsistent with the comparison is determined as a target sub-node to be renamed.
[0136] In one embodiment, when the processor implements the reorganization of the first menu tree based on the target child node and the target leaf node to obtain the third menu tree, it is configured to implement:
[0137] Adding a newly added target child node and target leaf node to the first menu tree to obtain a first desired sub-menu tree;
[0138] Based on the target child node and the target leaf node of the modified hierarchy, the corresponding nodes in the first sub-desired menu tree are hierarchically modified to obtain a second sub-desired menu tree;
[0139] Based on the renamed target child node and target leaf node, renaming the corresponding nodes in the second desired sub-menu tree to obtain a third desired sub-menu tree;
[0140] Based on the target child node and target leaf node to be deleted, a deletion operation is performed on the corresponding nodes in the third desired sub-menu tree to obtain the third menu tree.
[0141] In one embodiment, after obtaining the first role permission tree, the processor is further configured to:
[0142] Analyze whether there are any missing leaf nodes in the first role permission tree;
[0143] When there is a missing leaf node in the first role permission tree, the child nodes corresponding to the missing leaf node are cleared.
[0144] In one embodiment, the processor is further configured to implement:
[0145] Obtaining a first personalized permission tree, where the first personalized permission tree is used to represent the original permissions of the set character before the first menu tree is reconstructed, and the first personalized permission tree includes some child nodes and some leaf nodes in the first role permission tree;
[0146] According to the leaf nodes in the first personalized permission tree, the third menu tree is matched from bottom to top to obtain a second personalized permission tree; the second personalized permission tree is used to represent the target permissions of the set character after the first menu tree is reconstructed, and the second personalized permission tree includes some child nodes and some leaf nodes in the third menu tree.
[0147] It should be noted that technical personnel in the relevant field can clearly understand that for the convenience and conciseness of description, the specific working process of the computer device described above can refer to the corresponding process in the aforementioned role authority configuration method embodiment, and will not be repeated here.
[0148] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and the like. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments in which tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.
[0149] An embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. The computer program includes program instructions. The method implemented when the program instructions are executed can refer to the various embodiments of the role authority configuration method of the present application.
[0150] The computer-readable storage medium may be an internal storage unit of the computer device described in the aforementioned embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a SmartMedia Card (SMC), a Secure Digital (SD) card, a flash memory card, etc., equipped on the computer device.
[0151] Furthermore, the computer-usable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created based on the use of blockchain nodes, etc. The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. The blockchain may include the blockchain underlying platform, the platform product service layer, and the application service layer.
[0152] It should be understood that the terms used in this specification are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in this specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0153] It should also be understood that the term "and / or" used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, including these combinations. It should be noted that, in this article, the terms "include", "comprise" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system that includes a series of elements includes not only those elements, but also other elements that are not explicitly listed, or also includes elements that are inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "including a..." does not exclude the presence of other identical elements in the process, method, article or system that includes the element.
[0154] The serial numbers of the embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments. The above description is only a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A method for configuring role permissions, characterized in that: include: Acquire a first menu tree and a second menu tree; wherein the first menu tree is the original menu tree before reconstruction, and the second menu tree is the desired menu tree after reconstruction; Matching the first menu tree with the second menu tree to identify target child nodes and target leaf nodes where modifications are made; Based on the target child node and the target leaf node, the first menu tree is reorganized to obtain a third menu tree; Obtaining a first role permission tree, where the first role permission tree is used to represent the original permissions of the set role before the first menu tree is reconstructed, and the first role permission tree includes some child nodes and some leaf nodes in the first menu tree; According to the leaf nodes in the first role permission tree, the third menu tree is matched from bottom to top to obtain the second role permission tree; the second role permission tree is used to represent the target permissions of the set role after the first menu tree is reconstructed, and the second role permission tree includes some child nodes and some leaf nodes in the third menu tree.
2. The role authority configuration method according to claim 1, characterized in that: The matching of the first menu tree with the second menu tree to identify a target child node and a target leaf node where modifications are made includes: Matching the first menu tree with the plurality of child nodes and leaf nodes in the second menu tree to obtain a matching result; According to the matching result, the newly added, modified, renamed, or deleted child nodes are obtained as the target child nodes, and according to the matching result, the newly added, modified, renamed, or deleted leaf nodes are obtained as the target leaf nodes.
3. The role authority configuration method according to claim 1, wherein: The matching of the first menu tree with the second menu tree to identify a target child node and a target leaf node where modifications are made includes: Matching each child node in the first menu tree with multiple child nodes and leaf nodes in the second menu tree to obtain target child nodes with modified levels, renamed, or deleted, as well as unmodified child nodes; and Matching each leaf node in the first menu tree with multiple child nodes and leaf nodes in the second menu tree to obtain target leaf nodes that have been modified in level, renamed, or deleted, as well as unmodified leaf nodes; According to the target child node, the unmodified child node, the target leaf node and the unmodified leaf node, a newly added target child node and a newly added target leaf node are determined from multiple child nodes and multiple leaf nodes in the second menu tree.
4. The role authority configuration method according to claim 3, characterized in that: Matching each child node in the first menu tree with multiple child nodes and leaf nodes in the second menu tree to obtain a target child node to be renamed includes: Obtaining a first permission name and a first identification number of each child node in the first menu tree, and obtaining a second permission name and a second identification number of multiple child nodes and leaf nodes in the second menu tree; matching the first identification number of each child node in the first menu tree with a plurality of second identification numbers in the second menu tree to determine a target identification number from each first identification number, the target identification number matching the second identification number; The first permission name corresponding to the target identification number is compared with the second permission name, and each sub-node corresponding to the target identification number that is inconsistent with the comparison is determined as a target sub-node to be renamed.
5. The role authority configuration method according to any one of claims 1 to 4, characterized in that: The first menu tree is reorganized based on the target child node and the target leaf node to obtain a third menu tree, including: Adding a newly added target child node and target leaf node to the first menu tree to obtain a first desired sub-menu tree; Based on the target child node and the target leaf node of the modified hierarchy, the corresponding nodes in the first sub-desired menu tree are hierarchically modified to obtain a second sub-desired menu tree; Based on the renamed target child node and target leaf node, renaming the corresponding nodes in the second desired sub-menu tree to obtain a third desired sub-menu tree; Based on the target child node and target leaf node to be deleted, a deletion operation is performed on the corresponding nodes in the third desired sub-menu tree to obtain the third menu tree.
6. The role authority configuration method according to any one of claims 1 to 4, characterized in that: After obtaining the first role permission tree, the method further includes: Analyze whether there are any missing leaf nodes in the first role permission tree; When there is a missing leaf node in the first role permission tree, the child nodes corresponding to the missing leaf node are cleared.
7. The role authority configuration method according to any one of claims 1 to 4, characterized in that: The method further comprises: Obtaining a first personalized permission tree, where the first personalized permission tree is used to represent the original permissions of the set character before the first menu tree is reconstructed, and the first personalized permission tree includes some child nodes and some leaf nodes in the first role permission tree; According to the leaf nodes in the first personalized permission tree, the third menu tree is matched from bottom to top to obtain a second personalized permission tree; the second personalized permission tree is used to represent the target permissions of the set character after the first menu tree is reconstructed, and the second personalized permission tree includes some child nodes and some leaf nodes in the third menu tree.
8. A role authority configuration device, characterized in that: The role authority configuration device includes: An acquisition module, configured to acquire a first menu tree and a second menu tree; wherein the first menu tree is the original menu tree before reconstruction, and the second menu tree is the desired menu tree after reconstruction; a matching module, configured to match the first menu tree with the second menu tree to identify target child nodes and target leaf nodes that have been modified; a reorganization module, configured to reorganize the first menu tree based on the target child node and the target leaf node to obtain a third menu tree; The acquisition module is further configured to acquire a first role permission tree, wherein the first role permission tree is used to represent the original permissions of the set role before the first menu tree is reconstructed, and the first role permission tree includes some child nodes and some leaf nodes in the first menu tree; The matching module is also used to match the third menu tree from bottom to top according to the leaf nodes in the first role permission tree to obtain a second role permission tree; the second role permission tree is used to represent the target permissions of the set role after the first menu tree is reconstructed, and the second role permission tree includes some child nodes and some leaf nodes in the third menu tree.
9. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the role authority configuration method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the role authority configuration method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Data permission adjustment method and device based on data storage system
CN111767525A
Directory display method and device, computer equipment and computer readable storage medium
CN112035478A