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_AduitInfoRepository : BaseRepository<RB_Flow_AduitInfo>
    {
        /// <summary>
        /// 获取流程节点审核信息列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Flow_AduitInfo_ViewModel> GetFlowAduitInfoListRepository(RB_Flow_AduitInfo_ViewModel query)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(@"
SELECT * 
FROM RB_Flow_AduitInfo
WHERE 1=1 
");
            if (query != null)
            {
                if (query.NodeId > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Flow_AduitInfo_ViewModel.NodeId), query.NodeId);
                }
                if (!string.IsNullOrEmpty(query.QNodeIds))
                {
                    builder.AppendFormat(" AND {0} IN({1}) ", nameof(RB_Flow_AduitInfo_ViewModel.NodeId), query.QNodeIds);
                }
                if (query.FlowId > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Flow_AduitInfo_ViewModel.FlowId), query.FlowId);
                }
                if (!string.IsNullOrEmpty(query.QFlowIds))
                {
                    builder.AppendFormat(" AND {0} IN({1}) ", nameof(RB_Flow_AduitInfo_ViewModel.FlowId), query.QFlowIds);
                }
            }
            return Get<RB_Flow_AduitInfo_ViewModel>(builder.ToString()).ToList();
        }
    }
}
