using System.ComponentModel.DataAnnotations; using Tiku.Application.Content; namespace Tiku.Api.Contracts; /// /// 内容Navigation查询参数。 /// public sealed class ContentNavigationQueryDto { /// /// 租户编码。 /// [StringLength(100)] public string? TenantCode { get; set; } /// /// 地区 ID。 /// public Guid? RegionId { get; set; } /// /// 内容入口 ID。 /// public Guid? EntryId { get; set; } /// /// 节点 ID。 /// public Guid? NodeId { get; set; } /// /// 题集 ID。 /// public Guid? CollectionId { get; set; } /// /// 父节点 ID;传 root 表示根节点。 /// [StringLength(64)] [RegularExpression("^(root|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$")] public string? ParentId { get; set; } /// /// 入口类型。 /// [StringLength(50)] public string? EntryType { get; set; } /// /// 题集类型。 /// [StringLength(50)] public string? CollectionType { get; set; } /// /// 模式。 /// [StringLength(50)] public string? Mode { get; set; } /// /// 标记类型。 /// [StringLength(50)] public string? MarkerType { get; set; } /// /// 关键字。 /// [StringLength(100)] public string? Keyword { get; set; } /// /// 是否包含隐藏数据。 /// public bool IncludeHidden { get; set; } /// /// 是否包含停用数据。 /// public bool IncludeInactive { get; set; } /// /// 返回数量上限。 /// [Range(1, 1000)] public int? Limit { get; set; } public ContentNavigationFilter ToFilter(Guid tenantId) { var parentWasSpecified = ParentId is not null; var parentIsRoot = string.Equals(ParentId, "root", StringComparison.OrdinalIgnoreCase); Guid? parentId = parentIsRoot || string.IsNullOrWhiteSpace(ParentId) ? null : Guid.Parse(ParentId); return new ContentNavigationFilter( tenantId, RegionId, EntryId, NodeId, CollectionId, parentId, parentWasSpecified, parentIsRoot, EntryType, CollectionType, Mode, MarkerType, Keyword, IncludeHidden, IncludeInactive, Limit); } }