using System.ComponentModel.DataAnnotations;
using MiGu.DB.Kernel.Entities;

namespace MiGu.DB.Domains.SimpleFields;

public sealed class SimpleField : Entity<Guid>
{
    [MaxLength(64)] public string CarType { get; set; } = "";
    [MaxLength(64)] public string FieldType { get; set; } = "";
    [MaxLength(128)] public string Key { get; set; } = "";
    public string Value { get; set; } = "";
    [MaxLength(128)] public string DataType { get; set; } = "";
    [MaxLength(256)] public string? Chinese { get; set; }
    [MaxLength(256)] public string? English { get; set; }
    [MaxLength(512)] public string Other { get; set; } = "";
    public bool IsDefault { get; set; }
    public DateTimeOffset CreateTime { get; set; }
    public DateTimeOffset UpdateTime { get; set; }
}

public static class SimpleFieldDateTime
{
    public const string Format = "yyyy-MM-dd HH:mm:ss";

    public static DateTimeOffset Now => DateTimeOffset.UtcNow;

    public static string ToStorage(DateTimeOffset value)
        => value.UtcDateTime.ToString(Format);

    public static DateTimeOffset FromStorage(string value)
        => DateTimeOffset.Parse(value);
}
