using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using FreeSql.DataAnnotations;
using ZhonTai.Admin.Core.Entities;
using NPP.SmartSchedue.Api.Contracts.Core.Consts;
using NPP.SmartSchedue.Api.Contracts.Core.Enums;

namespace NPP.SmartSchedue.Api.Contracts.Domain.Notification;

/// <summary>
/// 人员组实体
/// 决策点4：混合人员组，支持静态+动态规则
/// 决策点5：不支持多租户，继承EntityBase
/// </summary>
[Table(Name = DbConsts.TableNamePrefix + "personnel_group")]
public partial class PersonnelGroupEntity : EntityBase
{
    #region 基础信息
    
    /// <summary>
    /// 人员组名称
    /// </summary>
    [Column(StringLength = 200)]
    [Required(ErrorMessage = "人员组名称不能为空")]
    public string GroupName { get; set; } = "";

    /// <summary>
    /// 人员组描述
    /// </summary>
    [Column(StringLength = 500)]
    public string Description { get; set; } = "";

    /// <summary>
    /// 人员组类型
    /// </summary>
    public int GroupType { get; set; } = (int)PersonnelGroupTypeEnum.Mixed;

    /// <summary>
    /// 是否启用
    /// </summary>
    public bool IsEnabled { get; set; } = true;

    #endregion

    #region 静态人员配置
    
    /// <summary>
    /// 静态人员ID列表（JSON格式存储，如：[1,2,3,4,5]）
    /// </summary>
    [Column(DbType = "text")]
    public string StaticPersonnelIds { get; set; } = "[]";

    #endregion

    #region 动态规则配置
    
    /// <summary>
    /// 动态规则：部门ID列表（JSON格式存储，如：[1,2,3]）
    /// 当GroupType包含DynamicByDepartment时有效
    /// </summary>
    [Column(DbType = "text")]
    public string DynamicDepartmentIds { get; set; } = "[]";

    /// <summary>
    /// 动态规则：职位列表（JSON格式存储，如：["经理","主管","组长"]）
    /// 当GroupType包含DynamicByPosition时有效
    /// </summary>
    [Column(DbType = "text")]
    public string DynamicPositions { get; set; } = "[]";

    /// <summary>
    /// 动态规则：是否仅包含激活人员
    /// </summary>
    public bool OnlyActivePersonnel { get; set; } = true;

    #endregion

    #region 排除规则
    
    /// <summary>
    /// 排除人员ID列表（JSON格式存储）
    /// 在动态规则生成的人员列表中排除这些人员
    /// </summary>
    [Column(DbType = "text")]
    public string ExcludePersonnelIds { get; set; } = "[]";

    #endregion

    #region 时间信息
    
    /// <summary>
    /// 最后修改时间
    /// </summary>
    public DateTime? LastModifiedTime { get; set; }

    #endregion

    #region 导航属性
    
    /// <summary>
    /// 使用此人员组的通知设置列表
    /// </summary>
    [Navigate("PersonnelGroupId")]
    public List<NotificationSettingEntity> NotificationSettings { get; set; } = new List<NotificationSettingEntity>();

    #endregion
}