
Some checks failed
TechAct / explore-gitea-actions (push) Failing after 30s
- 添加学生提交管理服务 (StudentSubmissionService, StudentSubmissionDetailService) - 新增学生提交相关控制器 (StudentSubmissionController, StudentSubmissionDetailController) - 添加学生提交数据传输对象 (StudentSubmissionDetailDto, StudentSubmissionSummaryDto) - 新增学生提交相关页面组件 (StudentExamView, ExamDetailView, StudentCard等) - 添加学生提交信息卡片组件 (SubmissionInfoCard, TeacherSubmissionInfoCard) - 更新数据库迁移文件以支持提交系统
76 lines
2.8 KiB
C#
76 lines
2.8 KiB
C#
using Entities.DTO;
|
||
using TechHelper.Services;
|
||
using System.Net.Http.Json;
|
||
using Newtonsoft.Json;
|
||
|
||
namespace TechHelper.Client.Services
|
||
{
|
||
public class StudentSubmissionService : IStudentSubmissionService
|
||
{
|
||
private readonly HttpClient _client;
|
||
|
||
public StudentSubmissionService(HttpClient client)
|
||
{
|
||
_client = client;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取当前学生的所有提交摘要
|
||
/// </summary>
|
||
/// <returns>学生提交摘要列表</returns>
|
||
public async Task<ApiResponse> GetMySubmissionsAsync()
|
||
{
|
||
try
|
||
{
|
||
var response = await _client.GetAsync("student-submission/my-submissions");
|
||
|
||
if (response.IsSuccessStatusCode)
|
||
{
|
||
var content = await response.Content.ReadAsStringAsync();
|
||
var submissions = JsonConvert.DeserializeObject<List<StudentSubmissionSummaryDto>>(content);
|
||
return ApiResponse.Success(result: submissions);
|
||
}
|
||
else
|
||
{
|
||
var errorContent = await response.Content.ReadAsStringAsync();
|
||
return ApiResponse.Error(message: $"获取学生提交信息失败: {response.StatusCode} - {errorContent}");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return ApiResponse.Error(message: $"内部错误: {ex.Message}");
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取当前学生的提交摘要(分页)
|
||
/// </summary>
|
||
/// <param name="pageNumber">页码,默认为1</param>
|
||
/// <param name="pageSize">每页数量,默认为10</param>
|
||
/// <returns>分页的学生提交摘要列表</returns>
|
||
public async Task<ApiResponse> GetMySubmissionsPagedAsync(int pageNumber = 1, int pageSize = 10)
|
||
{
|
||
try
|
||
{
|
||
var response = await _client.GetAsync($"student-submission/my-submissions-paged?pageNumber={pageNumber}&pageSize={pageSize}");
|
||
|
||
if (response.IsSuccessStatusCode)
|
||
{
|
||
var content = await response.Content.ReadAsStringAsync();
|
||
var result = JsonConvert.DeserializeObject<StudentSubmissionSummaryResponseDto>(content);
|
||
return ApiResponse.Success(result: result);
|
||
}
|
||
else
|
||
{
|
||
var errorContent = await response.Content.ReadAsStringAsync();
|
||
return ApiResponse.Error(message: $"获取学生提交信息失败: {response.StatusCode} - {errorContent}");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return ApiResponse.Error(message: $"内部错误: {ex.Message}");
|
||
}
|
||
}
|
||
}
|
||
}
|