using Znyc.CloudCar.IRepository.CardIntro;
using Znyc.CloudCar.IServices.CaChe;
using Znyc.CloudCar.IServices.CardIntro;
using Znyc.CloudCar.Model.Dtos.CardIntro;
using Znyc.CloudCar.Model.ViewModels.ReportsCallBack;
using Znyc.CloudCar.Utility.Extensions;
namespace Znyc.CloudCar.Services.CardIntro
{
public class CardIntroService : ICardIntroService
{
private readonly ICardIntroRepository _cardIntroRepository;
private readonly ICacheService _cacheService;
public CardIntroService(
ICardIntroRepository cardIntroRepository,
ICacheService cacheService
)
{
_cardIntroRepository = cardIntroRepository;
_cacheService = cacheService;
}
///
/// 查询优惠卡缓存
///
///
public async Task GetCardIntroListAsync()
{
var cardIntroes = await _cacheService.GetCardIntroListAsync();
if (cardIntroes.IsNull())
{
cardIntroes = await _cardIntroRepository
.Where(x => x.State == 10 && x.IsEnabled == true && x.IsDeleted == false)
.OrderBy(x => x.Sort)
.ToListAsync();
await _cacheService.SetCardIntroListAsync(cardIntroes);
}
return new ResponseOutput()
{
Data = cardIntroes,
Successed = true,
Code = 1
};
}
}
}