using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mall.Common.Enum;
using Mall.Model.Entity.Coffee;
using Mall.Model.Extend.Coffee;

namespace Mall.Repository.Coffee
{
    public class RB_Member_CoffeeCouponsRepository : BaseRepository<RB_Member_CoffeeCoupons>
    {

        /// <summary>
        /// 获取咖啡劵列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Member_CoffeeCoupons_Extend> GetList(RB_Member_CoffeeCoupons_Extend query)
        {

            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(@"
SELECT * 
FROM RB_Member_CoffeeCoupons
WHERE 1=1
");
            if (query == null)
            {
                return new List<RB_Member_CoffeeCoupons_Extend>();
            }
            else
            {
                if (query.MallBaseId > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Member_CoffeeCoupons_Extend.MallBaseId), query.MallBaseId);
                }
                if (query.UserId > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Member_CoffeeCoupons_Extend.UserId), query.UserId);
                }
            }
            return Get<RB_Member_CoffeeCoupons_Extend>(builder.ToString()).ToList();
        }
    }
}
