Merge branch 'abp' into ai-hub
This commit is contained in:
10
README.md
10
README.md
@@ -7,6 +7,12 @@
|
|||||||
[](https://gitee.com/ccnetcore/Yi)
|
[](https://gitee.com/ccnetcore/Yi)
|
||||||
[](https://gitee.com/ccnetcore/Yi)
|
[](https://gitee.com/ccnetcore/Yi)
|
||||||
|
|
||||||
|
本项目 CDN 加速及安全防护由 Tencent EdgeOne 赞助
|
||||||
|
|
||||||
|
[亚洲最佳CDN、边缘和安全解决方案 - Tencent EdgeOne](https://edgeone.ai/zh?from=github)
|
||||||
|
|
||||||
|
<img src="readme/edgeone.png"/>
|
||||||
|
|
||||||
[English](README-en.md) | 简体中文
|
[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) (已上线,欢迎加入)
|
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)
|
||||||
|
|
||||||
## 🍏 支持:
|
## 🍏 支持:
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// MIT 许可证
|
// MIT 许可证
|
||||||
//
|
//
|
||||||
// 版权 © 2020-present 百小僧, 百签科技(广东)有限公司 和所有贡献者
|
// 版权 © 2020-present 百小僧, 百签科技(广东)有限公司 和所有贡献者
|
||||||
//
|
//
|
||||||
@@ -17,25 +17,25 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Volo.Abp.AspNetCore.Mvc;
|
using Volo.Abp.AspNetCore.Mvc;
|
||||||
using Volo.Abp.DependencyInjection;
|
using Volo.Abp.Validation;
|
||||||
using Yi.Framework.Core.Extensions;
|
using Yi.Framework.Core.Extensions;
|
||||||
|
|
||||||
namespace Yi.Framework.AspNetCore.UnifyResult.Fiters;
|
namespace Yi.Framework.AspNetCore.UnifyResult.Fiters;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 友好异常拦截器
|
/// 友好异常拦截器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter
|
public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异常拦截
|
/// 异常拦截
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context"></param>
|
/// <param name="context"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task OnExceptionAsync(ExceptionContext context)
|
public async Task OnExceptionAsync(ExceptionContext context)
|
||||||
{
|
{
|
||||||
|
|
||||||
// 排除 WebSocket 请求处理
|
// 排除 WebSocket 请求处理
|
||||||
if (context.HttpContext.IsWebSocketRequest()) return;
|
if (context.HttpContext.IsWebSocketRequest()) return;
|
||||||
|
|
||||||
@@ -44,20 +44,23 @@ public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter
|
|||||||
|
|
||||||
// 解析异常信息
|
// 解析异常信息
|
||||||
var exceptionMetadata = GetExceptionMetadata(context);
|
var exceptionMetadata = GetExceptionMetadata(context);
|
||||||
|
var unifyResult = context.GetRequiredService<IUnifyResultProvider>();
|
||||||
IUnifyResultProvider unifyResult = context.GetRequiredService<IUnifyResultProvider>();
|
|
||||||
// 执行规范化异常处理
|
// 执行规范化异常处理
|
||||||
context.Result = unifyResult.OnException(context, exceptionMetadata);
|
context.Result = unifyResult.OnException(context, exceptionMetadata);
|
||||||
|
|
||||||
// 创建日志记录器
|
// 创建日志记录器
|
||||||
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<FriendlyExceptionFilter>>();
|
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<FriendlyExceptionFilter>>();
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取异常元数据
|
/// 获取异常元数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context"></param>
|
/// <param name="context"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@@ -74,22 +77,25 @@ public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter
|
|||||||
// 判断是否是 ExceptionContext 或者 ActionExecutedContext
|
// 判断是否是 ExceptionContext 或者 ActionExecutedContext
|
||||||
var exception = context is ExceptionContext exContext
|
var exception = context is ExceptionContext exContext
|
||||||
? exContext.Exception
|
? exContext.Exception
|
||||||
: (
|
: context is ActionExecutedContext edContext
|
||||||
context is ActionExecutedContext edContext
|
? edContext.Exception
|
||||||
? edContext.Exception
|
: default;
|
||||||
: default
|
|
||||||
);
|
if (exception is AbpValidationException validationException)
|
||||||
|
{
|
||||||
|
errors = validationException.ValidationErrors;
|
||||||
|
isValidationException = true;
|
||||||
|
}
|
||||||
|
|
||||||
// 判断是否是友好异常
|
// 判断是否是友好异常
|
||||||
if (exception is UserFriendlyException friendlyException)
|
if (exception is UserFriendlyException friendlyException)
|
||||||
{
|
{
|
||||||
int statusCode2 = 500;
|
var statusCode2 = 500;
|
||||||
int.TryParse(friendlyException.Code, out statusCode2);
|
int.TryParse(friendlyException.Code, out statusCode2);
|
||||||
isFriendlyException = true;
|
isFriendlyException = true;
|
||||||
errorCode = friendlyException.Code;
|
errorCode = friendlyException.Code;
|
||||||
originErrorCode = friendlyException.Code;
|
originErrorCode = friendlyException.Code;
|
||||||
statusCode = statusCode2==0?403:statusCode2;
|
statusCode = statusCode2 == 0 ? 403 : statusCode2;
|
||||||
isValidationException = false;
|
|
||||||
errors = friendlyException.Message;
|
errors = friendlyException.Message;
|
||||||
data = friendlyException.Data;
|
data = friendlyException.Data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
using Volo.Abp.AspNetCore.Mvc.ExceptionHandling;
|
using Volo.Abp.AspNetCore.Mvc.ExceptionHandling;
|
||||||
|
using Volo.Abp.AspNetCore.Mvc.Response;
|
||||||
using Yi.Framework.AspNetCore.UnifyResult.Fiters;
|
using Yi.Framework.AspNetCore.UnifyResult.Fiters;
|
||||||
|
|
||||||
namespace Yi.Framework.AspNetCore.UnifyResult;
|
namespace Yi.Framework.AspNetCore.UnifyResult;
|
||||||
@@ -20,9 +21,10 @@ public static class UnifyResultExtensions
|
|||||||
services.AddTransient<FriendlyExceptionFilter>();
|
services.AddTransient<FriendlyExceptionFilter>();
|
||||||
services.AddMvc(options =>
|
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<SucceededUnifyResultFilter>(99);
|
options.Filters.AddService<SucceededUnifyResultFilter>(99);
|
||||||
options.Filters.AddService<FriendlyExceptionFilter>(100);
|
options.Filters.AddService<FriendlyExceptionFilter>(100);
|
||||||
options.Filters.RemoveAll(x => (x as ServiceFilterAttribute)?.ServiceType == typeof(AbpExceptionFilter));
|
|
||||||
});
|
});
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Volo.Abp.Modularity;
|
using Volo.Abp.Modularity;
|
||||||
using Volo.Abp.ObjectMapping;
|
using Volo.Abp.ObjectMapping;
|
||||||
using Yi.Framework.Core;
|
using Yi.Framework.Core;
|
||||||
|
using Mapster;
|
||||||
|
|
||||||
namespace Yi.Framework.Mapster
|
namespace Yi.Framework.Mapster
|
||||||
{
|
{
|
||||||
@@ -22,7 +23,8 @@ namespace Yi.Framework.Mapster
|
|||||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||||
{
|
{
|
||||||
var services = context.Services;
|
var services = context.Services;
|
||||||
|
// 扫描并注册所有映射配置
|
||||||
|
TypeAdapterConfig.GlobalSettings.Scan(AppDomain.CurrentDomain.GetAssemblies());
|
||||||
// 注册Mapster相关服务
|
// 注册Mapster相关服务
|
||||||
services.AddTransient<IAutoObjectMappingProvider, MapsterAutoObjectMappingProvider>();
|
services.AddTransient<IAutoObjectMappingProvider, MapsterAutoObjectMappingProvider>();
|
||||||
services.AddTransient<IObjectMapper, MapsterObjectMapper>();
|
services.AddTransient<IObjectMapper, MapsterObjectMapper>();
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace Yi.Framework.Rbac.Application.Services.System
|
|||||||
.WhereIF(!string.IsNullOrEmpty(input.DeptName), u => u.DeptName.Contains(input.DeptName!))
|
.WhereIF(!string.IsNullOrEmpty(input.DeptName), u => u.DeptName.Contains(input.DeptName!))
|
||||||
.WhereIF(input.State is not null, u => u.State == input.State)
|
.WhereIF(input.State is not null, u => u.State == input.State)
|
||||||
.OrderBy(u => u.OrderNum, OrderByType.Asc)
|
.OrderBy(u => u.OrderNum, OrderByType.Asc)
|
||||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
.ToListAsync();
|
||||||
return new PagedResultDto<DeptGetListOutputDto>
|
return new PagedResultDto<DeptGetListOutputDto>
|
||||||
{
|
{
|
||||||
Items = await MapToGetListOutputDtosAsync(entities),
|
Items = await MapToGetListOutputDtosAsync(entities),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using Volo.Abp.Application.Dtos;
|
using Volo.Abp.Application.Dtos;
|
||||||
using Yi.Framework.Ddd.Application;
|
using Yi.Framework.Ddd.Application;
|
||||||
@@ -54,5 +55,25 @@ namespace Yi.Framework.Rbac.Application.Services.System
|
|||||||
throw new UserFriendlyException(RoleConst.Exist);
|
throw new UserFriendlyException(RoleConst.Exist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新状态
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="state"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Route("post/{id}/{state}")]
|
||||||
|
public async Task<PostGetOutputDto> 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,8 +34,7 @@ namespace Yi.Framework.Rbac.Domain.Entities
|
|||||||
var type = GetFileType();
|
var type = GetFileType();
|
||||||
|
|
||||||
var savePath = GetSaveFilePath();
|
var savePath = GetSaveFilePath();
|
||||||
var filePath = Path.Combine(savePath, this.FileName);
|
this.FilePath = savePath;
|
||||||
this.FilePath = filePath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ using Yi.Framework.AspNetCore.Authentication.OAuth.Gitee;
|
|||||||
using Yi.Framework.AspNetCore.Authentication.OAuth.QQ;
|
using Yi.Framework.AspNetCore.Authentication.OAuth.QQ;
|
||||||
using Yi.Framework.AspNetCore.Microsoft.AspNetCore.Builder;
|
using Yi.Framework.AspNetCore.Microsoft.AspNetCore.Builder;
|
||||||
using Yi.Framework.AspNetCore.Microsoft.Extensions.DependencyInjection;
|
using Yi.Framework.AspNetCore.Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Yi.Framework.AspNetCore.UnifyResult;
|
||||||
using Yi.Framework.BackgroundWorkers.Hangfire;
|
using Yi.Framework.BackgroundWorkers.Hangfire;
|
||||||
using Yi.Framework.Bbs.Application;
|
using Yi.Framework.Bbs.Application;
|
||||||
using Yi.Framework.Bbs.Application.Extensions;
|
using Yi.Framework.Bbs.Application.Extensions;
|
||||||
@@ -125,6 +126,7 @@ namespace Yi.Abp.Web
|
|||||||
});
|
});
|
||||||
|
|
||||||
//采用furion格式的规范化api,默认不开启,使用abp优雅的方式
|
//采用furion格式的规范化api,默认不开启,使用abp优雅的方式
|
||||||
|
//前置:需要将管道工作单元前加上app.Properties.Add("_AbpExceptionHandlingMiddleware_Added",false);
|
||||||
//你没看错。。。
|
//你没看错。。。
|
||||||
//service.AddFurionUnifyResultApi();
|
//service.AddFurionUnifyResultApi();
|
||||||
|
|
||||||
@@ -400,8 +402,7 @@ namespace Yi.Abp.Web
|
|||||||
app.UseDefaultFiles();
|
app.UseDefaultFiles();
|
||||||
app.UseDirectoryBrowser("/api/app/wwwroot");
|
app.UseDirectoryBrowser("/api/app/wwwroot");
|
||||||
|
|
||||||
|
//app.Properties.Add("_AbpExceptionHandlingMiddleware_Added",false);
|
||||||
// app.Properties.Add("_AbpExceptionHandlingMiddleware_Added",false);
|
|
||||||
//工作单元
|
//工作单元
|
||||||
app.UseUnitOfWork();
|
app.UseUnitOfWork();
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ export function usePost() {
|
|||||||
`确认要<strong>${
|
`确认要<strong>${
|
||||||
row.state === false ? "停用" : "启用"
|
row.state === false ? "停用" : "启用"
|
||||||
}</strong><strong style='color:var(--el-color-primary)'>${
|
}</strong><strong style='color:var(--el-color-primary)'>${
|
||||||
row.roleName
|
row.postName
|
||||||
}</strong>吗?`,
|
}</strong>吗?`,
|
||||||
"系统提示",
|
"系统提示",
|
||||||
{
|
{
|
||||||
@@ -132,7 +132,7 @@ export function usePost() {
|
|||||||
loading: false
|
loading: false
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
message(`已${row.state === false ? "停用" : "启用"}${row.roleName}`, {
|
message(`已${row.state === false ? "停用" : "启用"}${row.postName}`, {
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@@ -143,7 +143,7 @@ export function usePost() {
|
|||||||
|
|
||||||
async function handleDelete(row) {
|
async function handleDelete(row) {
|
||||||
await delPost([row.id]);
|
await delPost([row.id]);
|
||||||
message(`您删除了角色名称为${row.roleName}的这条数据`, { type: "success" });
|
message(`您删除了岗位名称为${row.postName}的这条数据`, { type: "success" });
|
||||||
onSearch();
|
onSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
readme/edgeone.png
Normal file
BIN
readme/edgeone.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Reference in New Issue
Block a user