using Edu.Common.Enum;
using Edu.Model.Entity.Flow;
using Edu.Model.ViewModel.Flow;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Edu.Repository.Flow
{
    /// <summary>
    /// 流程节点信息仓储层
    /// </summary>
    public class RB_Flow_NodeRepository : BaseRepository<RB_Flow_Node>
    {
        /// <summary>
        /// 获取流程节点信息列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Flow_Node_ViewModel> GetFlowNodeListRepository(RB_Flow_Node_ViewModel query)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(@"
SELECT * 
FROM  RB_Flow_Node
WHERE 1=1 
");
            if (query != null)
            {
                if (query.FlowId > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Flow_Node_ViewModel.FlowId), query.FlowId);
                }
                if (!string.IsNullOrEmpty(query.QFlowIds))
                {
                    builder.AppendFormat(" AND {0} IN({1}) ", nameof(RB_Flow_Node_ViewModel.FlowId), query.QFlowIds);
                }
            }
            builder.AppendFormat(" ORDER BY {0} ASC ", nameof(RB_Flow_Node_ViewModel.SortNum));
            return Get<RB_Flow_Node_ViewModel>(builder.ToString()).ToList();
        }
    }
}
