56 lines
1.6 KiB
56 lines
1.6 KiB
2 years ago
|
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
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
}
|