using MyHomePage.Api.Models.Entities;
namespace MyHomePage.Api.Models.Dtos;
/// 搜索引擎输出 DTO
public class SearchEngineDto
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string UrlTemplate { get; set; } = string.Empty;
public string IconType { get; set; } = "lucide";
public string? Icon { get; set; }
public string? IconUrl { get; set; }
public string? ColorBg { get; set; }
public int Sort { get; set; }
public bool IsDefault { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
/// 从实体映射(中心化转换,防止漏字段,与 BookmarkDto.FromEntity 对齐)
public static SearchEngineDto FromEntity(SearchEngine e) => new()
{
Id = e.Id,
Name = e.Name,
UrlTemplate = e.UrlTemplate,
IconType = e.IconType,
Icon = e.Icon,
IconUrl = e.IconUrl,
ColorBg = e.ColorBg,
Sort = e.Sort,
IsDefault = e.IsDefault,
CreatedAt = e.CreatedAt,
UpdatedAt = e.UpdatedAt
};
}
/// 搜索引擎创建/更新入参
public class SearchEngineUpsertRequest
{
public int? Id { get; set; }
public string Name { get; set; } = string.Empty;
public string UrlTemplate { get; set; } = string.Empty;
public string IconType { get; set; } = "lucide";
public string? Icon { get; set; }
public string? IconUrl { get; set; }
public string? ColorBg { get; set; }
public int Sort { get; set; }
public bool IsDefault { get; set; }
}