using Entities.Contracts;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Entities.DTO
{
    /// <summary>
    /// 用户信息数据传输对象
    /// 用于在API调用中传输用户的基本信息
    /// </summary>
    public record UserDto
    {
        /// <summary>
        /// 用户唯一标识符
        /// </summary>
        public Guid Id { get; init; }

        /// <summary>
        /// 用户名
        /// </summary>
        public string? UserName { get; init; }

        /// <summary>
        /// 电子邮箱
        /// </summary>
        [EmailAddress]
        public string? Email { get; init; }

        /// <summary>
        /// 手机号码
        /// </summary>
        [Phone]
        public string? PhoneNumber { get; init; }

        /// <summary>
        /// 显示名称
        /// </summary>
        public string? DisplayName { get; init; }

        /// <summary>
        /// 家庭住址
        /// </summary>
        public string? HomeAddress { get; init; }

        /// <summary>
        /// 用户角色
        /// </summary>
        public UserRoles? Role { get; init; }

        /// <summary>
        /// 教授科目ID
        /// </summary>
        public Guid? TeachSubjectId { get; init; }

        /// <summary>
        /// 教授科目信息
        /// </summary>
        public SubjectDto? TeachSubject { get; init; }

        /// <summary>
        /// 用户加入的班级数量
        /// </summary>
        public int JoinedClassCount { get; init; }

        /// <summary>
        /// 创建的问题数量
        /// </summary>
        public int CreatedQuestionsCount { get; init; }

        /// <summary>
        /// 创建的考试数量
        /// </summary>
        public int CreatedExamsCount { get; init; }

        /// <summary>
        /// 提交的作业数量
        /// </summary>
        public int SubmittedAssignmentsCount { get; init; }

        /// <summary>
        /// 批改的作业数量
        /// </summary>
        public int GradedAssignmentsCount { get; init; }

        /// <summary>
        /// 用户创建时间
        /// </summary>
        public DateTime CreatedAt { get; init; }

        /// <summary>
        /// 用户最后更新时间
        /// </summary>
        public DateTime UpdatedAt { get; init; }

        /// <summary>
        /// 用户是否已验证邮箱
        /// </summary>
        public bool EmailConfirmed { get; init; }

        /// <summary>
        /// 用户是否已锁定
        /// </summary>
        public bool LockoutEnabled { get; init; }

        /// <summary>
        /// 用户锁定结束时间
        /// </summary>
        public DateTime? LockoutEnd { get; init; }

        /// <summary>
        /// 获取用户角色的显示名称
        /// </summary>
        public string? RoleDisplayName => Role?.GetDisplayName();

        /// <summary>
        /// 获取用户角色的简短名称
        /// </summary>
        public string? RoleShortName => Role?.GetShortName();

        /// <summary>
        /// 获取用户的基本信息字符串
        /// </summary>
        public string? UserInfoString => $"{DisplayName ?? UserName} ({Email})";
    }
}
