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

namespace Edu.Repository.Grade
{
    public class RB_Class_FinanceRepository : BaseRepository<RB_Class_Finance>
    {
        /// <summary>
        /// 获取班级收支信息列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Class_Finance_ViewModel> GetClassFinanceListRepository(RB_Class_Finance_ViewModel query)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(@"
SELECT A.* 
FROM RB_Class_Finance AS A
WHERE 1=1 
");
            builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Finance_ViewModel.Status), (int)DateStateEnum.Normal);
            if (query != null)
            {

                if (query.Group_Id > 0)
                {
                    builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Finance_ViewModel.Group_Id), query.Group_Id);
                }
                if (query.School_Id > 0)
                {
                    builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Finance_ViewModel.School_Id), query.School_Id);
                }
                if (query.ClassId > 0)
                {
                    builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Class_Finance_ViewModel.ClassId), query.ClassId);
                }
            }
            return Get<RB_Class_Finance_ViewModel>(builder.ToString()).ToList();
        }

    }
}
