Files
AntSK/Xzy.KnowledgeBase/Services/UserService.cs
2024-02-01 23:12:53 +08:00

27 lines
643 B
C#

using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;
using Xzy.KnowledgeBase.Models;
namespace Xzy.KnowledgeBase.Services
{
public interface IUserService
{
Task<CurrentUser> GetCurrentUserAsync();
}
public class UserService : IUserService
{
private readonly HttpClient _httpClient;
public UserService(HttpClient httpClient)
{
_httpClient = httpClient;
}
public async Task<CurrentUser> GetCurrentUserAsync()
{
return await _httpClient.GetFromJsonAsync<CurrentUser>("data/current_user.json");
}
}
}