using Edu.Model.Entity.Bonus;
using Edu.Model.ViewModel.Bonus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Edu.Repository.Bonus
{
    /// <summary>
    /// 员工人头奖励详情仓储层
    /// </summary>
    public class RB_Personnel_BonusDetailRepository : BaseRepository<RB_Personnel_BonusDetail>
    {
        /// <summary>
        /// 获取员工人头奖励详情列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Personnel_BonusDetail_Extend> GetPersonnelBonusDetailListRepository(RB_Personnel_BonusDetail_Extend query)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(@"
SELECT A.*
FROM RB_Personnel_BonusDetail AS A
WHERE 1=1
");
            if (query != null)
            {
                if (query.BonusId > 0)
                {
                    builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Personnel_BonusDetail_Extend.BonusId), query.BonusId);
                }
                if (!string.IsNullOrEmpty(query.QBonusIds))
                {
                    builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Personnel_BonusDetail_Extend.BonusId), query.QBonusIds);
                }
            }
            return Get<RB_Personnel_BonusDetail_Extend>(builder.ToString()).ToList();
        }
    }
}