Esempio n. 1
0
        /// <summary>
        /// 获取角色的用户
        /// </summary>
        /// <param name="id"></param>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <param name="kw"></param>
        /// <param name="appid"></param>
        /// <returns></returns>
        public ActionResult Users(int id, int page = 1, int size = 10, string kw = "", string appid = "")
        {
            Expression <Func <UserInfo, bool> > where;
            if (!string.IsNullOrEmpty(kw))
            {
                if (string.IsNullOrEmpty(appid))
                {
                    where = u => u.Role.Any(c => c.Id == id) && (u.Username.Contains(kw) || u.Email.Contains(kw) || u.PhoneNumber.Contains(kw));
                }
                else
                {
                    where = u => u.ClientApp.Any(c => c.AppId.Equals(appid)) && u.Role.Any(c => c.Id == id) && (u.Username.Contains(kw) || u.Email.Contains(kw) || u.PhoneNumber.Contains(kw));
                }
            }
            else
            {
                if (string.IsNullOrEmpty(appid))
                {
                    where = u => u.Role.Any(c => c.Id == id);
                }
                else
                {
                    where = u => u.ClientApp.Any(c => c.AppId.Equals(appid)) && u.Role.Any(c => c.Id == id);
                }
            }
            List <UserInfoDto> my = UserInfoBll.LoadPageEntities <DateTime, UserInfoDto>(page, size, out int total, where, u => u.LastLoginTime, false).ToList();//属于该应用

            return(PageResult(my, size, total));
        }
Esempio n. 2
0
        /// <summary>
        /// 获取拥有该临时权限权限的用户
        /// </summary>
        /// <param name="id"></param>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <param name="kw"></param>
        /// <param name="appid">appid</param>
        /// <returns></returns>
        public ActionResult MyUsers(int id, int page = 1, int size = 10, string kw = "", string appid = "")
        {
            Expression <Func <UserInfo, bool> > where;
            Expression <Func <UserInfo, bool> > where2;

            if (!string.IsNullOrEmpty(kw))
            {
                if (string.IsNullOrEmpty(appid))
                {
                    where  = u => u.UserPermission.All(c => c.PermissionId != id) && (u.Username.Contains(kw) || u.Email.Contains(kw) || u.PhoneNumber.Contains(kw));
                    where2 = u => u.UserPermission.Any(c => c.PermissionId == id) && (u.Username.Contains(kw) || u.Email.Contains(kw) || u.PhoneNumber.Contains(kw));
                }
                else
                {
                    where  = u => u.ClientApp.Any(a => a.AppId.Equals(appid)) && u.UserPermission.All(c => c.PermissionId != id) && (u.Username.Contains(kw) || u.Email.Contains(kw) || u.PhoneNumber.Contains(kw));
                    where2 = u => u.ClientApp.Any(a => a.AppId.Equals(appid)) && u.UserPermission.Any(c => c.PermissionId == id) && (u.Username.Contains(kw) || u.Email.Contains(kw) || u.PhoneNumber.Contains(kw));
                }
            }
            else
            {
                if (string.IsNullOrEmpty(appid))
                {
                    where  = u => u.UserPermission.All(c => c.PermissionId != id);
                    where2 = u => u.UserPermission.Any(c => c.PermissionId == id);
                }
                else
                {
                    where  = u => u.ClientApp.Any(a => a.AppId.Equals(appid)) && u.UserPermission.All(c => c.PermissionId != id);
                    where2 = u => u.ClientApp.Any(a => a.AppId.Equals(appid)) && u.UserPermission.Any(c => c.PermissionId == id);
                }
            }

            List <UserInfoDto> not  = UserInfoBll.LoadPageEntities <DateTime, UserInfoDto>(page, size, out int total1, where, u => u.LastLoginTime, false).ToList(); //不属于该应用
            List <UserInfo>    list = UserInfoBll.LoadPageEntities(page, size, out int total2, where2, u => u.Id, false).ToList();                                   //属于该应用
            List <UserInfoDto> my   = new List <UserInfoDto>();

            foreach (var p in list)
            {
                //判断有没有临时权限
                UserInfoDto per = p.Mapper <UserInfoDto>();
                per.HasPermission = p.UserPermission.Any(u => u.PermissionId.Equals(id) && u.UserInfoId == p.Id && u.HasPermission);
                my.Add(per);
            }

            return(PageResult(new { my, not }, size, total1 >= total2 ? total1 : total2));
        }
Esempio n. 3
0
        /// <summary>
        /// 获取该应用的用户
        /// </summary>
        /// <param name="id"></param>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <param name="kw"></param>
        /// <returns></returns>
        public ActionResult MyUsers(int id, int page = 1, int size = 10, string kw = "")
        {
            Expression <Func <UserInfo, bool> > where;
            Expression <Func <UserInfo, bool> > where2;

            if (!string.IsNullOrEmpty(kw))
            {
                where  = u => u.ClientApp.All(c => c.Id != id) && (u.Username.Contains(kw) || u.Email.Contains(kw) || u.PhoneNumber.Contains(kw));
                where2 = u => u.ClientApp.Any(c => c.Id == id) && (u.Username.Contains(kw) || u.Email.Contains(kw) || u.PhoneNumber.Contains(kw));
            }
            else
            {
                where  = u => u.ClientApp.All(c => c.Id != id);
                where2 = u => u.ClientApp.Any(c => c.Id == id);
            }
            List <UserInfoDto> notMyUsers = UserInfoBll.LoadPageEntities <DateTime, UserInfoDto>(page, size, out int total1, where, u => u.LastLoginTime, false).ToList();  //不属于该应用
            List <UserInfoDto> myUsers    = UserInfoBll.LoadPageEntities <DateTime, UserInfoDto>(page, size, out int total2, where2, u => u.LastLoginTime, false).ToList(); //属于该应用

            return(PageResult(new { myUsers, notMyUsers }, size, total1 >= total2 ? total1 : total2));
        }