/// <summary> /// 获取菜单,无级别 /// </summary> /// <param name="queryMenuReq"></param> /// <returns></returns> public TableData LoadNoCascade([FromQuery] QueryMenuReq queryMenuReq) { return(new TableData() { statusText = "success", data = MenuManagerApp.LoadNoCascade(queryMenuReq) }); }
//public List<Menu> LoadMenuAuthority() //{ // //var listMenu = UnitWork.Find<Menu>(null).Where(w=>w.IsDel==false && w.IsAble == false).ToList(); // var listMenu = UnitWork.SqlQuery<Menu>( // "select Id, Name,Name as Label,Name as Title,Path,Component,Redirect, ParentId, ParentName, CascadeId, Code,hidden, LinkAddress, Icon, Sort, CreateTime, UpdateTime, IsAble, IsDel from Menus " + // "where isAble = 0 and isDel=0 order by Sort desc,CreateTime asc", new object[] { }).ToList(); // foreach (var m in listMenu) // { // var listButton = UnitWork.SqlQuery<Button>( // "select b.Id,b.Name,b.Name as Label,b.Code, b.Icon, b.Explain, b.CreateTime, b.UpdateTime, b.Sort from MenuButton bm left join Buttons b on bm.ButtonId = b.Id where MenuId=@ButtonId", // new object[] // { // new SqlParameter() // { // ParameterName = "@ButtonId", // Value = m.Id, // DbType = DbType.String // } // }).ToList(); // //m.ButtonIds = string.Join(",", listButton.Select(s => s.Id).ToList()); // //m.ButtonNames = string.Join(",", listButton.Select(s => s.Name).ToList()); // m.children = listButton; // m.meta = new Meta() // { // roles = new string[] { "admin", "editor" }, // title = m.Title, // icon = m.Icon, // noCache = false, // }; // } // return BindNew(listMenu, null); //} public List <Menu> Load(QueryMenuReq queryMenuReq) { //var listMenu = UnitWork.Find<Menu>(null).Where(w=>w.IsDel==false && w.IsAble == false).ToList(); var listMenu = UnitWork.SqlQuery <Menu>( "select Id, Name,Name as Label,Name as Title,Path,Component,Redirect, ParentId, ParentName, CascadeId, Code,hidden, LinkAddress, Icon, Sort, CreateTime, UpdateTime, IsAble, IsDel from Menus " + "where isAble = 0 and isDel=0 and Component like @Component and Name like @Name order by Sort desc,CreateTime asc", new object[] { new SqlParameter() { ParameterName = "@Component", Value = "%" + queryMenuReq.Component + "%", DbType = DbType.String }, new SqlParameter() { ParameterName = "@Name", Value = "%" + queryMenuReq.Name + "%", DbType = DbType.String } }).ToList(); foreach (var m in listMenu) { var listButton = UnitWork.SqlQuery <Button>( "select b.Id,b.Name,b.Name as Label,b.Name as Title,b.Code, b.Icon, b.Explain, b.CreateTime, b.UpdateTime, b.Sort from MenuButton bm left join Buttons b on bm.ButtonId = b.Id where MenuId=@ButtonId", new object[] { new SqlParameter() { ParameterName = "@ButtonId", Value = m.Id, DbType = DbType.String } }).ToList(); m.ButtonIds = string.Join(",", listButton.Select(s => s.Id).ToList()); m.ButtonNames = string.Join(",", listButton.Select(s => s.Name).ToList()); m.Buttons = listButton; m.meta = new Meta() { roles = new [] { "admin", "editor", "v" }, title = m.Title, icon = m.Icon, noCache = false, }; } return(BindNew(listMenu, null)); }
public List <Menu> LoadNoCascade(QueryMenuReq queryMenuReq) { //var listMenu = UnitWork.Find<Menu>(null).Where(w=>w.IsDel==false && w.IsAble == false).ToList(); var listMenu = UnitWork.SqlQuery <Menu>( "select Id, Name,Name as Label,Name as Title,Path,Component,Redirect, ParentId, ParentName, CascadeId, Code,hidden, LinkAddress, Icon, Sort, CreateTime, UpdateTime, IsAble, IsDel from Menus " + "where isAble = 0 and isDel=0 and Component like @Component and Name like @Name order by Sort desc,CreateTime asc", new object[] { new SqlParameter() { ParameterName = "@Component", Value = "%" + queryMenuReq.Component + "%", DbType = DbType.String }, new SqlParameter() { ParameterName = "@Name", Value = "%" + queryMenuReq.Name + "%", DbType = DbType.String } }).ToList(); return(listMenu); }