示例#1
0
 public async Task <JsonResult> GetMenuByParentId(SystemMenuGetMenuByParentIdInput input)
 {
     return(JsonForGridLoadOnce(await _menuLogic.GetMenuByParentId(input)));
 }
示例#2
0
        /// <summary>
        /// 获取显示在菜单列表上数据
        /// </summary>
        /// <returns></returns>
        public async Task <IList <SystemMenuGetMenuByParentIdOutput> > GetMenuByParentId(SystemMenuGetMenuByParentIdInput input)
        {
            var menus = (await GetAllEnumerableAsync()).ToList();
            IList <SystemMenuGetMenuByParentIdOutput> systemMenus = (await _menuRepository.GetMenuByParentId(input)).ToList();

            foreach (var menu in systemMenus)
            {
                if (!menu.ParentIds.IsNullOrEmpty())
                {
                    foreach (var parent in menu.ParentIds.Split(','))
                    {
                        //查找上级
                        var dicinfo = menus.FirstOrDefault(w => w.MenuId.ToString() == parent);
                        if (dicinfo != null)
                        {
                            menu.ParentNames += dicinfo.Name + ">";
                        }
                    }
                    if (!menu.ParentNames.IsNullOrEmpty())
                    {
                        menu.ParentNames = menu.ParentNames.TrimEnd('>');
                    }
                }
            }
            return(systemMenus.OrderBy(o => o.ParentNames).ToList());
        }
        /// <summary>
        /// 根据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public Task <IEnumerable <SystemMenuGetMenuByParentIdOutput> > GetMenuByParentId(SystemMenuGetMenuByParentIdInput input)
        {
            var sql = new StringBuilder();

            sql.Append("select *,(select name from System_Menu o where o.MenuId=menu.ParentId) ParentName from System_Menu menu Where 1=1 ");
            if (input.Id != null)
            {
                sql.Append(" And menu.ParentIds  like '%" + (input.Id + ",").Replace(",", @"\,") + "%" + "' escape '\\'");
            }
            sql.Append(input.Sql);
            return(SqlMapperUtil.SqlWithParams <SystemMenuGetMenuByParentIdOutput>(sql.ToString(), new { pId = input.Id }));
        }