RightControl.Service/Permissions/MenuService.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RightControl.Model;
using RightControl.IRepository;
using RightControl.IService;
namespace RightControl.Service
{
public class MenuService : BaseService<MenuModel>, IMenuService
{
public IMenuRepository repository { get; set; }
public IActionService actionService { get; set; }
public IMenuRoleActionService menuRoleActionService { get; set; }
private void SetTree(tree _tree, string menuUrl, bool isIndex)
{
if (isIndex)
{
_tree.href = menuUrl;
}
}
public string GetIconHtmlString()
{
StringBuilder sb = new StringBuilder();
sb.Append("<ul class='site-doc-icon'>");
return sb.ToString();
}
public string GetParentMenuName(int Id)
{
var sql = "select m.MenuName from t_menu m where m.Id=(SELECT ParentId as Id from t_menu where Id=@Id)";
var result = repository.GetParentMenu(sql, Id);
return result == null ? "" : result.MenuName;
}
public dynamic GetMenusList(bool isIndex, int roleId)
{
IEnumerable<MenuModel> allMenus = GetMenuListByRoleId(roleId);
List<tree> treeList = new List<tree>();
var rootMenus = allMenus.Where(x => x.ParentId == 0).OrderBy(x => x.OrderNo);
int index = 0;
foreach (var r in rootMenus)
{
var _tree = new tree { id = r.Id, name = r.MenuName, title = r.MenuName, icon = r.MenuIcon };
if (isIndex == true && index == 0) //首页菜单默认第一项展开
{
_tree.spread = true;
}
index++;
GetMenusByRootMenuId(treeList, allMenus, _tree, r.Id, isIndex);
treeList.Add(_tree);
}
var result = treeList;
return treeList;
}
/// <summary>
/// 根据一级菜单加载子菜单列表
/// </summary>
/// <returns></returns>
private void GetMenusByRootMenuId(List<tree> treeList, IEnumerable<MenuModel> allMenus, tree tree, int menuId, bool isIndex)
后面还有 68 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
