mirror of
https://github.com/AIDotNet/AntSK.git
synced 2026-02-17 22:10:14 +08:00
27 lines
643 B
C#
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");
|
|
}
|
|
}
|
|
} |