using Entities.DTO;
using System.Net.Http.Json;

namespace TechHelper.Client.Services
{
    public class StudentSubmissionDetailService : IStudentSubmissionDetailService
    {
        private readonly HttpClient _httpClient;

        public StudentSubmissionDetailService(HttpClient httpClient)
        {
            _httpClient = httpClient;
        }

        public async Task<StudentSubmissionDetailDto> GetSubmissionDetailAsync(Guid submissionId)
        {
            var response = await _httpClient.GetAsync($"api/student-submission-detail/{submissionId}");
            if (response.IsSuccessStatusCode)
            {
                return await response.Content.ReadFromJsonAsync<StudentSubmissionDetailDto>();
            }
            throw new HttpRequestException($"获取学生提交详细信息失败: {response.StatusCode}");
        }
    }
}
