/// <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); }
/// <summary> /// 更新权限分组 /// </summary> /// <param name="authorityGroup">权限信息</param> /// <returns>执行结果</returns> static Result <AuthorityGroup> UpdateAuthorityGroup(AuthorityGroup newAuthorityGroup) { AuthorityGroup authorityGroup = authorityGroupRepository.Get(QueryFactory.Create <AuthorityGroupQuery>(r => r.SysNo == newAuthorityGroup.SysNo)); if (authorityGroup == null) { return(Result <AuthorityGroup> .FailedResult("没有指定要操作的分组信息")); } //上级 long newParentGroupId = newAuthorityGroup.Parent == null ? 0 : newAuthorityGroup.Parent.SysNo; long oldParentGroupId = authorityGroup.Parent == null ? 0 : authorityGroup.Parent.SysNo; //上级改变后 if (newParentGroupId != oldParentGroupId) { AuthorityGroup parentGroup = null; if (newParentGroupId > 0) { IQuery parentQuery = QueryFactory.Create <AuthorityGroupQuery>(c => c.SysNo == newParentGroupId); parentGroup = authorityGroupRepository.Get(parentQuery); if (parentGroup == null) { return(Result <AuthorityGroup> .FailedResult("请选择正确的上级分组")); } } authorityGroup.SetParentGroup(parentGroup); } //修改信息 authorityGroup.Name = newAuthorityGroup.Name; authorityGroup.Status = newAuthorityGroup.Status; authorityGroup.Remark = newAuthorityGroup.Remark; authorityGroup.Save();//保存 var result = Result <AuthorityGroup> .SuccessResult("更新成功"); result.Data = authorityGroup; return(result); }