Exemplo n.º 1
0
        /// <summary>
        /// 获取用户所有的角色
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public async Task <ResponseMessage <List <string> > > GetUserRolesList(string userid)
        {
            var response = new ResponseMessage <List <string> >();

            if (userid == null)
            {
                throw new Exception("请求参数为空");
            }
            try
            {
                response.Extension = await _IRolesStore.GetUserRoleAsync().Where(o => o.UserId.Equals(userid) && !o.IsDeleted).Select(p => p.RoleId).Distinct().ToListAsync();
            }
            catch (Exception el)
            {
                throw new Exception(el.Message);
            }
            return(response);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 该用户的所有权限Id集合
        /// </summary>
        /// <param name="UerId"></param>
        /// <returns></returns>
        public async Task <List <string> > ReturnAuthorityName(string UerId)
        {
            //用户角色
            var UserRole = from b in _IRolesStore.GetUserRoleAsync().Where(p => p.UserId == UerId)
                           join c in _IRolesStore.GetRolePermissionsAsync()
                           on b.RoleId equals c.RoledId into b1
                           from c1 in b1.DefaultIfEmpty()
                           select c1;

            return(await UserRole.Select(p => p.PermissionsId).Distinct().ToListAsync());
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取该用户的所有的权限列表
        /// </summary>
        /// <returns></returns>
        public async Task <ResponseMessage <List <string> > > JurisdictionList(string useId)
        {
            var response = new ResponseMessage <List <string> >();

            try
            {
                var UserRole = from b in _IRolesStore.GetUserRoleAsync().Where(p => p.UserId == useId && !p.IsDeleted)
                               join c in _IRolesStore.GetRolePermissionsAsync()
                               on b.RoleId equals c.RoledId into b1
                               from c1 in b1.DefaultIfEmpty()
                               select c1;
                response.Extension = await UserRole.Select(p => p.PermissionsId).Distinct().ToListAsync();
            }
            catch (Exception el)
            {
                throw new Exception(el.Message);
            }
            return(response);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取所有用户信息
        /// </summary>
        /// <returns></returns>
        public virtual async Task <PagingResponseMessage <UsersResponse> > GettingUsers(OranizationUserRequest condition)
        {
            var users          = DataBaseUser.TokenModel;
            var pagingResponse = new PagingResponseMessage <UsersResponse>();

            ////判断该用户的权限,锁定该组织范围
            //1.1.找到该用户的所有权限
            var scopeList = await _RolesStore.BrowsingScope(users.Id, "User_Add_Edit");

            if (scopeList == null)
            {
                pagingResponse.Message = "暂无权限,请联系管理";
                pagingResponse.Code    = ResponseCodeDefines.NotAllow;
                return(pagingResponse);
            }

            //1.2.对应权限的所有的可以浏览的范围(默认包含可查看本组织的内容)
            scopeList.Add(users.OrganizationId);
            var query = _IUserStore.GetUserInformation().Where(p => scopeList.Contains(p.OrganizationId));

            if (condition.OranizationId != null)
            {
                query = _IUserStore.GetUserInformation().Where(u => u.OrganizationId == condition.OranizationId && !u.IsDeleted);
            }
            //员工管理筛选条件【角色】
            if (condition.RoleId != null)
            {
                query = from c in query
                        join b in _RolesStore.GetUserRoleAsync() on
                        c.Id equals b.UserId into c1
                        from c2 in c1.DefaultIfEmpty()
                        where c2.RoleId.Equals(condition.RoleId)
                        select c;
            }

            //员工管理筛选条件【姓名】
            if (condition.TrueName != null)
            {
                query = query.Where(p => p.TrueName.Contains(condition.TrueName));
            }

            //员工管理筛选条件【部门】
            if (condition.EpartmentId != null)
            {
                query = query.Where(p => p.OrganizationId.Equals(condition.EpartmentId));
            }

            //员工管理筛选条件【离职】
            if (condition.IsDelete != null)
            {
                query = query.Where(p => p.IsDeleted.Equals(condition.IsDelete));
            }

            pagingResponse.TotalCount = await query.CountAsync();

            var qlist = await query.Skip(condition.PageIndex *condition.PageSize).Take(condition.PageSize).ToListAsync();

            pagingResponse.PageIndex = condition.PageIndex;
            pagingResponse.PageSize  = condition.PageSize;
            pagingResponse.Extension = _Mapper.Map <List <UsersResponse> >(qlist);
            return(pagingResponse);
        }