using Hotline.Share.Enums.FlowEngine;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hotline.Share.Dtos.FlowEngine.Definition
{
    /// <summary>
    /// 模板定义节点
    /// </summary>
    public class StepDefineBasic
    {
        public string Name { get; set; }

        /// <summary>
        /// 模板内唯一
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 办理/汇总、开始/结束
        /// </summary>
        public EStepType StepType { get; init; }

        /// <summary>
        /// 节点业务类型
        /// </summary>
        public EBusinessType BusinessType { get; set; }

        /// <summary>
        /// 办理对象类型
        /// </summary>
        public EHandlerType HandlerType { get; set; }

        /// <summary>
        /// 办理者类型下的配置（或是直接保存办理者）
        /// <example>
        /// 根据类型可能为：roles, orgLevels, orgTypes, orgCodes, userIds
        /// </example>
        /// </summary>
        public List<Kv> HandlerTypeItems { get; set; } = new();

        /// <summary>
        /// 是否有否决按钮
        /// </summary>
        public bool CanReject { get; set; }

        /// <summary>
        /// 执行模式(自动与否)
        /// 只有普通节点支持自动，会签、动态节点均不支持自动
        /// </summary>
        public EExecuteMode ExecuteMode { get; set; }
        
        #region 会签

        /// <summary>
        /// 是否支持发起会签（即使支持发起，当下一节点为汇总或结束节点时亦不可发起）
        /// </summary>
        public bool CanStartCountersign { get; set; }

        /// <summary>
        /// 会签策略
        /// </summary>
        public ECountersignPolicy? CountersignPolicy { get; set; }

        #endregion
        
        #region 依据配置生成节点的方式

        /// <summary>
        /// 实例化模式
        /// </summary>
        public EInstanceMode InstanceMode { get; set; }

        /// <summary>
        /// 动态实例化策略(多次模式才有)
        /// </summary>
        public EDynamicPolicy? InstancePolicy { get; set; }

        /// <summary>
        /// 到此标记终止动态实例化(多次模式才有)
        /// <remarks>
        /// 按直属部门重复既保存x级部门办理的x：int
        /// </remarks>
        /// </summary>
        public string? TerminalDynamicMark { get; set; }

        #endregion

        /// <summary>
        /// 标签
        /// </summary>
        public string? Tag { get; set; }

        /// <summary>
        /// 汇总目标节点code
        /// </summary>
        public string? SummaryTargetCode { get; set; }

        /// <summary>
        /// 可跳转节点
        /// </summary>
        public List<StepDefineSimple> NextSteps { get; set; }
    }
}
