Esempio n. 1
0
        /// <summary>
        /// 返回符合某种权限要求的组织列表
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="organizationAuthorityEnum"></param>
        /// <returns></returns>
        public List <Organization> GetOrganizationList(long?userId, OrganizationAuthorityEnum organizationAuthorityEnum)
        {
            var list   = GetMyJoinOrganization(userId);
            var myOrgs = GetMyOrganization(userId);
            var result = new List <Organization>();

            result.AddRange(myOrgs);
            foreach (var item in list)
            {
                if (Verify(item.Id, userId, organizationAuthorityEnum))
                {
                    result.Add(item);
                }
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 验证某个成员对某个组织具有某种权限
        /// </summary>
        /// <param name="organizationId"></param>
        /// <param name="userId"></param>
        /// <param name="organizationAuthorityEnum"></param>
        /// <returns></returns>
        public bool Verify(long?organizationId, long?userId, OrganizationAuthorityEnum organizationAuthorityEnum)
        {
            var org = this.GetOrganizationById(organizationId);

            if (org.OwnerId == userId)
            {
                return(true);//组织拥有者 拥有任意权限
            }

            var set = GetOrganizationAuthoritySet(organizationId, userId);

            if (set == null)
            {
                return(false);
            }
            return(set.Contains(organizationAuthorityEnum));
        }
Esempio n. 3
0
        public IActionResult GetOrganizationListByAuthorityEnum(string token, OrganizationAuthorityEnum AuthorityEnum)
        {
            var apiRe = new ApiRe()
            {
                Ok   = false,
                Data = null
            };
            var user = tokenSerivce.GetUserByToken(token);

            if (user != null)
            {
                var list = organizationService.GetOrganizationList(user.UserId, AuthorityEnum);

                apiRe = new ApiRe()
                {
                    Ok   = true,
                    Data = list
                };
            }
            apiRe.Msg = "";
            return(SimpleJson(apiRe));
        }