/// <summary> /// 修改权限状态 /// </summary> /// <param name="statusInfo">状态信息</param> /// <returns>执行结果</returns> public Result ModifyAuthorityStatus(ModifyAuthorityStatusCmdDto statusInfo) { using (var businessWork = WorkFactory.Create()) { if (statusInfo == null || statusInfo.AuthorityStatusInfo == null) { return(Result.FailedResult("没有指定任何要修改的权限信息")); } List <ModifyAuthorityStatus> modifyStatusList = new List <ModifyAuthorityStatus>(); foreach (var statusItem in statusInfo.AuthorityStatusInfo) { modifyStatusList.Add(new ModifyAuthorityStatus() { Code = statusItem.Key, Status = statusItem.Value }); } var modifyResult = AuthorityDomainService.ModifyAuthorityStatus(modifyStatusList.ToArray()); if (!modifyResult.Success) { return(modifyResult); } var commitVal = businessWork.Commit(); return(commitVal.ExecutedSuccess ? Result.SuccessResult("修改成功") : Result.FailedResult("修改失败")); } }
/// <summary> /// 保存权限 /// </summary> /// <param name="saveInfo">权限对象</param> /// <returns>执行结果</returns> public Result <AuthorityDto> SaveAuthority(SaveAuthorityCmdDto saveInfo) { using (var businessWork = WorkFactory.Create()) { if (saveInfo == null) { return(Result <AuthorityDto> .FailedResult("没有指定任何要保存的权限信息")); } #region 保存权限数据 var authSaveResult = AuthorityDomainService.SaveAuthority(saveInfo.Authority.MapTo <Authority>()); if (!authSaveResult.Success) { return(Result <AuthorityDto> .FailedResult(authSaveResult.Message)); } #endregion var commitVal = businessWork.Commit(); Result <AuthorityDto> result = null; if (commitVal.ExecutedSuccess) { result = Result <AuthorityDto> .SuccessResult("保存成功"); result.Data = authSaveResult.Data.MapTo <AuthorityDto>(); } else { result = Result <AuthorityDto> .FailedResult("保存失败"); } return(result); } }
/// <summary> /// 检查权限名称是否存在 /// </summary> /// <param name="nameInfo">权限名信息</param> /// <returns></returns> public bool ExistAuthorityName(ExistAuthorityNameCmdDto nameInfo) { if (nameInfo == null) { return(false); } return(AuthorityDomainService.ExistAuthorityName(nameInfo.Name, nameInfo.ExcludeCode)); }
/// <summary> /// 检查权限编码是否存在 /// </summary> /// <param name="codeInfo">权限编码</param> /// <returns></returns> public bool ExistAuthorityCode(ExistAuthorityCodeCmdDto codeInfo) { if (codeInfo == null) { return(false); } return(AuthorityDomainService.ExistAuthorityCode(codeInfo.AuthCode)); }
/// <summary> /// 删除权限 /// </summary> /// <param name="deleteInfo">删除信息</param> /// <returns>执行结果</returns> public Result DeleteAuthority(DeleteAuthorityCmdDto deleteInfo) { using (var businessWork = WorkFactory.Create()) { #region 参数判断 if (deleteInfo == null || deleteInfo.AuthorityCodes.IsNullOrEmpty()) { return(Result.FailedResult("没有指定要删除的权限")); } #endregion AuthorityDomainService.DeleteAuthority(deleteInfo.AuthorityCodes); var exectVal = businessWork.Commit(); return(exectVal.ExecutedSuccess ? Result.SuccessResult("删除成功") : Result.FailedResult("删除失败")); } }
/// <summary> /// 获取权限 /// </summary> /// <param name="filter">查询对象</param> /// <returns></returns> public AuthorityDto GetAuthority(AuthorityFilterDto filter) { var authority = AuthorityDomainService.GetAuthority(CreateAuthorityQueryObject(filter)); return(authority.MapTo <AuthorityDto>()); }
/// <summary> /// 获取权限分页 /// </summary> /// <param name="filter">查询对象</param> /// <returns></returns> public IPaging <AuthorityDto> GetAuthorityPaging(AuthorityFilterDto filter) { var authorityPaging = AuthorityDomainService.GetAuthorityPaging(CreateAuthorityQueryObject(filter)); return(authorityPaging.ConvertTo <AuthorityDto>()); }
/// <summary> /// 获取权限列表 /// </summary> /// <param name="filter">查询对象</param> /// <returns></returns> public List <AuthorityDto> GetAuthorityList(AuthorityFilterDto filter) { var authorityList = AuthorityDomainService.GetAuthorityList(CreateAuthorityQueryObject(filter)); return(authorityList.Select(c => c.MapTo <AuthorityDto>()).ToList()); }