using System.ComponentModel.DataAnnotations;

namespace iyixiGames.Domain.DTOs.Sites
{
    // --- 请求 DTOs ---

    /// <summary>
    /// 创建新网站的请求数据。
    /// </summary>
    public class CreateSiteRequest
    {
        [Required(ErrorMessage = "网站名称是必填项。")]
        [StringLength(100, MinimumLength = 3, ErrorMessage = "网站名称长度必须在3到100个字符之间。")]
        public string Name { get; set; } = string.Empty;

        [Required(ErrorMessage = "网站域名是必填项。")]
        [Url(ErrorMessage = "域名格式不正确。")]
        public string Domain { get; set; } = string.Empty;

        [Required(ErrorMessage = "网站所有者ID是必填项。")]
        public string OwnerUserId { get; set; } = string.Empty;

        public List<SiteTeamMemberDTO>? TeamMembers { get; set; } // 创建时可以指定团队成员
        public SiteSeoDTO? Seo { get; set; }
        public SiteSettingsDTO? Settings { get; set; }
        // Analytics 通常不由创建者直接设置，而是在后台生成
    }

    /// <summary>
    /// 更新网站信息的请求数据。
    /// </summary>
    public class UpdateSiteRequest
    {
        [StringLength(100, MinimumLength = 3, ErrorMessage = "网站名称长度必须在3到100个字符之间。")]
        public string? Name { get; set; } // 可选更新

        [Url(ErrorMessage = "域名格式不正确。")]
        public string? Domain { get; set; } // 可选更新

        public string? OwnerUserId { get; set; } // 可选更新

        public List<SiteTeamMemberDTO>? TeamMembers { get; set; } // 团队成员的完整替换或部分更新
        public SiteSeoDTO? Seo { get; set; }
        public SiteSettingsDTO? Settings { get; set; }
        // Status, CreatedAt, UpdatedAt 通常不在请求中直接更新
    }

    /// <summary>
    /// 更新网站状态的请求数据。
    /// </summary>
    public class UpdateSiteStatusRequest
    {
        [Required(ErrorMessage = "网站状态是必填项。")]
        [StringLength(50, ErrorMessage = "状态长度不能超过50个字符。")]
        public string Status { get; set; } = string.Empty;
    }


    // --- 响应 DTOs ---

    /// <summary>
    /// 网站的完整响应数据。
    /// </summary>
    public class SiteResponse
    {
        public string Id { get; set; } = string.Empty;
        public string Name { get; set; } = string.Empty;
        public string Domain { get; set; } = string.Empty;
        public string OwnerUserId { get; set; } = string.Empty;
        public List<SiteTeamMemberDTO>? TeamMembers { get; set; }
        public SiteSeoDTO? Seo { get; set; }
        public SiteAnalyticsDTO? Analytics { get; set; }
        public SiteSettingsDTO? Settings { get; set; }
        public string Status { get; set; } = string.Empty;
        public DateTime CreatedAt { get; set; }
        public DateTime UpdatedAt { get; set; }
    }

    /// <summary>
    /// 团队成员的 DTO。
    /// </summary>
    public class SiteTeamMemberDTO
    {
        public string UserId { get; set; } = string.Empty;
        public string Role { get; set; } = string.Empty;
    }

    /// <summary>
    /// SEO 信息的 DTO。
    /// </summary>
    public class SiteSeoDTO
    {
        public string Description { get; set; } = string.Empty;
        public string Keywords { get; set; } = string.Empty;
    }

    /// <summary>
    /// 分析数据的 DTO。
    /// </summary>
    public class SiteAnalyticsDTO
    {
        public int DailyVisitors { get; set; }
        public string PopularGames { get; set; } = string.Empty; // 依然是字符串，但可以考虑更结构化的类型
    }

    /// <summary>
    /// 网站设置的 DTO。
    /// </summary>
    public class SiteSettingsDTO
    {
        public string Theme { get; set; } = string.Empty;
        public string Language { get; set; } = string.Empty;
        public bool AdEnabled { get; set; }
    }
}