using SQLite;
using System.Text.Json.Serialization;

namespace Blahblah.FlowerApp.Data.Model;

[Table("users")]
public class UserItem
{
    [Column("uid"), PrimaryKey, NotNull]
    public int Id { get; set; }

    [Column("token"), Indexed, NotNull]
    public string Token { get; set; } = null!;

    [Column("id"), NotNull]
    public string UserId { get; set; } = null!;

    [Column("name"), NotNull]
    public string Name { get; set; } = null!;

    [Column("level"), NotNull]
    public int Level { get; set; }

    [Column("regdate"), JsonPropertyName("registerDate"), NotNull]
    public long RegisterDateUnixTime { get; set; }

    [Column("email")]
    public string? Email { get; set; }

    [Column("mobile")]
    public string? Mobile { get; set; }

    [Column("avatar")]
    public byte[]? Avatar { get; set; }

    public override string ToString()
    {
        return $"{{ Id: {Id}, Token: \"{Token}\", UserId: \"{UserId}\", Name: \"{Name}\", Level: {Level}, RegisterDate: \"{DateTimeOffset.FromUnixTimeMilliseconds(RegisterDateUnixTime)}\" }}";
    }
}
