forked from gongxuegit/tiku-backend.net
feat: add catalog readonly endpoints
This commit is contained in:
90
Tiku.Api/Contracts/CatalogDtos.cs
Normal file
90
Tiku.Api/Contracts/CatalogDtos.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Tiku.Application.Catalog;
|
||||
|
||||
namespace Tiku.Api.Contracts;
|
||||
|
||||
public sealed class CatalogQueryDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 租户编码。未登录公开查询时使用;已登录时优先使用当前 token 的租户。
|
||||
/// </summary>
|
||||
[StringLength(100)]
|
||||
public string? TenantCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地区 ID。
|
||||
/// </summary>
|
||||
public Guid? RegionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 功能模块 ID。
|
||||
/// </summary>
|
||||
public Guid? ModuleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 父节点 ID;传 root 表示根节点。
|
||||
/// </summary>
|
||||
[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; }
|
||||
|
||||
/// <summary>
|
||||
/// 院校 ID。
|
||||
/// </summary>
|
||||
public Guid? SchoolId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 专业 ID。
|
||||
/// </summary>
|
||||
public Guid? MajorId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 科目 ID。
|
||||
/// </summary>
|
||||
public Guid? SubjectId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 导航节点 ID。
|
||||
/// </summary>
|
||||
public Guid? NodeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称关键词。
|
||||
/// </summary>
|
||||
[StringLength(100)]
|
||||
public string? Keyword { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类型过滤,例如 cultural、professional、chapter、paper。
|
||||
/// </summary>
|
||||
[StringLength(50)]
|
||||
public string? Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回条数上限。
|
||||
/// </summary>
|
||||
[Range(1, 2000)]
|
||||
public int? Limit { get; set; }
|
||||
|
||||
public CatalogFilter ToFilter(Guid tenantId)
|
||||
{
|
||||
var parentIsRoot = string.Equals(ParentId, "root", StringComparison.OrdinalIgnoreCase);
|
||||
Guid? parentId = parentIsRoot || string.IsNullOrWhiteSpace(ParentId)
|
||||
? null
|
||||
: Guid.Parse(ParentId);
|
||||
|
||||
return new CatalogFilter(
|
||||
tenantId,
|
||||
RegionId,
|
||||
ModuleId,
|
||||
parentId,
|
||||
parentIsRoot,
|
||||
SchoolId,
|
||||
MajorId,
|
||||
SubjectId,
|
||||
NodeId,
|
||||
Keyword,
|
||||
Type,
|
||||
Limit);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user