fix: 修复公告模块核心问题并完善功能
主要修复内容: 1. 修复 RowVersion 并发控制 - 配置 EF Core RowVersion 映射为 bytea 类型 - 添加 PostgreSQL 触发器自动生成 RowVersion - 在更新/发布/撤销操作中添加 RowVersion 校验 - 移除 Application 层对 EF Core 的直接依赖 2. 修复 API 路由和校验问题 - 添加平台公告列表路由的版本化别名 - 租户公告接口添加 X-Tenant-Id 必填校验,返回 400 - 生效时间校验返回 422 而非 500 - 修复 FluentValidation 异常命名冲突 3. 实现关键词搜索功能 - 在查询参数中添加 keyword 字段 - 使用 PostgreSQL ILIKE 实现大小写不敏感搜索 - 支持标题和内容字段的模糊匹配 4. 数据库迁移 - 新增 RowVersion 触发器迁移文件 - 回填现有公告记录的 RowVersion
This commit is contained in:
@@ -164,7 +164,7 @@ public sealed class AnnouncementWorkflowTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GivenStaleRowVersion_WhenUpdate_ThenThrowsConcurrencyException()
|
||||
public async Task GivenStaleRowVersion_WhenUpdate_ThenReturnsConflict()
|
||||
{
|
||||
// Arrange
|
||||
using var database = new SqliteTestDatabase();
|
||||
@@ -197,7 +197,8 @@ public sealed class AnnouncementWorkflowTests
|
||||
Func<Task> act = async () => await handler.Handle(command, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await act.Should().ThrowAsync<DbUpdateConcurrencyException>();
|
||||
var exception = await act.Should().ThrowAsync<BusinessException>();
|
||||
exception.Which.ErrorCode.Should().Be(ErrorCodes.Conflict);
|
||||
}
|
||||
|
||||
private static TenantAnnouncement CreateDraftAnnouncement(long tenantId, long id)
|
||||
|
||||
Reference in New Issue
Block a user