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

namespace Edu.Repository.Customer
{
    /// <summary>
    /// 客户类型仓储层
    /// </summary>
    public class RB_Student_TypeRepository : BaseRepository<RB_Student_Type>
    {
        /// <summary>
        /// 获取客户类型列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Student_Type_Extend> GetStudentTypeListRepository(RB_Student_Type_Extend query)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(@"
SELECT A.*
FROM RB_Student_Type AS A
WHERE 1=1
");
            builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Student_Type_Extend.Status), (int)DateStateEnum.Normal);
            if (query != null)
            {
                if (query.Group_Id > 0)
                {
                    builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Student_Type_Extend.Group_Id), query.Group_Id);
                }
            }
            builder.AppendFormat(" ORDER BY A.{0} ASC ", nameof(RB_Student_Type_Extend.No));
            return Get<RB_Student_Type_Extend>(builder.ToString()).ToList();
        }
    }
}
