Example #1
0
        /// <summary>
        ///     根据菜单获取功能项信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public Task <IEnumerable <SystemMenuButtonOutput> > GetMenuButtonByMenuId(SystemMenuGetMenuButtonByMenuIdInput input = null)
        {
            var sql = new StringBuilder();

            sql.Append(
                "SELECT f.*,menu.Name MenuName FROM System_MenuButton f LEFT JOIN System_Menu menu ON menu.MenuId=f.MenuId WHERE 1=1 ");

            if (input != null)
            {
                sql.Append(input.Sql);
                if (!input.Id.IsNullOrEmptyGuid())
                {
                    sql.Append(" AND f.MenuId=@menuId");
                }
                return(SqlMapperUtil.SqlWithParams <SystemMenuButtonOutput>(sql.ToString(), new { menuId = input.Id }));
            }
            return(SqlMapperUtil.SqlWithParams <SystemMenuButtonOutput>(sql.ToString()));
        }
        /// <summary>
        ///     根据菜单获取功能项信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <IEnumerable <SystemMenuButtonOutput> > GetMenuButtonByMenuId(SystemMenuGetMenuButtonByMenuIdInput input)
        {
            var functions = (await _functionRepository.GetMenuButtonByMenuId(input)).ToList();
            var menus     = (await _menuRepository.FindAllAsync()).ToList();

            foreach (var item in functions)
            {
                var menu = menus.FirstOrDefault(w => w.MenuId == item.MenuId);
                if (menu != null && !menu.ParentIds.IsNullOrEmpty())
                {
                    foreach (var parent in menu.ParentIds.Split(','))
                    {
                        //查找上级
                        var dicinfo = menus.FirstOrDefault(w => w.MenuId.ToString() == parent);
                        if (dicinfo != null)
                        {
                            item.MenuNames += dicinfo.Name + ">";
                        }
                    }
                    if (!item.MenuNames.IsNullOrEmpty())
                    {
                        item.MenuNames = item.MenuNames.TrimEnd('>');
                    }
                }
            }
            return(functions.OrderBy(o => o.MenuNames).ThenBy(b => b.OrderNo).ToList());
        }
 public async Task <JsonResult> GetMenuButtonByMenuId(SystemMenuGetMenuButtonByMenuIdInput input)
 {
     return(JsonForGridLoadOnce(await _menuButtonLogic.GetMenuButtonByMenuId(input)));
 }