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

namespace Edu.Repository.App
{
    /// <summary>
    /// app首页banner图片仓储层
    /// </summary>
    public class RB_HomePage_BannerRepository : BaseRepository<RB_HomePage_Banner>
    {
        /// <summary>
        /// 获取学生app首页banner列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_HomePage_Banner> GetHomePageBannerList(RB_HomePage_Banner query)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(@" SELECT *  FROM RB_HomePage_Banner  WHERE 1=1  ");
            builder.AppendFormat(" AND {0}={1} ", nameof(RB_HomePage_Banner.Status), (int)DateStateEnum.Normal);
            if (query != null)
            {
                if (query.Group_Id > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_HomePage_Banner.Group_Id), query.Group_Id);
                }
                if (query.School_Id > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_HomePage_Banner.School_Id), query.School_Id);
                }
            }
            return Get<RB_HomePage_Banner>(builder.ToString()).ToList();
        }
    }
}
