You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

55 lines
1.6 KiB

using Znyc.CloudCar.Configuration;
using Znyc.CloudCar.IRepository.Banner;
using Znyc.CloudCar.IServices.Banner;
using Znyc.CloudCar.IServices.CaChe;
using Znyc.CloudCar.Model.Dtos.Banner;
using Znyc.CloudCar.Model.ViewModels.ReportsCallBack;
using Znyc.CloudCar.Utility.Extensions;
namespace Znyc.CloudCar.Services.Banner
{
/// <summary>
/// Banner服务
/// </summary>
public class BannerService : IBannerService
{
private readonly IBannerRepository _bannerRepository;
private readonly ICacheService _cacheService;
public BannerService(
IBannerRepository bannerRepository,
ICacheService cacheService
)
{
_bannerRepository = bannerRepository;
_cacheService = cacheService;
}
/// <summary>
/// 查询Banner缓存
/// </summary>
/// <returns></returns>
public async Task<ResponseOutput> GetBannerListAsync()
{
var banners = await _cacheService.GetBannerListAsync();
if (banners.IsNull())
{
banners = await _bannerRepository
.Where(x => x.State == 1 && x.IsDeleted == false)
.OrderBy(x => x.Sort)
.ToListAsync(x => new BannerListOutput
{
PicUrl = GlobalConstVars.Default_Banner_Prefix + x.PicUrl
});
await _cacheService.SetBannerListAsync(banners);
}
return new ResponseOutput()
{
Data = banners,
Successed = true,
Code = 1
};
}
}
}