diff --git a/README.md b/README.md index 403f66a7..0c92f9dd 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,12 @@ [![fork](https://gitee.com/ccnetcore/yi/badge/fork.svg?theme=dark)](https://gitee.com/ccnetcore/Yi) [![license](https://img.shields.io/badge/license-MIT-yellow)](https://gitee.com/ccnetcore/Yi) +本项目 CDN 加速及安全防护由 Tencent EdgeOne 赞助 + +[亚洲最佳CDN、边缘和安全解决方案 - Tencent EdgeOne](https://edgeone.ai/zh?from=github) + + + [English](README-en.md) | 简体中文 **** ## 🍍 简介: @@ -60,9 +66,9 @@ bbs前端:`docker run -d --name yi.bbs -p 18001:18001 -v /home/Yi/Yi.Bbs.Vue3/ Yi社区官网网址(Bbs社区正式):[ccnetcore.com](https://ccnetcore.com) (已上线,欢迎加入) -Rbac后台演示地址:https://ccnetcore.com:1000 (用户cc、密码123456) +Rbac后台演示地址:https://data.ccnetcore.com:1000 (用户cc、密码123456) -Pure后台演示地址:https://ccnetcore.com:1001 (用户cc、密码123456) +Pure后台演示地址:https://data.ccnetcore.com:1001 (用户cc、密码123456) ## 🍏 支持: diff --git a/Yi.Abp.Net8/framework/Yi.Framework.AspNetCore/UnifyResult/Fiters/FriendlyExceptionFilter.cs b/Yi.Abp.Net8/framework/Yi.Framework.AspNetCore/UnifyResult/Fiters/FriendlyExceptionFilter.cs index cf86d283..e6392990 100644 --- a/Yi.Abp.Net8/framework/Yi.Framework.AspNetCore/UnifyResult/Fiters/FriendlyExceptionFilter.cs +++ b/Yi.Abp.Net8/framework/Yi.Framework.AspNetCore/UnifyResult/Fiters/FriendlyExceptionFilter.cs @@ -1,4 +1,4 @@ -// MIT 许可证 +// MIT 许可证 // // 版权 © 2020-present 百小僧, 百签科技(广东)有限公司 和所有贡献者 // @@ -17,25 +17,25 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Newtonsoft.Json; using Volo.Abp.AspNetCore.Mvc; -using Volo.Abp.DependencyInjection; +using Volo.Abp.Validation; using Yi.Framework.Core.Extensions; namespace Yi.Framework.AspNetCore.UnifyResult.Fiters; /// -/// 友好异常拦截器 +/// 友好异常拦截器 /// public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter { /// - /// 异常拦截 + /// 异常拦截 /// /// /// public async Task OnExceptionAsync(ExceptionContext context) { - // 排除 WebSocket 请求处理 if (context.HttpContext.IsWebSocketRequest()) return; @@ -44,20 +44,23 @@ public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter // 解析异常信息 var exceptionMetadata = GetExceptionMetadata(context); - - IUnifyResultProvider unifyResult = context.GetRequiredService(); + var unifyResult = context.GetRequiredService(); // 执行规范化异常处理 context.Result = unifyResult.OnException(context, exceptionMetadata); - + // 创建日志记录器 var logger = context.HttpContext.RequestServices.GetRequiredService>(); + var errorMsg = ""; + if (exceptionMetadata.Errors != null) errorMsg = "\n" + JsonConvert.SerializeObject(exceptionMetadata.Errors); + + // 记录拦截日常 - logger.LogError(context.Exception, context.Exception.Message); + logger.LogError(context.Exception, context.Exception.Message + errorMsg); } /// - /// 获取异常元数据 + /// 获取异常元数据 /// /// /// @@ -74,22 +77,25 @@ public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter // 判断是否是 ExceptionContext 或者 ActionExecutedContext var exception = context is ExceptionContext exContext ? exContext.Exception - : ( - context is ActionExecutedContext edContext - ? edContext.Exception - : default - ); + : context is ActionExecutedContext edContext + ? edContext.Exception + : default; + + if (exception is AbpValidationException validationException) + { + errors = validationException.ValidationErrors; + isValidationException = true; + } // 判断是否是友好异常 if (exception is UserFriendlyException friendlyException) { - int statusCode2 = 500; + var statusCode2 = 500; int.TryParse(friendlyException.Code, out statusCode2); isFriendlyException = true; errorCode = friendlyException.Code; originErrorCode = friendlyException.Code; - statusCode = statusCode2==0?403:statusCode2; - isValidationException = false; + statusCode = statusCode2 == 0 ? 403 : statusCode2; errors = friendlyException.Message; data = friendlyException.Data; } diff --git a/Yi.Abp.Net8/framework/Yi.Framework.AspNetCore/UnifyResult/UnifyResultExtensions.cs b/Yi.Abp.Net8/framework/Yi.Framework.AspNetCore/UnifyResult/UnifyResultExtensions.cs index 20b8db9a..b9d1ae7f 100644 --- a/Yi.Abp.Net8/framework/Yi.Framework.AspNetCore/UnifyResult/UnifyResultExtensions.cs +++ b/Yi.Abp.Net8/framework/Yi.Framework.AspNetCore/UnifyResult/UnifyResultExtensions.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.DependencyInjection; using Swashbuckle.AspNetCore.SwaggerGen; using Volo.Abp.AspNetCore.Mvc.ExceptionHandling; +using Volo.Abp.AspNetCore.Mvc.Response; using Yi.Framework.AspNetCore.UnifyResult.Fiters; namespace Yi.Framework.AspNetCore.UnifyResult; @@ -20,9 +21,10 @@ public static class UnifyResultExtensions services.AddTransient(); services.AddMvc(options => { + options.Filters.RemoveAll(x => (x as ServiceFilterAttribute)?.ServiceType == typeof(AbpExceptionFilter)); + options.Filters.RemoveAll(x => (x as ServiceFilterAttribute)?.ServiceType == typeof(AbpNoContentActionFilter)); options.Filters.AddService(99); options.Filters.AddService(100); - options.Filters.RemoveAll(x => (x as ServiceFilterAttribute)?.ServiceType == typeof(AbpExceptionFilter)); }); return services; } diff --git a/Yi.Abp.Net8/framework/Yi.Framework.Mapster/YiFrameworkMapsterModule.cs b/Yi.Abp.Net8/framework/Yi.Framework.Mapster/YiFrameworkMapsterModule.cs index 78f93dd1..9c250524 100644 --- a/Yi.Abp.Net8/framework/Yi.Framework.Mapster/YiFrameworkMapsterModule.cs +++ b/Yi.Abp.Net8/framework/Yi.Framework.Mapster/YiFrameworkMapsterModule.cs @@ -1,7 +1,8 @@ -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Modularity; using Volo.Abp.ObjectMapping; using Yi.Framework.Core; +using Mapster; namespace Yi.Framework.Mapster { @@ -22,7 +23,8 @@ namespace Yi.Framework.Mapster public override void ConfigureServices(ServiceConfigurationContext context) { var services = context.Services; - + // 扫描并注册所有映射配置 + TypeAdapterConfig.GlobalSettings.Scan(AppDomain.CurrentDomain.GetAssemblies()); // 注册Mapster相关服务 services.AddTransient(); services.AddTransient(); diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/System/DeptService.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/System/DeptService.cs index 531d610e..cc9898c3 100644 --- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/System/DeptService.cs +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/System/DeptService.cs @@ -51,7 +51,7 @@ namespace Yi.Framework.Rbac.Application.Services.System .WhereIF(!string.IsNullOrEmpty(input.DeptName), u => u.DeptName.Contains(input.DeptName!)) .WhereIF(input.State is not null, u => u.State == input.State) .OrderBy(u => u.OrderNum, OrderByType.Asc) - .ToPageListAsync(input.SkipCount, input.MaxResultCount, total); + .ToListAsync(); return new PagedResultDto { Items = await MapToGetListOutputDtosAsync(entities), diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/System/PostService.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/System/PostService.cs index 1975ed9d..b46d0070 100644 --- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/System/PostService.cs +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/System/PostService.cs @@ -1,3 +1,4 @@ +using Microsoft.AspNetCore.Mvc; using SqlSugar; using Volo.Abp.Application.Dtos; using Yi.Framework.Ddd.Application; @@ -54,5 +55,25 @@ namespace Yi.Framework.Rbac.Application.Services.System throw new UserFriendlyException(RoleConst.Exist); } } + + /// + /// 更新状态 + /// + /// + /// + /// + [Route("post/{id}/{state}")] + public async Task UpdateStateAsync([FromRoute] Guid id, [FromRoute] bool state) + { + var entity = await _repository.GetByIdAsync(id); + if (entity is null) + { + throw new ApplicationException("岗位未存在"); + } + + entity.State = state; + await _repository.UpdateAsync(entity); + return await MapToGetOutputDtoAsync(entity); + } } } \ No newline at end of file diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Entities/FileAggregateRoot.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Entities/FileAggregateRoot.cs index 7cb6faf9..285e9d4a 100644 --- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Entities/FileAggregateRoot.cs +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Entities/FileAggregateRoot.cs @@ -34,8 +34,7 @@ namespace Yi.Framework.Rbac.Domain.Entities var type = GetFileType(); var savePath = GetSaveFilePath(); - var filePath = Path.Combine(savePath, this.FileName); - this.FilePath = filePath; + this.FilePath = savePath; } /// diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs index 672e8164..1ffa409e 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs @@ -36,6 +36,7 @@ using Yi.Framework.AspNetCore.Authentication.OAuth.Gitee; using Yi.Framework.AspNetCore.Authentication.OAuth.QQ; using Yi.Framework.AspNetCore.Microsoft.AspNetCore.Builder; using Yi.Framework.AspNetCore.Microsoft.Extensions.DependencyInjection; +using Yi.Framework.AspNetCore.UnifyResult; using Yi.Framework.BackgroundWorkers.Hangfire; using Yi.Framework.Bbs.Application; using Yi.Framework.Bbs.Application.Extensions; @@ -125,6 +126,7 @@ namespace Yi.Abp.Web }); //采用furion格式的规范化api,默认不开启,使用abp优雅的方式 + //前置:需要将管道工作单元前加上app.Properties.Add("_AbpExceptionHandlingMiddleware_Added",false); //你没看错。。。 //service.AddFurionUnifyResultApi(); @@ -400,8 +402,7 @@ namespace Yi.Abp.Web app.UseDefaultFiles(); app.UseDirectoryBrowser("/api/app/wwwroot"); - - // app.Properties.Add("_AbpExceptionHandlingMiddleware_Added",false); + //app.Properties.Add("_AbpExceptionHandlingMiddleware_Added",false); //工作单元 app.UseUnitOfWork(); diff --git a/Yi.Pure.Vue3/src/views/system/post/utils/hook.tsx b/Yi.Pure.Vue3/src/views/system/post/utils/hook.tsx index 1aafdb69..1a28febd 100644 --- a/Yi.Pure.Vue3/src/views/system/post/utils/hook.tsx +++ b/Yi.Pure.Vue3/src/views/system/post/utils/hook.tsx @@ -103,7 +103,7 @@ export function usePost() { `确认要${ row.state === false ? "停用" : "启用" }${ - row.roleName + row.postName }吗?`, "系统提示", { @@ -132,7 +132,7 @@ export function usePost() { loading: false } ); - message(`已${row.state === false ? "停用" : "启用"}${row.roleName}`, { + message(`已${row.state === false ? "停用" : "启用"}${row.postName}`, { type: "success" }); }) @@ -143,7 +143,7 @@ export function usePost() { async function handleDelete(row) { await delPost([row.id]); - message(`您删除了角色名称为${row.roleName}的这条数据`, { type: "success" }); + message(`您删除了岗位名称为${row.postName}的这条数据`, { type: "success" }); onSearch(); } diff --git a/readme/edgeone.png b/readme/edgeone.png new file mode 100644 index 00000000..576d9154 Binary files /dev/null and b/readme/edgeone.png differ