using AutoMapper;
using Kean.Application.Query.Interfaces;
using Kean.Application.Query.ViewModels;
using Kean.Infrastructure.Database.Repository.Default.Entities;
using Kean.Infrastructure.NoSql.Repository.Default;
using Kean.Infrastructure.Utilities;
using System.Threading.Tasks;
namespace Kean.Application.Query.Implements
{
///
/// 应用程序查询服务实现
///
public class AppService : IAppService
{
private readonly IMapper _mapper; // 模型映射
private readonly IDefaultRedis _redis; // 默认 Redis
///
/// 依赖注入
///
public AppService(
IMapper mapper,
IDefaultRedis redis)
{
_mapper = mapper;
_redis = redis;
}
/*
* 实现 Kean.Application.Query.Interfaces.IAppService.GetBlacklist(string address) 方法
*/
public async Task GetBlacklist(string address)
{
var cache = await _redis.Hash["blacklist"].Get(address);
var entity = cache == null ? null : JsonHelper.Deserialize(cache);
return _mapper.Map(entity);
}
}
}