diff --git a/docs/content/user-guide/zh/extension/MagicodesIE.md b/docs/content/user-guide/zh/extension/MagicodesIE.md index a8920ece..0dc4abe5 100644 --- a/docs/content/user-guide/zh/extension/MagicodesIE.md +++ b/docs/content/user-guide/zh/extension/MagicodesIE.md @@ -1,4 +1,4 @@ -## 配置 +# 配置 ```csharp /// @@ -35,4 +35,4 @@ public async Task ExportAsync(PagingUserListInput input) return new XlsxFileResult(bytes: bytes, fileDownloadName: $"用户导出列表{DateTime.Now:yyyyMMdd}"); } -``` \ No newline at end of file +``` diff --git a/docs/content/user-guide/zh/infrastructure/cap.md b/docs/content/user-guide/zh/infrastructure/cap.md index 9de5cc30..81f378d8 100644 --- a/docs/content/user-guide/zh/infrastructure/cap.md +++ b/docs/content/user-guide/zh/infrastructure/cap.md @@ -1,8 +1,8 @@ -## dotnetcore.cap +# dotnetcore.cap 分布式事件总线系统允许发布和订阅跨应用/服务边界传输的事件. 你可以使用分布式事件总线在微服务或应用程序之间异步发送和接收消息. -### 安装 +## 安装 - 添加以下 NuGet 包到你的项目 - Lion.AbpPro.CAP diff --git a/docs/content/user-guide/zh/infrastructure/freesql.md b/docs/content/user-guide/zh/infrastructure/freesql.md index e53e3489..0485dc8e 100644 --- a/docs/content/user-guide/zh/infrastructure/freesql.md +++ b/docs/content/user-guide/zh/infrastructure/freesql.md @@ -1,4 +1,5 @@ -### CQRS +# CQRS + CQRS:命令查询职责隔离,命令是指 插入、修改、删除,就是更改数据的动作.通过 Freesql 解决单一数据模型带来的查询尴尬场面。 当前架构下,Freesql 和 ef 不在一个事务,最好实现就是用来做查询,比如分页查询。 ![](https://blog-resouce.oss-cn-shenzhen.aliyuncs.com/images/abp/cqrs.png) diff --git a/docs/content/user-guide/zh/modules/file.md b/docs/content/user-guide/zh/modules/file.md index 36b14fc1..80ceff59 100644 --- a/docs/content/user-guide/zh/modules/file.md +++ b/docs/content/user-guide/zh/modules/file.md @@ -1,7 +1,7 @@ -# 数据字典模块 +# 文件模块 -- 与abp自带的文件模块不一样,此模块接入阿里云oss作为云存储。 -- 前端上传文件到OSS,文件模块保存相对路径。 +- 与 abp 自带的文件模块不一样,此模块接入阿里云 oss 作为云存储。 +- 前端上传文件到 OSS,文件模块保存相对路径。 ![](../../../img/file.png) @@ -15,34 +15,37 @@ - Lion.Abp.FileManagement.HttpApi - Lion.Abp.FileManagement.HttpApi.Client - ## 模块依赖 - 添加 DependsOn(typeof(FileManagementXxxModule)) 特性到对应模块。 -- 在EntityFrameworkCore层添加数据库配置在AbpProDbContext.cs的OnModelCreating()方法中添加builder.ConfigureFileManagement(); +- 在 EntityFrameworkCore 层添加数据库配置在 AbpProDbContext.cs 的 OnModelCreating()方法中添加 builder.ConfigureFileManagement(); ## 实体 + **File** 表结构: -字段名 | 描述 | 类型 -:---|:---|:--- -Id | Id | Guid -TenantId | 租户id | Guid? -FileName | 文件名称 | string -FilePath | 文件路径 | string -IsDeleted | 是否删除 | bool -DeleterId | 删除人 | Guid? -DeletionTime | 删除时间 | DateTime -LastModifierId | 最后修改人 | Guid? -LastModificationTime | 最后修改时间 | DateTime -CreatorId | 创建人 | Guid? -CreationTime | 创建时间 | DateTime - -## OSS配置 -[阿里云OSS配置](https://help.aliyun.com/document_detail/100624.html) - -- 将OSS配置添加到AppSetting -## AppSetting配置 +| 字段名 | 描述 | 类型 | +| :------------------- | :----------- | :------- | +| Id | Id | Guid | +| TenantId | 租户 id | Guid? | +| FileName | 文件名称 | string | +| FilePath | 文件路径 | string | +| IsDeleted | 是否删除 | bool | +| DeleterId | 删除人 | Guid? | +| DeletionTime | 删除时间 | DateTime | +| LastModifierId | 最后修改人 | Guid? | +| LastModificationTime | 最后修改时间 | DateTime | +| CreatorId | 创建人 | Guid? | +| CreationTime | 创建时间 | DateTime | + +## OSS 配置 + +[阿里云 OSS 配置](https://help.aliyun.com/document_detail/100624.html) + +- 将 OSS 配置添加到 AppSetting + +## AppSetting 配置 + ```Json "AliYun": { "OSS": { @@ -57,4 +60,5 @@ CreationTime | 创建时间 | DateTime ``` ## 上传组件 -- [前端UploadOss.ts](https://github.com/WangJunZzz/abp-vnext-pro/blob/main/vben28/src/views/admin/files/UploadOss.ts) \ No newline at end of file + +- [前端 UploadOss.ts](https://github.com/WangJunZzz/abp-vnext-pro/blob/main/vben28/src/views/admin/files/UploadOss.ts) diff --git a/docs/content/user-guide/zh/modules/signalr.md b/docs/content/user-guide/zh/modules/signalr.md index 90dd81ec..d8e2eb99 100644 --- a/docs/content/user-guide/zh/modules/signalr.md +++ b/docs/content/user-guide/zh/modules/signalr.md @@ -1,5 +1,6 @@ # 实时通信 -集成Abp SignalR,实现类似站内信模块。 + +集成 Abp SignalR,实现类似站内信模块。 - 发送消息会在前端右上角,根据不同消息等级有不同的窗体提示。 @@ -23,47 +24,50 @@ - 添加 DependsOn(typeof(NotificationManagementXxxModule)) 特性到对应模块。 -- 在EntityFrameworkCore层添加数据库配置在AbpProDbContext.cs的OnModelCreating()方法中添加builder.ConfigureNotificationManagement(); +- 在 EntityFrameworkCore 层添加数据库配置在 AbpProDbContext.cs 的 OnModelCreating()方法中添加 builder.ConfigureNotificationManagement(); ## 实体 + **Notification** 表结构: -字段名 | 描述 | 类型 -:---|:---|:--- -Id | Id | Guid -Title | 消息标题 | string -Content | 消息内容 | string -MessageType | 消息类型 | MessageType -MessageLevel | 消息等级 | MessageLevel -SenderId | 创建人 | 发送人 -NotificationSubscriptions | 消息订阅者集合 | List -IsDeleted | 是否删除 | bool -DeleterId | 删除人 | Guid? -DeletionTime | 删除时间 | DateTime -LastModifierId | 最后修改人 | Guid? -LastModificationTime | 最后修改时间 | DateTime -CreatorId | 创建人 | Guid? -CreationTime | 创建时间 | DateTime +| 字段名 | 描述 | 类型 | +| :------------------------ | :------------- | :----------------------------- | +| Id | Id | Guid | +| Title | 消息标题 | string | +| Content | 消息内容 | string | +| MessageType | 消息类型 | MessageType | +| MessageLevel | 消息等级 | MessageLevel | +| SenderId | 创建人 | 发送人 | +| NotificationSubscriptions | 消息订阅者集合 | List | +| IsDeleted | 是否删除 | bool | +| DeleterId | 删除人 | Guid? | +| DeletionTime | 删除时间 | DateTime | +| LastModifierId | 最后修改人 | Guid? | +| LastModificationTime | 最后修改时间 | DateTime | +| CreatorId | 创建人 | Guid? | +| CreationTime | 创建时间 | DateTime | **NotificationSubscription** 表结构: -字段名 | 描述 | 类型 -:---|:---|:--- -Id | Id | Guid -ReceiveId | 接收人 | Guid -Read | 是否已读 | bool -ReadTime | 已读时间 | DateTime? -IsDeleted | 是否删除 | bool -DeleterId | 删除人 | Guid? -DeletionTime | 删除时间 | DateTime -LastModifierId | 最后修改人 | Guid? -LastModificationTime | 最后修改时间 | DateTime -CreatorId | 创建人 | Guid? -CreationTime | 创建时间 | DateTime +| 字段名 | 描述 | 类型 | +| :------------------- | :----------- | :-------- | +| Id | Id | Guid | +| ReceiveId | 接收人 | Guid | +| Read | 是否已读 | bool | +| ReadTime | 已读时间 | DateTime? | +| IsDeleted | 是否删除 | bool | +| DeleterId | 删除人 | Guid? | +| DeletionTime | 删除时间 | DateTime | +| LastModifierId | 最后修改人 | Guid? | +| LastModificationTime | 最后修改时间 | DateTime | +| CreatorId | 创建人 | Guid? | +| CreationTime | 创建时间 | DateTime | ## 发送消息 -- 注入NotificationManager,NotificationAppService即可发送不同级别,不同等级的消息。 + +- 注入 NotificationManager,NotificationAppService 即可发送不同级别,不同等级的消息。 - 发送给指定人 + ```csharp /// /// 发送警告文本消息 @@ -73,7 +77,9 @@ CreationTime | 创建时间 | DateTime /// 接受人,发送给谁。 await _notificationManager.SendCommonWarningMessageAsync(title,content,receiveIds); ``` + - 发送给所有人 + ```csharp /// /// 发送警告文本消息 @@ -84,7 +90,9 @@ await _notificationManager.SendBroadCastInformationMessageAsync(title,content); ``` ## 依赖 -- 如果服务分布式部署,需要使用Redis(默认依赖),解决SignalR消息重复问题。 + +- 如果服务分布式部署,需要使用 Redis(默认依赖),解决 SignalR 消息重复问题。 + ```csharp private void ConfigurationSignalR(ServiceConfigurationContext context) { @@ -98,14 +106,14 @@ private void ConfigurationSignalR(ServiceConfigurationContext context) } ``` -## Vue客户端连接 -- 在用户登陆成功之后,连接SignalR,并且带自动重连机制。[源码](https://github.com/WangJunZzz/abp-vnext-pro/blob/main/vben28/src/hooks/web/useSignalR.ts) -- 示例如下: +## Vue 客户端连接 +- 在用户登陆成功之后,连接 SignalR,并且带自动重连机制。[源码](https://github.com/WangJunZzz/abp-vnext-pro/blob/main/vben28/src/hooks/web/useSignalR.ts) +- 示例如下: ```ts const { startConnect } = useSignalR(); - onMounted(() => { - startConnect(); - }); -``` \ No newline at end of file +onMounted(() => { + startConnect(); +}); +``` diff --git a/docs/content/user-guide/zh/problem/ef.md b/docs/content/user-guide/zh/problem/ef.md new file mode 100644 index 00000000..7165d2d1 --- /dev/null +++ b/docs/content/user-guide/zh/problem/ef.md @@ -0,0 +1,134 @@ +# EFCore + +## 创建时间,更新时间,删除时间 + +- 当实体继承了这三个属性得时候,只有在新增才会又创建时间,如果想要也有更新时间如何处理呢? + +- 解决方式:重写 DbContext 一下方法 + +```csharp +namespace Lion.AbpPro.EntityFrameworkCore +{ + [ConnectionStringName("Default")] + public class AbpProDbContext : + AbpDbContext, + IAbpProDbContext + { + protected override void SetCreationAuditProperties(EntityEntry entry) + { + SetModificationAuditProperties(entry); + base.SetCreationAuditProperties(entry); + } + + protected override void SetDeletionAuditProperties(EntityEntry entry) + { + SetModificationAuditProperties(entry); + base.SetDeletionAuditProperties(entry); + } + } +} +``` + +## 设置数据库字符集格式 + +```csharp +namespace Lion.AbpPro.EntityFrameworkCore +{ + [ConnectionStringName("Default")] + public class AbpProDbContext : + AbpDbContext, + IAbpProDbContext + { + protected override void OnModelCreating(ModelBuilder builder) + { + builder.UseCollation("utf8mb4_unicode_ci"); + builder.UseGuidCollation("utf8mb4_unicode_ci"); + base.OnModelCreating(builder); + } + } +} +``` + +## 全局设置字符串长度 + +- 当数据类型是 string 时,需要给每个字段指定长度很麻烦,以下提供统一处理方式。 + +```csharp +namespace Lion.Pro.EntityFrameworkCore; + +/// +/// ef迁移全局设置 +/// +public static class LionDbContextGlobalSettingExtensions +{ + private const string Remark = "Remark"; + private const string Description = "Description"; + private const string CreationTime = "CreationTime"; + private const string IndexPrefix = "IX_Default_"; + + public static void ConfigureGlobalSetting(this ModelBuilder builder) + { + ConfigureDefaultMaxLength(builder); + ConfigureIndexForCreationTime(builder); + } + + /// + /// 配置默认字符串长度 + /// + private static void ConfigureDefaultMaxLength(ModelBuilder builder) + { + var rules = ConfigureEntityMaxLengthOptions.Configure(); + // 如果是abp表不全局修改长度 + foreach (var property in builder.Model + .GetEntityTypes() + .Where(e => !e.GetTableName().StartsWith(AbpCommonDbProperties.DbTablePrefix)) + .SelectMany(t => t.GetProperties()) + .Where(e => e.ClrType == typeof(string))) + { + // 默认设置128长度 + if (property.GetMaxLength() == null) + { + property.SetMaxLength(128); + } + + } + } + + /// + /// 创建时间添加索引 + /// + private static void ConfigureIndexForCreationTime(ModelBuilder builder) + { + foreach (var property in builder.Model + .GetEntityTypes() + .Where(e => !e.GetTableName().StartsWith(AbpCommonDbProperties.DbTablePrefix)) + .SelectMany(t => t.GetProperties()) + .Where(e => e.Name == CreationTime)) + { + var entityType = builder.Model.GetEntityTypes().Where(e => e.ClrType == property.DeclaringEntityType.ClrType).ToList().FirstOrDefault(); + var indexName = IndexPrefix + entityType.GetTableName() + "_" + property.Name; + if (entityType.FindIndex(indexName) == null) + { + entityType?.AddIndex(property, indexName); + } + } + } +} +``` + +```csharp +namespace Lion.AbpPro.EntityFrameworkCore +{ + [ConnectionStringName("Default")] + public class AbpProDbContext : + AbpDbContext, + IAbpProDbContext + { + protected override void OnModelCreating(ModelBuilder builder) + { + builder.ConfigureGlobalSetting(); + base.OnModelCreating(builder); + } + } +} +``` diff --git a/docs/content/user-guide/zh/problem/problem.md b/docs/content/user-guide/zh/problem/problem.md index 2a7d2867..24979cda 100644 --- a/docs/content/user-guide/zh/problem/problem.md +++ b/docs/content/user-guide/zh/problem/problem.md @@ -1,5 +1,5 @@ -## 编译 +# 编译 -### VS 编译项目字符串超过 256 个字符 +## VS 编译项目字符串超过 256 个字符 -- 把项目拷贝到磁盘根目录 OR 使用 Rider 开发 \ No newline at end of file +- 把项目拷贝到磁盘根目录 OR 使用 Rider 开发 diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 5d96139e..aabdd9d3 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -18,6 +18,7 @@ theme: palette: primary: "deep purple" accent: "indigo" + scheme: slate language: en include_sidebar: true logo: "img/logo.svg" @@ -92,7 +93,8 @@ nav: - Docker: user-guide/zh/deploy/docker.md - Github自动化部署: user-guide/zh/deploy/github.md - 常见问题: - - 问题: user-guide/zh/problem/problem.md + - 编译: user-guide/zh/problem/problem.md + - EFCore: user-guide/zh/problem/ef.md - Release: - 升级指南: about/6.0-7.0.md - 发行说明: about/release-notes.md diff --git a/vben28/src/locales/lang/en/routes/admin.ts b/vben28/src/locales/lang/en/routes/admin.ts index 89826f14..b1983a9d 100644 --- a/vben28/src/locales/lang/en/routes/admin.ts +++ b/vben28/src/locales/lang/en/routes/admin.ts @@ -46,6 +46,9 @@ export default { audit_hasException_yes: 'Yes', audit_hasException_no: 'No', audit_applicationName: 'ApplicationName', + audit_serviceName: 'serviceName', + audit_methodName: 'methodName', + audit_parameters: 'parameters', grantedMessage: 'Authorization Successful, Please Login Again.', close: 'close', auditLog: 'AuditLog', diff --git a/vben28/src/locales/lang/zh-CN/routes/admin.ts b/vben28/src/locales/lang/zh-CN/routes/admin.ts index d491368d..f8ce76aa 100644 --- a/vben28/src/locales/lang/zh-CN/routes/admin.ts +++ b/vben28/src/locales/lang/zh-CN/routes/admin.ts @@ -43,6 +43,9 @@ export default { audit_hasException_all: '全部', audit_hasException_yes: '是', audit_hasException_no: '否', + audit_serviceName: '服务名', + audit_methodName: '方法名', + audit_parameters: '参数', grantedMessage: '授权成功,请重新登录.', close: '关闭',