Example #1
0
        /// <summary>
        /// 不分页获取权限内的所有数据, 根据账户得到对应渠道管理员的所有权限,才能给下级分配权限
        /// </summary>
        /// <param name="userId">当前登陆用户的Id</param>
        /// <param name="userType">用户类型 0员工 1会员</param>
        /// <returns>
        /// List&lt;Sys_role&gt;.
        /// </returns>
        public static List <Sysmenu> GetListByUserId_Sysmenu(int userId, int userType)
        {
            if (userId == 1)
            {
                return(GetAllList());
            }

            if (userType == 0)
            {
                #region 处理员工

                var adminuser = EmployeeLogic.GetListByInSelect(nameof(Employee), nameof(Employee.CompanyId), nameof(Employee.CompanyId),
                                                                new Dictionary <string, object>()
                {
                    { nameof(Employee.IsDeleted), 0 }
                }, new Dictionary <string, object>
                {
                    { nameof(Employee.KID), userId },
                    { nameof(Employee.IsDeleted), 0 }
                }, 1, 1000).FirstOrDefault();

                if (adminuser == null)
                {
                    return(new List <Sysmenu>());
                }

                var allrole = SysroleLogic.GetListByInSelect(nameof(Sysuserrole), nameof(Sysrole.KID),
                                                             nameof(Sysuserrole.Roleid), new Dictionary <string, object>
                {
                    { nameof(Sysrole.IsDeleted), 0 }
                }, new Dictionary <string, object>
                {
                    { nameof(Sysuserrole.Userid), adminuser.KID },
                    { nameof(Sysuserrole.UserType), 0 },
                }, 1, 10000);

                var menuids = string.Join(",", allrole.Select(p => p.MenuList).ToList());

                if (menuids.Length > 1)
                {
                    return(GetList(new Dictionary <string, object>()
                    {
                        { nameof(Sysmenu.KID) + "|i", menuids }
                    }));
                }
                #endregion
            }

            return(new List <Sysmenu>());
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public static List <Sysmenu> GetListByuserid_Sysmenu(int userid)
        {
            var menulist = new List <Sysmenu>();

            try
            {
                if (userid <= 0)
                {
                    return(menulist);
                }

                //1是超管
                if (userid == 1)
                {
                    return(GetAllList());
                }
                else
                {
                    var userrole = SysroleLogic.GetListByInSelect(nameof(Sysuserrole), nameof(Sysrole.KID), nameof(Sysuserrole.Roleid), new Dictionary <string, object>()
                    {
                        { nameof(Sysmenu.IsDeleted), 0 },
                        { nameof(Sysmenu.States), 0 }
                    },
                                                                  new Dictionary <string, object>()
                    {
                        { nameof(Sysuserrole.Userid), userid }
                    });

                    var roleids = string.Join(",", userrole.Select(x => x.KID));
                    var roles   = SysroleLogic.GetList(new Dictionary <string, object>()
                    {
                        { $"{nameof(Sysrole.KID)}|i", roleids }
                    });
                    var menulists = string.Join(",", roles.Select(x => x.MenuList));
                    menulist = GetList(new Dictionary <string, object>()
                    {
                        {
                            $"{nameof(Sysmenu.KID)}|i", menulists
                        },
                        { nameof(Sysmenu.IsDeleted), 0 }
                    });
                }
            }
            catch (Exception ex)
            {
            }

            return(menulist);
        }