using MyHomePage.Api.Models.Entities; namespace MyHomePage.Api.Models.Dtos; /// 链接输出 DTO public class BookmarkDto { public int Id { get; set; } public int CategoryId { get; set; } public string Title { get; set; } = string.Empty; public string Url { get; set; } = string.Empty; public string? Description { get; set; } public string? Icon { get; set; } public string IconType { get; set; } = "lucide"; public string? IconUrl { get; set; } public string? ColorBg { get; set; } public int Sort { get; set; } public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } /// /// 集中映射 Bookmark → BookmarkDto。BookmarkService / SyncService 共用, /// 避免手写 new BookmarkDto { ... } 漏字段(P28 Bug 教训)。 /// public static BookmarkDto FromEntity(Bookmark b) => new() { Id = b.Id, CategoryId = b.CategoryId, Title = b.Title, Url = b.Url, Description = b.Description, Icon = b.Icon, IconType = b.IconType, IconUrl = b.IconUrl, ColorBg = b.ColorBg, Sort = b.Sort, CreatedAt = b.CreatedAt, UpdatedAt = b.UpdatedAt }; } /// 链接创建/更新入参 public class BookmarkUpsertRequest { public int? Id { get; set; } public int CategoryId { get; set; } public string Title { get; set; } = string.Empty; public string Url { get; set; } = string.Empty; public string? Description { get; set; } public string? Icon { get; set; } public string? IconType { get; set; } public string? IconUrl { get; set; } public string? ColorBg { get; set; } public int Sort { get; set; } }