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_DeductionRepository : BaseRepository<RB_Personnel_Deduction>
    {
        /// <summary>
        /// 获取员工人头奖励抵扣列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Personnel_Deduction_Extend> GetPersonnelBonusListRepository(RB_Personnel_Deduction_Extend query)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(@"
SELECT A.*
FROM RB_Personnel_Deduction AS A
WHERE 1=1
");
            if (query != null)
            {
                if (query.BonusId > 0)
                {
                    builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Personnel_Deduction_Extend.BonusId), query.BonusId);
                }
                if (!string.IsNullOrEmpty(query.QBonusIds))
                {
                    builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Personnel_Deduction_Extend.BonusId), query.QBonusIds);
                }
            }
            return Get<RB_Personnel_Deduction_Extend>(builder.ToString()).ToList();
        }
    }
}
