using Mall.Model.Entity.MarketingCenter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mall.Repository.MarketingCenter
{
    /// <summary>
    /// 积分设置
    /// </summary>
    public class RB_Integral_SettingsRepository : BaseRepository<RB_Integral_Settings>
    {
        /// <summary>
        /// 表名称
        /// </summary>
        public string TableName { get { return nameof(RB_Integral_Settings); } }


        /// <summary>
        /// 积分设置列表
        /// </summary>
        /// <param name="query">查询条件</param>
        /// <returns></returns>
        public List<RB_Integral_Settings> GetIntegralSettingsList(RB_Integral_Settings query)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_Integral_Settings.Status)}=0 ");
            if (query != null)
            {
                if (query.ID > 0)
                {
                    builder.Append($" AND {nameof(RB_Integral_Settings.ID)}={query.ID}");
                }
                if (query.TenantId > 0)
                {
                    builder.Append($" AND {nameof(RB_Integral_Settings.TenantId)}={query.TenantId}");
                }
                if (query.TenantId > 0)
                {
                    builder.Append($" AND {nameof(RB_Integral_Settings.MallBaseId)}={query.MallBaseId}");
                }
            }
            return Get<RB_Integral_Settings>(builder.ToString()).ToList();
        }
    }
}
