Ejemplo n.º 1
0
        /// <summary>
        /// 添加权限分组
        /// </summary>
        /// <param name="authorityGroup">权限信息</param>
        /// <returns>执行结果</returns>
        static Result <AuthorityGroup> AddAuthorityGroup(AuthorityGroup authorityGroup)
        {
            #region  级

            long           parentGroupId = authorityGroup.Parent == null ? 0 : authorityGroup.Parent.SysNo;
            AuthorityGroup parentGroup   = null;
            if (parentGroupId > 0)
            {
                IQuery parentQuery = QueryFactory.Create <AuthorityGroupQuery>(c => c.SysNo == parentGroupId);
                parentGroup = authorityGroupRepository.Get(parentQuery);
                if (parentGroup == null)
                {
                    return(Result <AuthorityGroup> .FailedResult("请选择正确的上级分组"));
                }
            }
            authorityGroup.SetParentGroup(parentGroup);

            #endregion

            authorityGroup.Save();//保存
            var result = Result <AuthorityGroup> .SuccessResult("添加成功");

            result.Data = authorityGroup;
            return(result);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 加载上级分组
 /// </summary>
 AuthorityGroup LoadParentGroup()
 {
     if (!AllowLazyLoad(r => r.Parent))
     {
         return(_parent.CurrentValue);
     }
     if (_level <= 1 || _parent.CurrentValue == null)
     {
         return(null);
     }
     return(authorityGroupRepository.Get(QueryFactory.Create <AuthorityGroupQuery>(r => r.SysNo == _parent.CurrentValue.SysNo)));
 }