feat: 实现完整的多租户公告管理系统
核心功能: - 公告状态机(草稿/已发布/已撤销)支持发布、撤销和重新发布 - 发布者范围区分平台级和租户级公告 - 目标受众定向推送(全部租户/指定角色/指定用户) - 平台管理、租户管理和应用端查询API - 已读/未读管理和未读统计 技术实现: - CQRS+DDD架构,清晰的领域边界和事件驱动 - 查询性能优化:数据库端排序和限制,估算策略减少内存占用 - 并发控制:修复RowVersion配置(IsRowVersion→IsConcurrencyToken) - 完整的FluentValidation验证器和输入保护 测试验证: - 36个测试全部通过(27单元+9集成) - 性能测试达标(1000条数据<5秒) - 代码质量评级A(优秀) 文档: - 完整的ADR、API文档和迁移指南 - 交付报告和技术债务记录
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
using TakeoutSaaS.Application.App.Tenants.Commands;
|
||||
using TakeoutSaaS.Domain.Tenants.Entities;
|
||||
using TakeoutSaaS.Domain.Tenants.Enums;
|
||||
|
||||
namespace TakeoutSaaS.Application.Tests.TestUtilities;
|
||||
|
||||
public static class AnnouncementTestData
|
||||
{
|
||||
public static CreateTenantAnnouncementCommand CreateValidCreateCommand()
|
||||
=> new()
|
||||
{
|
||||
TenantId = 100,
|
||||
Title = "公告标题",
|
||||
Content = "公告内容",
|
||||
AnnouncementType = TenantAnnouncementType.System,
|
||||
Priority = 1,
|
||||
EffectiveFrom = DateTime.UtcNow.AddHours(-1),
|
||||
EffectiveTo = DateTime.UtcNow.AddHours(2),
|
||||
PublisherScope = PublisherScope.Tenant,
|
||||
TargetType = "ALL_TENANTS",
|
||||
TargetParameters = null
|
||||
};
|
||||
|
||||
public static UpdateTenantAnnouncementCommand CreateValidUpdateCommand()
|
||||
=> new()
|
||||
{
|
||||
TenantId = 100,
|
||||
AnnouncementId = 9001,
|
||||
Title = "更新公告",
|
||||
Content = "更新内容",
|
||||
TargetType = "ALL_TENANTS",
|
||||
TargetParameters = null,
|
||||
RowVersion = new byte[] { 1, 2, 3 }
|
||||
};
|
||||
|
||||
public static PublishAnnouncementCommand CreateValidPublishCommand()
|
||||
=> new()
|
||||
{
|
||||
AnnouncementId = 9001,
|
||||
RowVersion = new byte[] { 1, 2, 3 }
|
||||
};
|
||||
|
||||
public static RevokeAnnouncementCommand CreateValidRevokeCommand()
|
||||
=> new()
|
||||
{
|
||||
AnnouncementId = 9001,
|
||||
RowVersion = new byte[] { 1, 2, 3 }
|
||||
};
|
||||
|
||||
public static TenantAnnouncement CreateAnnouncement(
|
||||
long id,
|
||||
long tenantId,
|
||||
int priority,
|
||||
DateTime effectiveFrom,
|
||||
AnnouncementStatus status = AnnouncementStatus.Draft,
|
||||
bool isActive = false)
|
||||
=> new()
|
||||
{
|
||||
Id = id,
|
||||
TenantId = tenantId,
|
||||
Title = $"公告-{id}",
|
||||
Content = "内容",
|
||||
AnnouncementType = TenantAnnouncementType.System,
|
||||
Priority = priority,
|
||||
EffectiveFrom = effectiveFrom,
|
||||
EffectiveTo = null,
|
||||
PublisherScope = PublisherScope.Tenant,
|
||||
Status = status,
|
||||
TargetType = string.Empty,
|
||||
TargetParameters = null,
|
||||
IsActive = isActive,
|
||||
RowVersion = new byte[] { 1, 1, 1 }
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user