namespace XF.Domain.Entities;

public interface IWorkflow
{
    string? WorkflowId { get; set; }

    /// <summary>
    /// 过期时间配置id
    /// </summary>
    string? ExpiredTimeConfigId { get; set; }

    /// <summary>
    /// 流经部门
    /// </summary>
    List<string> FlowedOrgIds { get; set; }

    /// <summary>
    /// 流经办理人
    /// </summary>
    List<string> FlowedUserIds { get; set; }
    
    #region 当前办理对象

    /// <summary>
    /// 办理人id
    /// </summary>
    public List<HandlerGroupItem> HandlerUsers { get; set; }

    /// <summary>
    /// 办理部门id
    /// </summary>
    public List<HandlerGroupItem> HandlerOrgs { get; set; }

    #endregion

    //void Assign(EFlowAssignType type, string handler);

    //void Assign(EFlowAssignType type, IEnumerable<string> handlers);

    /// <summary>
    /// 是否可查看
    /// </summary>
    /// <param name="userId"></param>
    /// <param name="orgId"></param>
    /// <returns></returns>
    bool CanView(string userId, string orgId);

    /// <summary>
    /// 是否能办理
    /// </summary>
    /// <param name="userId"></param>
    /// <param name="orgId"></param>
    /// <returns></returns>
    bool CanHandle(string userId, string orgId);

    /// <summary>
    /// 流程每次流转时更新待办对象及流经对象
    /// </summary>
    void Flowed(List<string> flowedUserIds, List<string> flowedOrgIds,
        List<HandlerGroupItem> handlerUsers, List<HandlerGroupItem> handlerOrgs);
}

/// <summary>
/// 办理对象分组（以办理step分组，多人办理一个step为一组）
/// </summary>
public class HandlerGroupItem
{
    public string GroupId { get; set; }

    public string Key { get; set; }

    public string Value { get; set; }
}