using System.ComponentModel.DataAnnotations;
using System.Text.Json;
using Tiku.Application.Catalog;
using Tiku.Domain.Catalog;
using Tiku.Domain.Common;
using Tiku.Domain.Content;

namespace Tiku.Api.Contracts;

public sealed class CreateTaxonomyNodeDto
{
    public Guid? ParentId { get; set; }
    public QuestionSource? ParentSource { get; set; }
    [Required]
    public TaxonomyNodeType NodeType { get; set; }
    [Required, StringLength(100)]
    public string Code { get; set; } = string.Empty;
    [Required, StringLength(300)]
    public string Name { get; set; } = string.Empty;
    public int SortOrder { get; set; }
    public JsonElement Metadata { get; set; } = JsonDefaults.Object();

    public CreateTaxonomyNodeCommand ToCommand() => new(
        ParentId,
        ParentSource,
        NodeType,
        Code,
        Name,
        SortOrder,
        Metadata);
}
