示例#1
0
        /// <summary>
        /// 批量删除权限分组
        /// </summary>
        /// <param name="groupIds">分组编号</param>
        /// <returns></returns>
        public static Result RemoveAuthorityGroup(IEnumerable <long> groupIds)
        {
            #region 参数判断

            if (groupIds.IsNullOrEmpty())
            {
                return(Result.FailedResult("没有指定任何要删除的权限分组"));
            }

            #endregion

            //删除分组信息
            IQuery parentRemoveCondition = QueryFactory.Create();
            parentRemoveCondition.In <AuthorityGroupQuery>(r => r.SysNo, groupIds);
            authorityGroupRepository.Remove(parentRemoveCondition);
            //删除下级
            IQuery childQuery = QueryFactory.Create();
            childQuery.In <AuthorityGroupQuery>(r => r.Parent, groupIds);
            childQuery.AddQueryFields <AuthorityGroupQuery>(r => r.SysNo);
            List <AuthorityGroup> authorityGroupList = authorityGroupRepository.GetList(childQuery);
            if (authorityGroupList.IsNullOrEmpty())
            {
                return(Result.SuccessResult("没有需要删除的下级分组"));
            }
            RemoveAuthorityGroup(authorityGroupList.Select(r => r.SysNo));
            return(Result.SuccessResult("删除成功"));
        }
        /// <summary>
        /// 批量删除权限分组
        /// </summary>
        /// <param name="groupIds">分组编号</param>
        /// <returns></returns>
        public Result RemoveAuthorityGroup(IEnumerable <long> groupIds)
        {
            #region 参数判断

            if (groupIds.IsNullOrEmpty())
            {
                return(Result.FailedResult("没有指定任何要删除的权限分组"));
            }

            #endregion

            //删除分组信息
            IQuery removeQuery = QueryManager.Create <AuthorityGroupQuery>(c => groupIds.Contains(c.SysNo));
            removeQuery.SetRecurve <AuthorityGroupQuery>(c => c.SysNo, c => c.Parent);
            authorityGroupRepository.Remove(removeQuery);
            return(Result.SuccessResult("删除成功"));
        }