-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Permission Tree Add Create And Update Delete
- Loading branch information
1 parent
e8862af
commit 257f84b
Showing
12 changed files
with
190 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/LinCms.Application.Contracts/Cms/Permissions/PermissioCreateUpdateDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using LinCms.Entities; | ||
|
||
namespace LinCms.Cms.Permissions; | ||
|
||
public class PermissioCreateUpdateDto | ||
{ | ||
|
||
public PermissionType PermissionType { get; set; } | ||
|
||
/// <summary> | ||
/// 父级Id | ||
/// </summary> | ||
public long ParentId { get; set; } | ||
|
||
/// <summary> | ||
/// 所属权限、权限名称,例如:访问首页 | ||
/// </summary> | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// 后台路由 | ||
/// </summary> | ||
public string Router { get; set; } | ||
|
||
/// <summary> | ||
/// 排序 | ||
/// </summary> | ||
public int SortCode { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/LinCms.Application.Contracts/LinCms.Application.Contracts.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace LinCms.Cms.Permissions; | ||
|
||
public record TreeBuilder | ||
{ | ||
public List<PermissionTreeNode> BuildPermissionTree(List<PermissionTreeNode> nodes) | ||
{ | ||
var nodeDict = nodes.ToDictionary(n => n.Id); | ||
List<PermissionTreeNode> roots = new List<PermissionTreeNode>(); | ||
|
||
foreach (var node in nodes) | ||
{ | ||
if (node.ParentId == 0) // 假定ParentId为0表示根节点 | ||
{ | ||
roots.Add(node); | ||
} | ||
else | ||
{ | ||
if (nodeDict.TryGetValue(node.ParentId, out PermissionTreeNode parentNode)) | ||
{ | ||
parentNode.Children.Add(node); | ||
} | ||
} | ||
} | ||
return roots; // 返回森林中所有根节点的列表 | ||
} | ||
|
||
public List<TreeNode> BuildTree(List<TreeNode> nodes) | ||
{ | ||
var nodeDict = nodes.ToDictionary(n => n.Id); | ||
List<TreeNode> roots = new List<TreeNode>(); | ||
|
||
foreach (var node in nodes) | ||
{ | ||
if (node.ParentId == 0) // 假定ParentId为0表示根节点 | ||
{ | ||
roots.Add(node); | ||
} | ||
else | ||
{ | ||
if (nodeDict.TryGetValue(node.ParentId, out TreeNode parentNode)) | ||
{ | ||
parentNode.Children.Add(node); | ||
} | ||
} | ||
} | ||
return roots; // 返回森林中所有根节点的列表 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.