重构项目结构,移除Assignment相关功能,优化Submission模块
Some checks failed
TechAct / explore-gitea-actions (push) Failing after 12s
Some checks failed
TechAct / explore-gitea-actions (push) Failing after 12s
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Entities.DTO;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Json;
|
||||
using TechHelper.Client.HttpRepository;
|
||||
using TechHelper.Services;
|
||||
|
||||
namespace TechHelper.Client.Services
|
||||
{
|
||||
@@ -38,7 +36,7 @@ namespace TechHelper.Client.Services
|
||||
{
|
||||
var result = await _client.PostAsJsonAsync("class/getClassStudents","");
|
||||
var content = await result.Content.ReadAsStringAsync();
|
||||
var users = JsonConvert.DeserializeObject<List<StudentDto>>(content);
|
||||
var users = JsonConvert.DeserializeObject<List<StudentExamDetailDto>>(content);
|
||||
return ApiResponse.Success(result: users);
|
||||
}
|
||||
catch(Exception ex)
|
||||
@@ -63,7 +61,7 @@ namespace TechHelper.Client.Services
|
||||
}
|
||||
}
|
||||
|
||||
public StudentDto GetStudents(byte Class)
|
||||
public StudentExamDetailDto GetStudents(byte Class)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -71,18 +69,18 @@ namespace TechHelper.Client.Services
|
||||
var content = result.Result.Content.ReadAsStringAsync();
|
||||
if (content.Result != null)
|
||||
{
|
||||
var users = JsonConvert.DeserializeObject<StudentDto>(content.Result);
|
||||
var users = JsonConvert.DeserializeObject<StudentExamDetailDto>(content.Result);
|
||||
return users;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new StudentDto();
|
||||
return new StudentExamDetailDto();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"获取失败,{ex.Message}, InnerException: {ex.InnerException}");
|
||||
return new StudentDto();
|
||||
return new StudentExamDetailDto();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
47
TechHelper.Client/Services/CommonService.cs
Normal file
47
TechHelper.Client/Services/CommonService.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using System.Net.Http.Json;
|
||||
using TechHelper.Client.HttpRepository;
|
||||
|
||||
namespace TechHelper.Client.Services
|
||||
{
|
||||
|
||||
public class CommonService : ICommonService
|
||||
{
|
||||
private readonly HttpClient _client;
|
||||
private readonly IAuthenticationClientService _authenticationClientService;
|
||||
|
||||
public CommonService(HttpClient client, IAuthenticationClientService authenticationClientService)
|
||||
{
|
||||
_client = client;
|
||||
_authenticationClientService = authenticationClientService;
|
||||
}
|
||||
public async Task<List<TypeCommonDto>> GetCommonTypesAsync(TypeNameType typeNameType, Guid? SubjectId = null)
|
||||
{
|
||||
|
||||
switch (typeNameType)
|
||||
{
|
||||
case TypeNameType.Subject:
|
||||
{
|
||||
var response = await _client.GetAsync("subject");
|
||||
var result = await response.Content.ReadFromJsonAsync<List<TypeCommonDto>>();
|
||||
return result;
|
||||
}
|
||||
case TypeNameType.ExamType:
|
||||
{
|
||||
var response = await _client.GetAsync("exam-type");
|
||||
var result = await response.Content.ReadFromJsonAsync<List<TypeCommonDto>>();
|
||||
return result;
|
||||
}
|
||||
case TypeNameType.QuestionType:
|
||||
{
|
||||
var response = await _client.GetAsync("question-type");
|
||||
var result = await response.Content.ReadFromJsonAsync<List<TypeCommonDto>>();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Xml.Serialization; // 用于 XML 序列化/反序列化
|
||||
using TechHelper.Client.AI;
|
||||
using TechHelper.Services;
|
||||
using Entities.DTO;
|
||||
using System.Net.Http.Json; // 用于 PostAsJsonAsync
|
||||
using Newtonsoft.Json;
|
||||
@@ -93,7 +92,7 @@ namespace TechHelper.Client.Services
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
var result = JsonConvert.DeserializeObject<List<AssignmentDto>>(content);
|
||||
var result = JsonConvert.DeserializeObject<List<ExamDto>>(content);
|
||||
return ApiResponse.Success(result: result);
|
||||
}
|
||||
else
|
||||
@@ -112,7 +111,7 @@ namespace TechHelper.Client.Services
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
var exam = JsonConvert.DeserializeObject<AssignmentDto>(content);
|
||||
var exam = JsonConvert.DeserializeObject<ExamDto>(content);
|
||||
return ApiResponse.Success();
|
||||
}
|
||||
return ApiResponse.Error(message: "获取失败");
|
||||
@@ -130,7 +129,7 @@ namespace TechHelper.Client.Services
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
var exam = JsonConvert.DeserializeObject<AssignmentDto>(content);
|
||||
var exam = JsonConvert.DeserializeObject<ExamDto>(content);
|
||||
return ApiResponse.Success(result: exam);
|
||||
}
|
||||
else
|
||||
@@ -162,7 +161,7 @@ namespace TechHelper.Client.Services
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ApiResponse> SaveParsedExam(AssignmentDto assiDto)
|
||||
public async Task<ApiResponse> SaveParsedExam(ExamDto assiDto)
|
||||
{
|
||||
// 直接使用注入的 _client 实例
|
||||
var response = await _client.PostAsJsonAsync("exam/add", assiDto);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Entities.DTO;
|
||||
using System.Net;
|
||||
using TechHelper.Services;
|
||||
|
||||
namespace TechHelper.Client.Services
|
||||
{
|
||||
@@ -10,6 +9,6 @@ namespace TechHelper.Client.Services
|
||||
public Task<ResponseDto> CreateClass(UserRegistrationToClassDto userClass);
|
||||
public Task<ApiResponse> GetClassStudents();
|
||||
public Task<ApiResponse> GetGradeClasses(byte grade);
|
||||
public StudentDto GetStudents(byte Class);
|
||||
public StudentExamDetailDto GetStudents(byte Class);
|
||||
}
|
||||
}
|
||||
|
||||
10
TechHelper.Client/Services/ICommonService.cs
Normal file
10
TechHelper.Client/Services/ICommonService.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
|
||||
namespace TechHelper.Client.Services
|
||||
{
|
||||
public interface ICommonService
|
||||
{
|
||||
public Task<List<TypeCommonDto>> GetCommonTypesAsync(TypeNameType typeNameType, Guid? SubjectId = null);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using Entities.DTO;
|
||||
using TechHelper.Services;
|
||||
|
||||
namespace TechHelper.Client.Services
|
||||
{
|
||||
@@ -7,7 +6,7 @@ namespace TechHelper.Client.Services
|
||||
{
|
||||
public Task<ApiResponse> FormatExam(string examContent);
|
||||
public Task<ApiResponse> DividExam(string examContent);
|
||||
public Task<ApiResponse> SaveParsedExam(AssignmentDto assiDto);
|
||||
public Task<ApiResponse> SaveParsedExam(ExamDto assiDto);
|
||||
public Task<ApiResponse> ParseSingleQuestionGroup(string examContent);
|
||||
public ApiResponse ConvertToXML<T>(string xmlContent);
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
using Entities.DTO;
|
||||
using TechHelper.Services;
|
||||
|
||||
namespace TechHelper.Client.Services
|
||||
{
|
||||
public interface INoteService
|
||||
{
|
||||
public Task<ApiResponse> AddNote(GlobalDto dto);
|
||||
public Task<ApiResponse> DeleteNote(byte id);
|
||||
public Task<ApiResponse> GetAllNotes();
|
||||
public Task<ApiResponse> GetNote(byte id);
|
||||
public Task<ApiResponse> UpdateNote(GlobalDto dto);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using Entities.DTO;
|
||||
using TechHelper.Services;
|
||||
|
||||
namespace TechHelper.Client.Services
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using TechHelper.Services;
|
||||
using Entities.DTO;
|
||||
|
||||
namespace TechHelper.Client.Services
|
||||
{
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
using Entities.DTO;
|
||||
using System.Net.Http.Json;
|
||||
using TechHelper.Client.AI;
|
||||
using TechHelper.Services;
|
||||
|
||||
namespace TechHelper.Client.Services
|
||||
{
|
||||
public class NoteService : INoteService
|
||||
{
|
||||
private readonly HttpClient _client;
|
||||
|
||||
public NoteService(HttpClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个新笔记
|
||||
/// </summary>
|
||||
/// <param name="dto">包含笔记数据的数据传输对象</param>
|
||||
/// <returns>操作结果</returns>
|
||||
public async Task<ApiResponse> AddNote(GlobalDto dto)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _client.PostAsJsonAsync("note", dto);
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var result = await response.Content.ReadFromJsonAsync<ApiResponse>();
|
||||
return result ?? ApiResponse.Success("操作成功。");
|
||||
}
|
||||
else
|
||||
{
|
||||
var errorContent = await response.Content.ReadAsStringAsync();
|
||||
return ApiResponse.Error($"添加失败。状态码: {response.StatusCode}。详情: {errorContent}");
|
||||
}
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
return ApiResponse.Error($"网络请求错误: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据 ID 删除一个笔记
|
||||
/// </summary>
|
||||
/// <param name="id">要删除的笔记的 ID</param>
|
||||
/// <returns>操作结果</returns>
|
||||
public async Task<ApiResponse> DeleteNote(byte id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _client.DeleteAsync($"note/{id}");
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var result = await response.Content.ReadFromJsonAsync<ApiResponse>();
|
||||
return result ?? ApiResponse.Success("删除成功。");
|
||||
}
|
||||
else
|
||||
{
|
||||
var errorContent = await response.Content.ReadAsStringAsync();
|
||||
return ApiResponse.Error($"删除失败。状态码: {response.StatusCode}。详情: {errorContent}");
|
||||
}
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
return ApiResponse.Error($"网络请求错误: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有笔记
|
||||
/// </summary>
|
||||
/// <returns>包含所有笔记列表的操作结果</returns>
|
||||
public async Task<ApiResponse> GetAllNotes()
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _client.GetAsync("note");
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var result = await response.Content.ReadFromJsonAsync<ApiResponse>();
|
||||
return result ?? ApiResponse.Success("获取成功。");
|
||||
}
|
||||
else
|
||||
{
|
||||
var errorContent = await response.Content.ReadAsStringAsync();
|
||||
return ApiResponse.Error($"获取失败。状态码: {response.StatusCode}。详情: {errorContent}");
|
||||
}
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
return ApiResponse.Error($"网络请求错误: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据 ID 获取单个笔记
|
||||
/// </summary>
|
||||
/// <param name="id">要获取的笔记的 ID</param>
|
||||
/// <returns>包含单个笔记数据的操作结果</returns>
|
||||
public async Task<ApiResponse> GetNote(byte id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _client.GetAsync($"note/{id}");
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var result = await response.Content.ReadFromJsonAsync<ApiResponse>();
|
||||
return result ?? ApiResponse.Success("获取成功。");
|
||||
}
|
||||
else
|
||||
{
|
||||
var errorContent = await response.Content.ReadAsStringAsync();
|
||||
return ApiResponse.Error($"获取失败。状态码: {response.StatusCode}。详情: {errorContent}");
|
||||
}
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
return ApiResponse.Error($"网络请求错误: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ApiResponse> UpdateNote(GlobalDto dto)
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _client.PutAsJsonAsync("note", dto);
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var result = await response.Content.ReadFromJsonAsync<ApiResponse>();
|
||||
return result ?? ApiResponse.Success("更新成功。");
|
||||
}
|
||||
else
|
||||
{
|
||||
var errorContent = await response.Content.ReadAsStringAsync();
|
||||
return ApiResponse.Error($"更新失败。状态码: {response.StatusCode}。详情: {errorContent}");
|
||||
}
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
return ApiResponse.Error($"网络请求错误: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using Entities.DTO;
|
||||
using TechHelper.Client.HttpRepository;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
namespace TechHelper.Client.Services
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using Entities.DTO;
|
||||
using TechHelper.Services;
|
||||
using System.Net.Http.Json;
|
||||
using Newtonsoft.Json;
|
||||
using Entities.DTO;
|
||||
|
||||
namespace TechHelper.Client.Services
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using TechHelper.Services;
|
||||
using Entities.DTO;
|
||||
|
||||
namespace TechHelper.Client.Services
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user