重构项目结构,移除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,12 +1,10 @@
|
||||
using TechHelper.Context;
|
||||
using TechHelper.Services;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TechHelper.Features;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Entities.Contracts;
|
||||
using TechHelper.Services.Beta;
|
||||
|
||||
namespace TechHelper.Controllers
|
||||
{
|
||||
@@ -19,9 +17,9 @@ namespace TechHelper.Controllers
|
||||
public class AccountController : ControllerBase
|
||||
{
|
||||
private readonly UserManager<User> _userManager;
|
||||
private readonly IUserRegistrationService _userRegistrationService;
|
||||
private IAuthenticationService _authenticationService;
|
||||
private readonly IEmailSender _emailSender;
|
||||
private readonly IUserSerivces _userSerivces;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化账户控制器
|
||||
@@ -31,13 +29,13 @@ namespace TechHelper.Controllers
|
||||
/// <param name="emailSender">邮件发送服务</param>
|
||||
/// <param name="authenticationService">认证服务</param>
|
||||
public AccountController(UserManager<User> userManager,
|
||||
IUserRegistrationService userRegistrationService,
|
||||
IEmailSender emailSender,
|
||||
IUserSerivces userSerivces,
|
||||
IAuthenticationService authenticationService)
|
||||
{
|
||||
_userManager = userManager;
|
||||
this._userRegistrationService = userRegistrationService;
|
||||
_emailSender = emailSender;
|
||||
_userSerivces = userSerivces;
|
||||
_authenticationService = authenticationService;
|
||||
}
|
||||
|
||||
@@ -98,7 +96,7 @@ namespace TechHelper.Controllers
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiResponse(false, ModelState));
|
||||
|
||||
var response = await _userRegistrationService.RegisterNewUserAsync(userForRegistrationDto);
|
||||
var response = await _userSerivces.RegisterNewUserAsync(userForRegistrationDto);
|
||||
|
||||
if (response.Status)
|
||||
{
|
||||
@@ -184,6 +182,17 @@ namespace TechHelper.Controllers
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost("initadmin")]
|
||||
public async Task<IActionResult> InitAdmin([FromBody] UserForAdmin admin)
|
||||
{
|
||||
var result = await _userSerivces.InitAdminUser(admin);
|
||||
if(result.Status)
|
||||
{
|
||||
return Ok(result.Message);
|
||||
}
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成两步验证的OTP令牌
|
||||
/// </summary>
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Security.Claims;
|
||||
using TechHelper.Services.Beta;
|
||||
using TechHelper.Services;
|
||||
using Entities.DTO.Class;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
@@ -17,7 +21,7 @@ namespace TechHelper.Server.Controllers
|
||||
[ApiController]
|
||||
public class ClassController : ControllerBase
|
||||
{
|
||||
private IClassService _classService;
|
||||
private TechHelper.Services.Beta.IClassService _classService;
|
||||
private UserManager<User> _userManager;
|
||||
|
||||
/// <summary>
|
||||
@@ -25,12 +29,159 @@ namespace TechHelper.Server.Controllers
|
||||
/// </summary>
|
||||
/// <param name="classService">班级服务</param>
|
||||
/// <param name="userManager">用户管理服务</param>
|
||||
public ClassController(IClassService classService, UserManager<User> userManager)
|
||||
public ClassController(TechHelper.Services.Beta.IClassService classService, UserManager<User> userManager)
|
||||
{
|
||||
_classService = classService;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
#region 班级基本信息CRUD操作
|
||||
|
||||
/// <summary>
|
||||
/// 获取班级列表(支持搜索)
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <returns>班级列表</returns>
|
||||
/// <response code="200">成功获取班级列表</response>
|
||||
/// <response code="400">获取失败</response>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetAll([FromQuery] QueryParameter query)
|
||||
{
|
||||
var result = await _classService.GetAllAsync(query);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取班级详细信息
|
||||
/// </summary>
|
||||
/// <param name="id">班级ID</param>
|
||||
/// <returns>班级详细信息</returns>
|
||||
/// <response code="200">成功获取班级信息</response>
|
||||
/// <response code="400">班级未找到或获取失败</response>
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await _classService.GetAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建新班级
|
||||
/// </summary>
|
||||
/// <param name="model">班级数据传输对象</param>
|
||||
/// <returns>创建结果</returns>
|
||||
/// <response code="200">创建成功</response>
|
||||
/// <response code="400">创建失败</response>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create([FromBody] ClassDto model)
|
||||
{
|
||||
var result = await _classService.AddAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("AdminCreate")]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Create([FromBody] ClassCreateDto dto)
|
||||
{
|
||||
var result = await _classService.AdminAddAsync(dto);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新班级信息
|
||||
/// </summary>
|
||||
/// <param name="model">班级数据传输对象</param>
|
||||
/// <returns>更新结果</returns>
|
||||
/// <response code="200">更新成功</response>
|
||||
/// <response code="400">更新失败</response>
|
||||
[HttpPut]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Update([FromBody] ClassDto model)
|
||||
{
|
||||
var result = await _classService.UpdateAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除班级
|
||||
/// </summary>
|
||||
/// <param name="id">班级ID</param>
|
||||
/// <returns>删除结果</returns>
|
||||
/// <response code="200">删除成功</response>
|
||||
/// <response code="400">删除失败</response>
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
{
|
||||
var result = await _classService.DeleteAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 班级用户管理
|
||||
|
||||
/// <summary>
|
||||
/// 验证班级信息是否存在
|
||||
/// </summary>
|
||||
/// <param name="toClass">包含学校名称、年级和班级名称的数据传输对象</param>
|
||||
/// <returns>验证结果和班级信息</returns>
|
||||
/// <response code="200">验证成功,返回班级信息</response>
|
||||
/// <response code="400">验证失败</response>
|
||||
[HttpPost("validate")]
|
||||
[Authorize(Roles = "Student,Teacher,Admin")]
|
||||
public async Task<IActionResult> ValidateClassInfo(
|
||||
[FromBody] ClassValidDto toClass)
|
||||
{
|
||||
var result = await _classService.ValidateClassRegistration(toClass);
|
||||
|
||||
if (!result.Status) return BadRequest(result.Message);
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户注册到班级
|
||||
/// </summary>
|
||||
@@ -39,107 +190,68 @@ namespace TechHelper.Server.Controllers
|
||||
/// <response code="200">注册成功</response>
|
||||
/// <response code="400">注册失败</response>
|
||||
[HttpPost("userRegiste")]
|
||||
[Authorize(Roles = "Student,Teacher,Admin")]
|
||||
public async Task<IActionResult> UserRegisterToClass(
|
||||
[FromBody] UserRegistrationToClassDto toClass)
|
||||
[FromBody] RegisterUserToClassDto toClass)
|
||||
{
|
||||
|
||||
var result = await _classService.UserRegister(toClass);
|
||||
|
||||
if (!result.Status) return BadRequest(result.Message);
|
||||
|
||||
return Ok();
|
||||
return Ok(result.Message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取班级学生列表
|
||||
/// 仅限教师角色访问,根据教师所在班级信息获取学生列表
|
||||
/// 根据班级ID获取班级学生列表
|
||||
/// </summary>
|
||||
/// <param name="classId">班级ID</param>
|
||||
/// <returns>班级学生列表</returns>
|
||||
/// <response code="200">成功获取学生列表</response>
|
||||
/// <response code="400">权限不足或班级信息缺失</response>
|
||||
[HttpPost("getClassStudents")]
|
||||
public async Task<IActionResult> GetClassStudents()
|
||||
/// <response code="400">班级未找到或获取失败</response>
|
||||
[HttpGet("students/{classId}")]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetClassStudentsById(Guid classId)
|
||||
{
|
||||
if (User.IsInRole("Teacher"))
|
||||
var result = await _classService.GetClassStudentsAsync(classId);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
var gradeClaim = User.FindFirst("Grade")?.Value;
|
||||
var classClaim = User.FindFirst("Class")?.Value;
|
||||
|
||||
if (string.IsNullOrEmpty(gradeClaim) || string.IsNullOrEmpty(classClaim))
|
||||
{
|
||||
return BadRequest("未识别到你加入的班级信息(年级或班级声明缺失)。");
|
||||
}
|
||||
|
||||
if (!byte.TryParse(gradeClaim, out byte grade) || !byte.TryParse(classClaim, out byte cla))
|
||||
{
|
||||
return BadRequest("你班级或年级信息格式不正确。");
|
||||
}
|
||||
|
||||
var classDto = new ClassDto
|
||||
{
|
||||
Grade = grade,
|
||||
Class = cla
|
||||
};
|
||||
|
||||
var result = await _classService.GetClassStudents(classDto);
|
||||
var css = result.Result as ICollection<ClassStudent>;
|
||||
if (css == null) return BadRequest("你还没有学生");
|
||||
|
||||
|
||||
List<StudentDto> sts = new List<StudentDto>();
|
||||
css?.ToList().ForEach(s => sts.Add(new StudentDto
|
||||
{
|
||||
DisplayName = s.Student.DisplayName,
|
||||
Id = s.Student.Id,
|
||||
}));
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
return Ok(sts);
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest("你没有权限查看,未识别到你的教师身份。");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建新班级
|
||||
/// </summary>
|
||||
/// <param name="classDto">班级数据传输对象</param>
|
||||
/// <returns>操作结果</returns>
|
||||
/// <response code="200">班级创建成功</response>
|
||||
/// <response code="400">班级创建失败</response>
|
||||
[HttpPost("Create")]
|
||||
public async Task<IActionResult> Create(
|
||||
[FromBody] ClassDto classDto)
|
||||
{
|
||||
var result = await _classService.AddAsync(classDto);
|
||||
if (!result.Status) return BadRequest(result.Message);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定年级的所有班级列表
|
||||
/// </summary>
|
||||
/// <param name="classDto">年级编号</param>
|
||||
/// <returns>班级列表</returns>
|
||||
/// <response code="200">成功获取班级列表</response>
|
||||
/// <response code="400">获取失败</response>
|
||||
[HttpPost("GetGradeClasses")]
|
||||
public async Task<IActionResult> GetGradeClasses(
|
||||
[FromBody] byte classDto)
|
||||
{
|
||||
var result = await _classService.GetGradeClasses(classDto);
|
||||
if (!result.Status) return BadRequest(result.Message);
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("classes")]
|
||||
[Authorize(Roles = "Teacher, Student")]
|
||||
public async Task<IActionResult> GetUserInjoinedClass()
|
||||
{
|
||||
var user = await _userManager.FindByEmailAsync(User.Identity.Name);
|
||||
var userid = user.Id;
|
||||
|
||||
var result = await _classService.GetUserInjoinedClasses(userid);
|
||||
if (result.Status)
|
||||
return Ok(result.Result);
|
||||
else
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
[HttpGet("injoint/{id:guid}")]
|
||||
[Authorize(Roles = "Teacher, Student")]
|
||||
public async Task<IActionResult> InjoinClass(Guid id)
|
||||
{
|
||||
var user = await _userManager.FindByEmailAsync(User.Identity.Name);
|
||||
var userid = user.Id;
|
||||
|
||||
var registerClass = new RegisterUserToClassDto { ClassId = id, UserId = userid, Role = user.Role ?? UserRoles.Student };
|
||||
|
||||
var result = await _classService.UserRegister(registerClass);
|
||||
if (result.Status)
|
||||
return Ok(result.Result);
|
||||
else
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
28
TechHelper.Server/Controllers/CommonController.cs
Normal file
28
TechHelper.Server/Controllers/CommonController.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
[Route("api/common")]
|
||||
[ApiController]
|
||||
public class CommonController : Controller
|
||||
{
|
||||
private readonly UserManager<User> _userManager;
|
||||
|
||||
public CommonController(UserManager<User> userManager)
|
||||
{
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
[HttpGet("GetCommonType")]
|
||||
public IActionResult GetCommonType(TypeCommonRequest typeCommon)
|
||||
{
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,8 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TechHelper.Server.Services;
|
||||
using System.Security.Claims;
|
||||
using TechHelper.Services;
|
||||
using TechHelper.Services.Beta;
|
||||
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
@@ -30,13 +29,14 @@ namespace TechHelper.Server.Controllers
|
||||
/// </summary>
|
||||
/// <param name="examDto">考试/作业的数据传输对象。</param>
|
||||
/// <returns>新创建的考试/作业信息或错误信息。</returns>
|
||||
[HttpPost("add")]
|
||||
public async Task<IActionResult> AddExam([FromBody] AssignmentDto examDto)
|
||||
[HttpPost()]
|
||||
[Authorize(Roles = "Teacher")]
|
||||
public async Task<IActionResult> AddExam([FromBody] ExamDto examDto)
|
||||
{
|
||||
var user = await _userManager.FindByEmailAsync(User.Identity.Name);
|
||||
if (user == null) return NotFound("没有找到用户");
|
||||
examDto.CreatorId = user.Id;
|
||||
var result = await _examService.CreateExamAsync(examDto);
|
||||
var result = await _examService.AddAsync(examDto);
|
||||
|
||||
if (result.Status)
|
||||
{
|
||||
@@ -48,17 +48,12 @@ namespace TechHelper.Server.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 提交作业。
|
||||
/// </summary>
|
||||
/// <param name="submissionDto">提交的数据传输对象。</param>
|
||||
/// <returns>提交结果或错误信息。</returns>
|
||||
[HttpPost("submission")]
|
||||
public async Task<IActionResult> SubmissionAssignment([FromBody] SubmissionDto submissionDto)
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAllExams([FromQuery] QueryParameter queryParameter)
|
||||
{
|
||||
var result = await _examService.SubmissionAssignment(submissionDto);
|
||||
var result = await _examService.GetAllAsync(queryParameter);
|
||||
|
||||
if (result.Status)
|
||||
if(result.Status)
|
||||
{
|
||||
return Ok(result.Result);
|
||||
}
|
||||
@@ -96,70 +91,7 @@ namespace TechHelper.Server.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有考试/作业的预览信息(教师获取自己创建的,学生获取自己需要提交的)。
|
||||
/// </summary>
|
||||
/// <returns>考试/作业预览列表或错误信息。</returns>
|
||||
[HttpGet("getAllPreview")]
|
||||
public async Task<IActionResult> GetAllExamPreview()
|
||||
{
|
||||
var user = await _userManager.FindByEmailAsync(User.Identity.Name);
|
||||
if (user == null) return NotFound("没有找到用户");
|
||||
|
||||
ApiResponse result;
|
||||
|
||||
if (User.IsInRole("Teacher"))
|
||||
{
|
||||
result = await _examService.GetAllExamPreviewsAsync(user.Id);
|
||||
}
|
||||
else if (User.IsInRole("Student"))
|
||||
{
|
||||
result = await _examService.GetAllSubmissionAsync(user.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Forbid("你没有查看考试预览的权限。");
|
||||
}
|
||||
|
||||
if (result.Status)
|
||||
{
|
||||
return Ok(result.Result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取学生的所有提交记录。
|
||||
/// </summary>
|
||||
/// <returns>提交记录列表或错误信息。</returns>
|
||||
[HttpGet("getAllSubmissions")]
|
||||
[Authorize(Roles = "Student")]
|
||||
public async Task<IActionResult> GetAllSubmission()
|
||||
{
|
||||
var user = await _userManager.FindByEmailAsync(User.Identity.Name);
|
||||
if (user == null) return NotFound("没有找到用户");
|
||||
|
||||
var result = await _examService.GetAllSubmissionAsync(user.Id);
|
||||
|
||||
if (result.Status)
|
||||
{
|
||||
return Ok(result.Result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 逻辑删除指定ID的考试/作业。
|
||||
/// </summary>
|
||||
/// <param name="id">要删除的考试/作业ID。</param>
|
||||
/// <returns>操作结果。</returns>
|
||||
[HttpDelete("delete/{id:guid}")]
|
||||
[HttpDelete("{id:guid}")]
|
||||
[Authorize(Roles = "Teacher")]
|
||||
public async Task<IActionResult> DeleteAsync(Guid id)
|
||||
{
|
||||
@@ -179,13 +111,32 @@ namespace TechHelper.Server.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("GetTotalDistributionInClass")]
|
||||
[Authorize(Roles = "Teacher")]
|
||||
public async Task<IActionResult> GetTotalDistributionInClass(AssigExamToClassDto dto)
|
||||
{
|
||||
var result = await _examService.GetExamTotalErrorDistributionInClassAsync(dto);
|
||||
|
||||
if (result.Status)
|
||||
{
|
||||
return Ok(result.Result);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result.Message.Contains("未找到") || result.Message.Contains("not found", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return NotFound(result.Message);
|
||||
}
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为指定学生指派作业
|
||||
/// </summary>
|
||||
/// <param name="AETSdto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("assignmentExamToStudent")]
|
||||
[HttpPost("assignmentExamToStudents")]
|
||||
[Authorize(Roles = "Teacher")]
|
||||
public async Task<IActionResult> AssignmentExamToStudent([FromBody] AssigExamToStudentsDto AETSdto)
|
||||
{
|
||||
@@ -206,12 +157,28 @@ namespace TechHelper.Server.Controllers
|
||||
/// </summary>
|
||||
/// <param name="AETSdto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("assignmentExamToStudent/{id:guid}")]
|
||||
[HttpPost("assignmentExamToClass")]
|
||||
[Authorize(Roles = "Teacher")]
|
||||
public async Task<IActionResult> AssignmentExamToAllStudentsAsync(Guid id)
|
||||
public async Task<IActionResult> AssignmentExamToClassAsync([FromBody] AssigExamToClassDto AETSdto)
|
||||
{
|
||||
var user = await _userManager.FindByEmailAsync(User.Identity.Name ?? "");
|
||||
var result = await _examService.AssignmentToAllStudentsAsync(id, user.Id);
|
||||
var result = await _examService.AssignmentToClassAsync(user.Id, AETSdto.examId, AETSdto.classId);
|
||||
if (result.Status)
|
||||
{
|
||||
return Ok(result.Result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpGet("GetExamSubmissionDetailInClassAsync")]
|
||||
public async Task<IActionResult> GetExamSubmissionDetailInClassAsync([FromBody] AssigExamToClassDto model)
|
||||
{
|
||||
var result = await _examService.GetExamSubmissionDetailInClassAsync(model);
|
||||
if (result.Status)
|
||||
{
|
||||
return Ok(result.Result);
|
||||
|
||||
161
TechHelper.Server/Controllers/ExamQuestionController.cs
Normal file
161
TechHelper.Server/Controllers/ExamQuestionController.cs
Normal file
@@ -0,0 +1,161 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Security.Claims;
|
||||
using TechHelper.Services;
|
||||
using TechHelper.Services.Beta;
|
||||
using static TechHelper.Services.Beta.IExamQuestionService;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 考试题目管理控制器
|
||||
/// 处理考试题目相关的操作,如创建、更新、删除考试题目等
|
||||
/// </summary>
|
||||
[Route("api/exam-question")]
|
||||
[ApiController]
|
||||
public class ExamQuestionController : ControllerBase
|
||||
{
|
||||
private readonly IExamQuestionService _examQuestionService;
|
||||
private readonly UserManager<User> _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化考试题目控制器
|
||||
/// </summary>
|
||||
/// <param name="examQuestionService">考试题目服务</param>
|
||||
/// <param name="userManager">用户管理服务</param>
|
||||
public ExamQuestionController(IExamQuestionService examQuestionService, UserManager<User> userManager)
|
||||
{
|
||||
_examQuestionService = examQuestionService;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
#region 考试题目基本信息CRUD操作
|
||||
|
||||
/// <summary>
|
||||
/// 获取考试题目列表(支持搜索)
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <returns>考试题目列表</returns>
|
||||
/// <response code="200">成功获取考试题目列表</response>
|
||||
/// <response code="400">获取失败</response>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetAll([FromQuery] QueryParameter query)
|
||||
{
|
||||
var result = await _examQuestionService.GetAllAsync(query);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取考试题目详细信息
|
||||
/// </summary>
|
||||
/// <param name="id">考试题目ID</param>
|
||||
/// <returns>考试题目详细信息</returns>
|
||||
/// <response code="200">成功获取考试题目信息</response>
|
||||
/// <response code="400">考试题目未找到或获取失败</response>
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await _examQuestionService.GetAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建新考试题目
|
||||
/// </summary>
|
||||
/// <param name="model">考试题目数据传输对象</param>
|
||||
/// <returns>创建结果</returns>
|
||||
/// <response code="200">创建成功</response>
|
||||
/// <response code="400">创建失败</response>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = "Admin,Teacher")]
|
||||
public async Task<IActionResult> Create([FromBody] ExamQuestionDto model)
|
||||
{
|
||||
var result = await _examQuestionService.AddAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新考试题目信息
|
||||
/// </summary>
|
||||
/// <param name="model">考试题目数据传输对象</param>
|
||||
/// <returns>更新结果</returns>
|
||||
/// <response code="200">更新成功</response>
|
||||
/// <response code="400">更新失败</response>
|
||||
[HttpPut]
|
||||
[Authorize(Roles = "Admin, Teacher")]
|
||||
public async Task<IActionResult> Update([FromBody] ExamQuestionDto model)
|
||||
{
|
||||
var result = await _examQuestionService.UpdateAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除考试题目
|
||||
/// </summary>
|
||||
/// <param name="id">考试题目ID</param>
|
||||
/// <returns>删除结果</returns>
|
||||
/// <response code="200">删除成功</response>
|
||||
/// <response code="400">删除失败</response>
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
{
|
||||
var result = await _examQuestionService.DeleteAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
[HttpPost("GetQuestionDependy")]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetQuestionDependy(QuesitionDenpendceyRequst request)
|
||||
{
|
||||
var result = await _examQuestionService.GetQuestionDependy(request);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
}
|
||||
}
|
||||
145
TechHelper.Server/Controllers/ExamTypeController.cs
Normal file
145
TechHelper.Server/Controllers/ExamTypeController.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Security.Claims;
|
||||
using TechHelper.Services.Beta;
|
||||
using TechHelper.Services;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 考试类型管理控制器
|
||||
/// 处理考试类型相关的操作,如创建、更新、删除考试类型等
|
||||
/// </summary>
|
||||
[Route("api/exam-type")]
|
||||
[ApiController]
|
||||
public class ExamTypeController : ControllerBase
|
||||
{
|
||||
private readonly IExamTypeService _examTypeService;
|
||||
private readonly UserManager<User> _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化考试类型控制器
|
||||
/// </summary>
|
||||
/// <param name="examTypeService">考试类型服务</param>
|
||||
/// <param name="userManager">用户管理服务</param>
|
||||
public ExamTypeController(IExamTypeService examTypeService, UserManager<User> userManager)
|
||||
{
|
||||
_examTypeService = examTypeService;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
#region 考试类型基本信息CRUD操作
|
||||
|
||||
/// <summary>
|
||||
/// 获取考试类型列表(支持搜索)
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <returns>考试类型列表</returns>
|
||||
/// <response code="200">成功获取考试类型列表</response>
|
||||
/// <response code="400">获取失败</response>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetAll([FromQuery] QueryParameter query)
|
||||
{
|
||||
var result = await _examTypeService.GetAllAsync(query);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取考试类型详细信息
|
||||
/// </summary>
|
||||
/// <param name="id">考试类型ID</param>
|
||||
/// <returns>考试类型详细信息</returns>
|
||||
/// <response code="200">成功获取考试类型信息</response>
|
||||
/// <response code="400">考试类型未找到或获取失败</response>
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await _examTypeService.GetAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建新考试类型
|
||||
/// </summary>
|
||||
/// <param name="model">考试类型数据传输对象</param>
|
||||
/// <returns>创建结果</returns>
|
||||
/// <response code="200">创建成功</response>
|
||||
/// <response code="400">创建失败</response>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = "Admin, Teacher")]
|
||||
public async Task<IActionResult> Create([FromBody] ExamTypeDto model)
|
||||
{
|
||||
var result = await _examTypeService.AddAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新考试类型信息
|
||||
/// </summary>
|
||||
/// <param name="model">考试类型数据传输对象</param>
|
||||
/// <returns>更新结果</returns>
|
||||
/// <response code="200">更新成功</response>
|
||||
/// <response code="400">更新失败</response>
|
||||
[HttpPut]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Update([FromBody] ExamTypeDto model)
|
||||
{
|
||||
var result = await _examTypeService.UpdateAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除考试类型
|
||||
/// </summary>
|
||||
/// <param name="id">考试类型ID</param>
|
||||
/// <returns>删除结果</returns>
|
||||
/// <response code="200">删除成功</response>
|
||||
/// <response code="400">删除失败</response>
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
{
|
||||
var result = await _examTypeService.DeleteAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
144
TechHelper.Server/Controllers/GradeController.cs
Normal file
144
TechHelper.Server/Controllers/GradeController.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Security.Claims;
|
||||
using TechHelper.Services.Beta;
|
||||
using TechHelper.Services;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 年级管理控制器
|
||||
/// 处理年级相关的操作,如创建、更新、删除年级等
|
||||
/// </summary>
|
||||
[Route("api/grade")]
|
||||
[ApiController]
|
||||
public class GradeController : ControllerBase
|
||||
{
|
||||
private TechHelper.Services.Beta.IGradeService _gradeService;
|
||||
private UserManager<User> _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化年级控制器
|
||||
/// </summary>
|
||||
/// <param name="gradeService">年级服务</param>
|
||||
/// <param name="userManager">用户管理服务</param>
|
||||
public GradeController(TechHelper.Services.Beta.IGradeService gradeService, UserManager<User> userManager)
|
||||
{
|
||||
_gradeService = gradeService;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
#region 年级基本信息CRUD操作
|
||||
|
||||
/// <summary>
|
||||
/// 获取年级列表(支持搜索)
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <returns>年级列表</returns>
|
||||
/// <response code="200">成功获取年级列表</response>
|
||||
/// <response code="400">获取失败</response>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetAll([FromQuery] QueryParameter query)
|
||||
{
|
||||
var result = await _gradeService.GetAllAsync(query);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取年级详细信息
|
||||
/// </summary>
|
||||
/// <param name="id">年级ID</param>
|
||||
/// <returns>年级详细信息</returns>
|
||||
/// <response code="200">成功获取年级信息</response>
|
||||
/// <response code="400">年级未找到或获取失败</response>
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await _gradeService.GetAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建新年级
|
||||
/// </summary>
|
||||
/// <param name="model">年级数据传输对象</param>
|
||||
/// <returns>创建结果</returns>
|
||||
/// <response code="200">创建成功</response>
|
||||
/// <response code="400">创建失败</response>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create([FromBody] GradeDto model)
|
||||
{
|
||||
var result = await _gradeService.AddAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新年级信息
|
||||
/// </summary>
|
||||
/// <param name="model">年级数据传输对象</param>
|
||||
/// <returns>更新结果</returns>
|
||||
/// <response code="200">更新成功</response>
|
||||
/// <response code="400">更新失败</response>
|
||||
[HttpPut]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Update([FromBody] GradeDto model)
|
||||
{
|
||||
var result = await _gradeService.UpdateAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除年级
|
||||
/// </summary>
|
||||
/// <param name="id">年级ID</param>
|
||||
/// <returns>删除结果</returns>
|
||||
/// <response code="200">删除成功</response>
|
||||
/// <response code="400">删除失败</response>
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
{
|
||||
var result = await _gradeService.DeleteAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
167
TechHelper.Server/Controllers/KeyPointController.cs
Normal file
167
TechHelper.Server/Controllers/KeyPointController.cs
Normal file
@@ -0,0 +1,167 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TechHelper.Services;
|
||||
using TechHelper.Services.Beta;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 知识点管理控制器
|
||||
/// 处理知识点相关的操作,如创建、更新、删除知识点等
|
||||
/// </summary>
|
||||
[Route("api/keypoint")]
|
||||
[ApiController]
|
||||
public class KeyPointController : ControllerBase
|
||||
{
|
||||
private readonly IKeyPointService _keyPointService;
|
||||
private readonly UserManager<User> _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化知识点控制器
|
||||
/// </summary>
|
||||
/// <param name="keyPointService">知识点服务</param>
|
||||
/// <param name="userManager">用户管理服务</param>
|
||||
public KeyPointController(IKeyPointService keyPointService, UserManager<User> userManager)
|
||||
{
|
||||
_keyPointService = keyPointService;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
#region 知识点基本信息CRUD操作
|
||||
|
||||
/// <summary>
|
||||
/// 获取知识点列表(支持搜索)
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <returns>知识点列表</returns>
|
||||
/// <response code="200">成功获取知识点列表</response>
|
||||
/// <response code="400">获取失败</response>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetAll([FromQuery] QueryParameter query)
|
||||
{
|
||||
var result = await _keyPointService.GetAllAsync(query);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取知识点详细信息
|
||||
/// </summary>
|
||||
/// <param name="id">知识点ID</param>
|
||||
/// <returns>知识点详细信息</returns>
|
||||
/// <response code="200">成功获取知识点信息</response>
|
||||
/// <response code="400">知识点未找到或获取失败</response>
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await _keyPointService.GetAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建新知识点
|
||||
/// </summary>
|
||||
/// <param name="model">知识点数据传输对象</param>
|
||||
/// <returns>创建结果</returns>
|
||||
/// <response code="200">创建成功</response>
|
||||
/// <response code="400">创建失败</response>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> Create([FromBody] KeyPointDto model)
|
||||
{
|
||||
var result = await _keyPointService.AddAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新知识点信息
|
||||
/// </summary>
|
||||
/// <param name="model">知识点数据传输对象</param>
|
||||
/// <returns>更新结果</returns>
|
||||
/// <response code="200">更新成功</response>
|
||||
/// <response code="400">更新失败</response>
|
||||
[HttpPut]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> Update([FromBody] KeyPointDto model)
|
||||
{
|
||||
var result = await _keyPointService.UpdateAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除知识点
|
||||
/// </summary>
|
||||
/// <param name="id">知识点ID</param>
|
||||
/// <returns>删除结果</returns>
|
||||
/// <response code="200">删除成功</response>
|
||||
/// <response code="400">删除失败</response>
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
{
|
||||
var result = await _keyPointService.DeleteAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 知识点扩展操作
|
||||
|
||||
/// <summary>
|
||||
/// 根据课程ID获取知识点列表
|
||||
/// </summary>
|
||||
/// <param name="lessonId">课程ID</param>
|
||||
/// <returns>知识点列表</returns>
|
||||
/// <response code="200">成功获取知识点列表</response>
|
||||
/// <response code="400">获取失败</response>
|
||||
[HttpGet("lesson/{lessonId}")]
|
||||
[Authorize(Roles = "Student,Teacher,Admin")]
|
||||
public async Task<IActionResult> GetByLessonId(Guid lessonId)
|
||||
{
|
||||
var result = await _keyPointService.GetKeyPointsByLessonIdAsync(lessonId);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
167
TechHelper.Server/Controllers/LessonController.cs
Normal file
167
TechHelper.Server/Controllers/LessonController.cs
Normal file
@@ -0,0 +1,167 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TechHelper.Services;
|
||||
using TechHelper.Services.Beta;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 课程管理控制器
|
||||
/// 处理课程相关的操作,如创建、更新、删除课程等
|
||||
/// </summary>
|
||||
[Route("api/Lesson")]
|
||||
[ApiController]
|
||||
public class LessonController : ControllerBase
|
||||
{
|
||||
private readonly ILessonService _lessonService;
|
||||
private readonly UserManager<User> _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化课程控制器
|
||||
/// </summary>
|
||||
/// <param name="lessonService">课程服务</param>
|
||||
/// <param name="userManager">用户管理服务</param>
|
||||
public LessonController(ILessonService lessonService, UserManager<User> userManager)
|
||||
{
|
||||
_lessonService = lessonService;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
#region 课程基本信息CRUD操作
|
||||
|
||||
/// <summary>
|
||||
/// 获取课程列表(支持搜索)
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <returns>课程列表</returns>
|
||||
/// <response code="200">成功获取课程列表</response>
|
||||
/// <response code="400">获取失败</response>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetAll([FromQuery] QueryParameter query)
|
||||
{
|
||||
var result = await _lessonService.GetAllAsync(query);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取课程详细信息
|
||||
/// </summary>
|
||||
/// <param name="id">课程ID</param>
|
||||
/// <returns>课程详细信息</returns>
|
||||
/// <response code="200">成功获取课程信息</response>
|
||||
/// <response code="400">课程未找到或获取失败</response>
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await _lessonService.GetAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建新课程
|
||||
/// </summary>
|
||||
/// <param name="model">课程数据传输对象</param>
|
||||
/// <returns>创建结果</returns>
|
||||
/// <response code="200">创建成功</response>
|
||||
/// <response code="400">创建失败</response>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> Create([FromBody] LessonDto model)
|
||||
{
|
||||
var result = await _lessonService.AddAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新课程信息
|
||||
/// </summary>
|
||||
/// <param name="model">课程数据传输对象</param>
|
||||
/// <returns>更新结果</returns>
|
||||
/// <response code="200">更新成功</response>
|
||||
/// <response code="400">更新失败</response>
|
||||
[HttpPut]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> Update([FromBody] LessonDto model)
|
||||
{
|
||||
var result = await _lessonService.UpdateAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除课程
|
||||
/// </summary>
|
||||
/// <param name="id">课程ID</param>
|
||||
/// <returns>删除结果</returns>
|
||||
/// <response code="200">删除成功</response>
|
||||
/// <response code="400">删除失败</response>
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
{
|
||||
var result = await _lessonService.DeleteAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 课程扩展操作
|
||||
|
||||
/// <summary>
|
||||
/// 根据教材ID获取课程列表
|
||||
/// </summary>
|
||||
/// <param name="textbookId">教材ID</param>
|
||||
/// <returns>课程列表</returns>
|
||||
/// <response code="200">成功获取课程列表</response>
|
||||
/// <response code="400">获取失败</response>
|
||||
[HttpGet("textbook/{textbookId}")]
|
||||
[Authorize(Roles = "Student,Teacher,Admin")]
|
||||
public async Task<IActionResult> GetByTextbookId(Guid textbookId)
|
||||
{
|
||||
var result = await _lessonService.GetAllAsync(new QueryParameter { Search = textbookId.ToString() });
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TechHelper.Services;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
[Route("api/note")]
|
||||
[ApiController]
|
||||
public class NoteController : ControllerBase
|
||||
{
|
||||
private readonly INoteService _noteService;
|
||||
|
||||
// 通过依赖注入获取 NoteService
|
||||
public NoteController(INoteService noteService)
|
||||
{
|
||||
_noteService = noteService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有全局数据。
|
||||
/// GET: api/Note
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll([FromQuery] QueryParameter query)
|
||||
{
|
||||
var response = await _noteService.GetAllAsync(query);
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据 ID 获取单个全局数据。
|
||||
/// GET: api/Note/{id}
|
||||
/// </summary>
|
||||
[HttpGet("{id}")]
|
||||
public async Task<IActionResult> Get(byte id)
|
||||
{
|
||||
var response = await _noteService.GetAsync(id);
|
||||
if (!response.Status)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加新的全局数据。
|
||||
/// POST: api/Note
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Add([FromBody] GlobalDto model)
|
||||
{
|
||||
var response = await _noteService.AddAsync(model);
|
||||
if (!response.Status)
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新已存在的全局数据。
|
||||
/// PUT: api/Note
|
||||
/// </summary>
|
||||
[HttpPut]
|
||||
public async Task<IActionResult> Update([FromBody] GlobalDto model)
|
||||
{
|
||||
var response = await _noteService.UpdateAsync(model);
|
||||
if (!response.Status)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据 ID 删除全局数据。
|
||||
/// DELETE: api/Note/{id}
|
||||
/// </summary>
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> Delete(byte id)
|
||||
{
|
||||
var response = await _noteService.DeleteAsync(id);
|
||||
if (!response.Status)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
return Ok(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
188
TechHelper.Server/Controllers/QuestionController.cs
Normal file
188
TechHelper.Server/Controllers/QuestionController.cs
Normal file
@@ -0,0 +1,188 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TechHelper.Services;
|
||||
using TechHelper.Services.Beta;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 题目管理控制器
|
||||
/// 处理题目相关的操作,如CRUD、按标题查找等
|
||||
/// </summary>
|
||||
[Route("api/question")]
|
||||
[ApiController]
|
||||
public class QuestionController : ControllerBase
|
||||
{
|
||||
private readonly IQuestionService _questionService;
|
||||
private readonly UserManager<User> _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化题目控制器
|
||||
/// </summary>
|
||||
/// <param name="questionService">题目服务</param>
|
||||
/// <param name="userManager">用户管理服务</param>
|
||||
public QuestionController(IQuestionService questionService, UserManager<User> userManager)
|
||||
{
|
||||
_questionService = questionService;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
#region 题目基本信息CRUD操作
|
||||
|
||||
/// <summary>
|
||||
/// 获取题目列表(支持搜索和分页)
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <returns>题目列表</returns>
|
||||
/// <response code="200">成功获取题目列表</response>
|
||||
/// <response code="400">获取失败</response>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetAll([FromQuery] QueryParameter query)
|
||||
{
|
||||
var result = await _questionService.GetAllAsync(query);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取题目详细信息
|
||||
/// </summary>
|
||||
/// <param name="id">题目ID</param>
|
||||
/// <returns>题目详细信息</returns>
|
||||
/// <response code="200">成功获取题目信息</response>
|
||||
/// <response code="400">题目未找到或获取失败</response>
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await _questionService.GetAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建新题目
|
||||
/// </summary>
|
||||
/// <param name="model">题目数据传输对象</param>
|
||||
/// <returns>创建结果</returns>
|
||||
/// <response code="200">创建成功</response>
|
||||
/// <response code="400">创建失败</response>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> Create([FromBody] QuestionDto model)
|
||||
{
|
||||
var result = await _questionService.AddAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新题目信息
|
||||
/// </summary>
|
||||
/// <param name="model">题目数据传输对象</param>
|
||||
/// <returns>更新结果</returns>
|
||||
/// <response code="200">更新成功</response>
|
||||
/// <response code="400">更新失败</response>
|
||||
[HttpPut]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> Update([FromBody] QuestionDto model)
|
||||
{
|
||||
var result = await _questionService.UpdateAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除题目(软删除)
|
||||
/// </summary>
|
||||
/// <param name="id">题目ID</param>
|
||||
/// <returns>删除结果</returns>
|
||||
/// <response code="200">删除成功</response>
|
||||
/// <response code="400">删除失败</response>
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
{
|
||||
var result = await _questionService.DeleteAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 题目业务逻辑操作
|
||||
|
||||
/// <summary>
|
||||
/// 根据标题查找题目
|
||||
/// </summary>
|
||||
/// <param name="title">题目标题</param>
|
||||
/// <returns>题目信息</returns>
|
||||
/// <response code="200">成功找到题目</response>
|
||||
/// <response code="400">题目未找到或查找失败</response>
|
||||
[HttpGet("by-title/{title}")]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetByTitle(string title)
|
||||
{
|
||||
var result = await _questionService.FindByTitle(title);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量检查题目标题是否存在
|
||||
/// </summary>
|
||||
/// <param name="titles">题目标题集合</param>
|
||||
/// <returns>标题存在性检查结果</returns>
|
||||
/// <response code="200">检查成功</response>
|
||||
/// <response code="400">检查失败</response>
|
||||
[HttpPost("check-titles")]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> CheckTitlesExistence([FromBody] List<string> titles)
|
||||
{
|
||||
var result = await _questionService.CheckTitlesExistence(titles);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
145
TechHelper.Server/Controllers/QuestionTypeController.cs
Normal file
145
TechHelper.Server/Controllers/QuestionTypeController.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Security.Claims;
|
||||
using TechHelper.Services.Beta;
|
||||
using TechHelper.Services;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 题型管理控制器
|
||||
/// 处理题型相关的操作,如创建、更新、删除题型等
|
||||
/// </summary>
|
||||
[Route("api/question-type")]
|
||||
[ApiController]
|
||||
public class QuestionTypeController : ControllerBase
|
||||
{
|
||||
private readonly IQuestionTypeService _questionTypeService;
|
||||
private readonly UserManager<User> _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化题型控制器
|
||||
/// </summary>
|
||||
/// <param name="questionTypeService">题型服务</param>
|
||||
/// <param name="userManager">用户管理服务</param>
|
||||
public QuestionTypeController(IQuestionTypeService questionTypeService, UserManager<User> userManager)
|
||||
{
|
||||
_questionTypeService = questionTypeService;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
#region 题型基本信息CRUD操作
|
||||
|
||||
/// <summary>
|
||||
/// 获取题型列表(支持搜索)
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <returns>题型列表</returns>
|
||||
/// <response code="200">成功获取题型列表</response>
|
||||
/// <response code="400">获取失败</response>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetAll([FromQuery] QueryParameter query)
|
||||
{
|
||||
var result = await _questionTypeService.GetAllAsync(query);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取题型详细信息
|
||||
/// </summary>
|
||||
/// <param name="id">题型ID</param>
|
||||
/// <returns>题型详细信息</returns>
|
||||
/// <response code="200">成功获取题型信息</response>
|
||||
/// <response code="400">题型未找到或获取失败</response>
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await _questionTypeService.GetAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建新题型
|
||||
/// </summary>
|
||||
/// <param name="model">题型数据传输对象</param>
|
||||
/// <returns>创建结果</returns>
|
||||
/// <response code="200">创建成功</response>
|
||||
/// <response code="400">创建失败</response>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = "Admin, Teacher")]
|
||||
public async Task<IActionResult> Create([FromBody] QuestionTypeDto model)
|
||||
{
|
||||
var result = await _questionTypeService.AddAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新题型信息
|
||||
/// </summary>
|
||||
/// <param name="model">题型数据传输对象</param>
|
||||
/// <returns>更新结果</returns>
|
||||
/// <response code="200">更新成功</response>
|
||||
/// <response code="400">更新失败</response>
|
||||
[HttpPut]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Update([FromBody] QuestionTypeDto model)
|
||||
{
|
||||
var result = await _questionTypeService.UpdateAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除题型
|
||||
/// </summary>
|
||||
/// <param name="id">题型ID</param>
|
||||
/// <returns>删除结果</returns>
|
||||
/// <response code="200">删除成功</response>
|
||||
/// <response code="400">删除失败</response>
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
{
|
||||
var result = await _questionTypeService.DeleteAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
161
TechHelper.Server/Controllers/SchoolController.cs
Normal file
161
TechHelper.Server/Controllers/SchoolController.cs
Normal file
@@ -0,0 +1,161 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TechHelper.Services;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 学校管理控制器
|
||||
/// 处理学校相关的操作,如创建、更新、删除学校等
|
||||
/// </summary>
|
||||
[Route("api/school")]
|
||||
[ApiController]
|
||||
public class SchoolController : ControllerBase
|
||||
{
|
||||
private TechHelper.Services.Beta.ISchoolService _schoolService;
|
||||
private UserManager<User> _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化学校控制器
|
||||
/// </summary>
|
||||
/// <param name="schoolService">学校服务</param>
|
||||
/// <param name="userManager">用户管理服务</param>
|
||||
public SchoolController(TechHelper.Services.Beta.ISchoolService schoolService, UserManager<User> userManager)
|
||||
{
|
||||
_schoolService = schoolService;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
#region 学校基本信息CRUD操作
|
||||
|
||||
/// <summary>
|
||||
/// 获取学校列表(支持搜索)
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <returns>学校列表</returns>
|
||||
/// <response code="200">成功获取学校列表</response>
|
||||
/// <response code="400">获取失败</response>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetAll([FromQuery] QueryParameter query)
|
||||
{
|
||||
var result = await _schoolService.GetAllAsync(query);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取学校详细信息
|
||||
/// </summary>
|
||||
/// <param name="id">学校ID</param>
|
||||
/// <returns>学校详细信息</returns>
|
||||
/// <response code="200">成功获取学校信息</response>
|
||||
/// <response code="400">学校未找到或获取失败</response>
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await _schoolService.GetAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建新学校
|
||||
/// </summary>
|
||||
/// <param name="model">学校数据传输对象</param>
|
||||
/// <returns>创建结果</returns>
|
||||
/// <response code="200">创建成功</response>
|
||||
/// <response code="400">创建失败</response>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create([FromBody] SchoolDto model)
|
||||
{
|
||||
var result = await _schoolService.AddAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新学校信息
|
||||
/// </summary>
|
||||
/// <param name="model">学校数据传输对象</param>
|
||||
/// <returns>更新结果</returns>
|
||||
/// <response code="200">更新成功</response>
|
||||
/// <response code="400">更新失败</response>
|
||||
[HttpPut]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Update([FromBody] SchoolDto model)
|
||||
{
|
||||
var result = await _schoolService.UpdateAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除学校
|
||||
/// </summary>
|
||||
/// <param name="id">学校ID</param>
|
||||
/// <returns>删除结果</returns>
|
||||
/// <response code="200">删除成功</response>
|
||||
/// <response code="400">删除失败</response>
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
{
|
||||
var result = await _schoolService.DeleteAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据学校名称获取学校信息
|
||||
/// </summary>
|
||||
/// <param name="schoolName">学校名称</param>
|
||||
/// <returns>学校信息</returns>
|
||||
/// <response code="200">成功获取学校信息</response>
|
||||
/// <response code="400">学校未找到或获取失败</response>
|
||||
[HttpGet("byname/{schoolName}")]
|
||||
[Authorize(Roles = "Student,Teacher,Admin")]
|
||||
public async Task<IActionResult> GetByName(string schoolName)
|
||||
{
|
||||
var result = await _schoolService.GetSchoolByNameAsync(schoolName);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,7 @@ using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TechHelper.Server.Services;
|
||||
using System.Security.Claims;
|
||||
using TechHelper.Services.Beta;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
@@ -13,11 +12,11 @@ namespace TechHelper.Server.Controllers
|
||||
[Authorize]
|
||||
public class StudentSubmissionController : ControllerBase
|
||||
{
|
||||
private readonly IStudentSubmissionService _studentSubmissionService;
|
||||
private readonly ISubmissionService _studentSubmissionService;
|
||||
private readonly UserManager<User> _userManager;
|
||||
|
||||
public StudentSubmissionController(
|
||||
IStudentSubmissionService studentSubmissionService,
|
||||
ISubmissionService studentSubmissionService,
|
||||
UserManager<User> userManager)
|
||||
{
|
||||
_studentSubmissionService = studentSubmissionService;
|
||||
@@ -35,7 +34,7 @@ namespace TechHelper.Server.Controllers
|
||||
if (user == null)
|
||||
return NotFound("未找到用户信息");
|
||||
|
||||
var result = await _studentSubmissionService.GetStudentSubmissionsAsync(user.Id);
|
||||
var result = await _studentSubmissionService.GetStudentSubmissionDetailAsync(user.Id);
|
||||
|
||||
if (result.Status)
|
||||
{
|
||||
@@ -64,7 +63,7 @@ namespace TechHelper.Server.Controllers
|
||||
if (user == null)
|
||||
return NotFound("未找到用户信息");
|
||||
|
||||
var result = await _studentSubmissionService.GetStudentSubmissionsPagedAsync(user.Id, pageNumber, pageSize);
|
||||
var result = await _studentSubmissionService.GetStudentSubmissionSummariesAsync(user.Id);
|
||||
|
||||
if (result.Status)
|
||||
{
|
||||
@@ -85,7 +84,7 @@ namespace TechHelper.Server.Controllers
|
||||
[Authorize(Roles = "Teacher")]
|
||||
public async Task<IActionResult> GetStudentSubmissions(Guid studentId)
|
||||
{
|
||||
var result = await _studentSubmissionService.GetStudentSubmissionsAsync(studentId);
|
||||
var result = await _studentSubmissionService.GetStudentSubmissionSummariesAsync(studentId);
|
||||
|
||||
if (result.Status)
|
||||
{
|
||||
@@ -112,7 +111,7 @@ namespace TechHelper.Server.Controllers
|
||||
if (pageSize < 1) pageSize = 10;
|
||||
if (pageSize > 100) pageSize = 100; // 限制最大页面大小
|
||||
|
||||
var result = await _studentSubmissionService.GetStudentSubmissionsPagedAsync(studentId, pageNumber, pageSize);
|
||||
var result = await _studentSubmissionService.GetStudentSubmissionSummariesAsync(studentId);
|
||||
|
||||
if (result.Status)
|
||||
{
|
||||
|
||||
@@ -3,11 +3,11 @@ using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TechHelper.Server.Services;
|
||||
using TechHelper.Context;
|
||||
using TechHelper.Repository;
|
||||
using SharedDATA.Api;
|
||||
using System.Security.Claims;
|
||||
using TechHelper.Services.Beta;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
@@ -16,12 +16,12 @@ namespace TechHelper.Server.Controllers
|
||||
[Authorize]
|
||||
public class StudentSubmissionDetailController : ControllerBase
|
||||
{
|
||||
private readonly IStudentSubmissionDetailService _studentSubmissionDetailService;
|
||||
private readonly ISubmissionDetailService _studentSubmissionDetailService;
|
||||
private readonly UserManager<User> _userManager;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public StudentSubmissionDetailController(
|
||||
IStudentSubmissionDetailService studentSubmissionDetailService,
|
||||
ISubmissionDetailService studentSubmissionDetailService,
|
||||
UserManager<User> userManager,
|
||||
IUnitOfWork unitOfWork)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ namespace TechHelper.Server.Controllers
|
||||
return Forbid("您没有权限查看此提交记录");
|
||||
}
|
||||
|
||||
var result = await _studentSubmissionDetailService.GetSubmissionDetailAsync(submissionId);
|
||||
var result = await _studentSubmissionDetailService.GetBySubmissionIdAsync(submissionId);
|
||||
|
||||
if (result.Status)
|
||||
{
|
||||
|
||||
145
TechHelper.Server/Controllers/SubjectController.cs
Normal file
145
TechHelper.Server/Controllers/SubjectController.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Security.Claims;
|
||||
using TechHelper.Services.Beta;
|
||||
using TechHelper.Services;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 科目管理控制器
|
||||
/// 处理科目相关的操作,如创建、更新、删除科目等
|
||||
/// </summary>
|
||||
[Route("api/subject")]
|
||||
[ApiController]
|
||||
public class SubjectController : ControllerBase
|
||||
{
|
||||
private readonly ISubjectService _subjectService;
|
||||
private readonly UserManager<User> _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化科目控制器
|
||||
/// </summary>
|
||||
/// <param name="subjectService">科目服务</param>
|
||||
/// <param name="userManager">用户管理服务</param>
|
||||
public SubjectController(ISubjectService subjectService, UserManager<User> userManager)
|
||||
{
|
||||
_subjectService = subjectService;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
#region 科目基本信息CRUD操作
|
||||
|
||||
/// <summary>
|
||||
/// 获取科目列表(支持搜索)
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <returns>科目列表</returns>
|
||||
/// <response code="200">成功获取科目列表</response>
|
||||
/// <response code="400">获取失败</response>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetAll([FromQuery] QueryParameter query)
|
||||
{
|
||||
var result = await _subjectService.GetAllAsync(query);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取科目详细信息
|
||||
/// </summary>
|
||||
/// <param name="id">科目ID</param>
|
||||
/// <returns>科目详细信息</returns>
|
||||
/// <response code="200">成功获取科目信息</response>
|
||||
/// <response code="400">科目未找到或获取失败</response>
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await _subjectService.GetAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建新科目
|
||||
/// </summary>
|
||||
/// <param name="model">科目数据传输对象</param>
|
||||
/// <returns>创建结果</returns>
|
||||
/// <response code="200">创建成功</response>
|
||||
/// <response code="400">创建失败</response>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = "Admin,Teacher")]
|
||||
public async Task<IActionResult> Create([FromBody] SubjectDto model)
|
||||
{
|
||||
var result = await _subjectService.AddAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新科目信息
|
||||
/// </summary>
|
||||
/// <param name="model">科目数据传输对象</param>
|
||||
/// <returns>更新结果</returns>
|
||||
/// <response code="200">更新成功</response>
|
||||
/// <response code="400">更新失败</response>
|
||||
[HttpPut]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Update([FromBody] SubjectDto model)
|
||||
{
|
||||
var result = await _subjectService.UpdateAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除科目
|
||||
/// </summary>
|
||||
/// <param name="id">科目ID</param>
|
||||
/// <returns>删除结果</returns>
|
||||
/// <response code="200">删除成功</response>
|
||||
/// <response code="400">删除失败</response>
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
{
|
||||
var result = await _subjectService.DeleteAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TechHelper.Server.Services;
|
||||
using TechHelper.Services;
|
||||
using TechHelper.Services.Beta;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
@@ -16,15 +16,16 @@ namespace TechHelper.Server.Controllers
|
||||
public class SubmissionController : ControllerBase
|
||||
{
|
||||
private readonly UserManager<User> _userManager;
|
||||
private readonly ISubmissionServices _submissionServices;
|
||||
private readonly ISubmissionService _submissionServices;
|
||||
|
||||
public SubmissionController(UserManager<User> userManager, ISubmissionServices submissionServices)
|
||||
public SubmissionController(UserManager<User> userManager, ISubmissionService submissionServices)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_submissionServices = submissionServices;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前用户的所有错题。
|
||||
/// </summary>
|
||||
@@ -35,7 +36,7 @@ namespace TechHelper.Server.Controllers
|
||||
var user = await _userManager.FindByEmailAsync(User.Identity.Name);
|
||||
if (user == null)
|
||||
{
|
||||
return NotFound("未找到当前用户信息。");
|
||||
return NotFound("未找到当前用户信息。");
|
||||
}
|
||||
|
||||
var result = await _submissionServices.GetAllErrorQuestionsAsync(user.Id);
|
||||
@@ -55,7 +56,7 @@ namespace TechHelper.Server.Controllers
|
||||
/// </summary>
|
||||
/// <param name="assignmentId">作业ID。</param>
|
||||
/// <returns>错题列表或错误信息。</returns>
|
||||
[HttpGet("getAssignmentErrorQuestions/{assignmentId:guid}")]
|
||||
[HttpGet("getAssignmentErrorQuestions/{assignmentId:guid}")]
|
||||
public async Task<IActionResult> GetAssignmentErrorQuestionsAsync(Guid assignmentId)
|
||||
{
|
||||
var user = await _userManager.FindByEmailAsync(User.Identity.Name);
|
||||
@@ -138,7 +139,7 @@ namespace TechHelper.Server.Controllers
|
||||
/// <param name="assignmentId">作业ID。</param>
|
||||
/// <returns>按题目分组的学生错题列表。</returns>
|
||||
[HttpGet("getQuestionErrorStudents/{assignmentId:guid}")]
|
||||
[Authorize(Roles = "Teacher")]
|
||||
[Authorize(Roles = "Teacher")]
|
||||
public async Task<IActionResult> GetQuestionErrorStudents(Guid assignmentId)
|
||||
{
|
||||
var result = await _submissionServices.GetQuestionErrorStudents(assignmentId);
|
||||
@@ -158,8 +159,8 @@ namespace TechHelper.Server.Controllers
|
||||
/// </summary>
|
||||
/// <param name="model">提交的数据模型。</param>
|
||||
/// <returns>新创建的提交记录或错误信息。</returns>
|
||||
[HttpPost("add")]
|
||||
public async Task<IActionResult> AddAsync([FromBody] Submission model)
|
||||
[HttpPost()]
|
||||
public async Task<IActionResult> AddAsync([FromBody] SubmissionDto model)
|
||||
{
|
||||
// 可以在这里获取当前用户ID并赋值给 model.StudentId,确保提交人信息正确
|
||||
// var user = await _userManager.FindByEmailAsync(User.Identity.Name);
|
||||
@@ -209,7 +210,7 @@ namespace TechHelper.Server.Controllers
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数,包含分页信息。</param>
|
||||
/// <returns>分页的提交记录列表。</returns>
|
||||
[HttpGet("getAll")]
|
||||
[HttpGet()]
|
||||
[Authorize(Roles = "Admin,Teacher")]
|
||||
public async Task<IActionResult> GetAllAsync([FromQuery] QueryParameter query)
|
||||
{
|
||||
@@ -252,7 +253,7 @@ namespace TechHelper.Server.Controllers
|
||||
/// <param name="model">要更新的提交数据。</param>
|
||||
/// <returns>更新后的提交记录或错误信息。</returns>
|
||||
[HttpPut("update/{id:guid}")]
|
||||
public async Task<IActionResult> UpdateAsync(Guid id, [FromBody] Submission model)
|
||||
public async Task<IActionResult> UpdateAsync(Guid id, [FromBody] SubmissionDto model)
|
||||
{
|
||||
if (id != model.Id) // 确保路径中的ID和模型中的ID一致
|
||||
{
|
||||
@@ -275,5 +276,90 @@ namespace TechHelper.Server.Controllers
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("GradeExam")]
|
||||
[Authorize(Roles = "Teacher")]
|
||||
public async Task<IActionResult> GradeExam([FromBody] SubmissionTeacherUpdateDto model)
|
||||
{
|
||||
var result = await _submissionServices.GradeExam(model);
|
||||
if (result.Status)
|
||||
{
|
||||
return Ok(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取学生提交摘要。
|
||||
/// </summary>
|
||||
/// <param name="userId">用户ID。</param>
|
||||
/// <returns>学生提交摘要列表或错误信息。</returns>
|
||||
[HttpGet("getStudentSubmissionSummaries")]
|
||||
[Authorize(Roles = "Student")]
|
||||
public async Task<IActionResult> GetStudentSubmissionSummariesAsync()
|
||||
{
|
||||
var user = await _userManager.FindByEmailAsync(User.Identity.Name);
|
||||
if (user == null)
|
||||
{
|
||||
return NotFound("未找到当前用户信息。");
|
||||
}
|
||||
|
||||
var userId = user.Id; // 假设当前用户是学生,获取其ID
|
||||
var result = await _submissionServices.GetStudentSubmissionSummariesAsync(userId);
|
||||
|
||||
if (result.Status)
|
||||
{
|
||||
return Ok(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取学生提交摘要。
|
||||
/// </summary>
|
||||
/// <param name="userId">用户ID。</param>
|
||||
/// <returns>学生提交摘要列表或错误信息。</returns>
|
||||
[HttpGet("getStudentSubmissionSummaries/{userId:guid}")]
|
||||
[Authorize(Roles = "Teacher")]
|
||||
public async Task<IActionResult> GetStudentSubmissionSummariesAsync(Guid userId)
|
||||
{
|
||||
var result = await _submissionServices.GetStudentSubmissionSummariesAsync(userId);
|
||||
|
||||
if (result.Status)
|
||||
{
|
||||
return Ok(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取学生提交详情。
|
||||
/// </summary>
|
||||
/// <param name="submissionId">提交ID。</param>
|
||||
/// <returns>学生提交详情或错误信息。</returns>
|
||||
[HttpGet("getStudentSubmissionDetail/{submissionId:guid}")]
|
||||
public async Task<IActionResult> GetStudentSubmissionDetailAsync(Guid submissionId)
|
||||
{
|
||||
var result = await _submissionServices.GetStudentSubmissionDetailAsync(submissionId);
|
||||
|
||||
if (result.Status)
|
||||
{
|
||||
return Ok(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
223
TechHelper.Server/Controllers/SubmissionDetailController.cs
Normal file
223
TechHelper.Server/Controllers/SubmissionDetailController.cs
Normal file
@@ -0,0 +1,223 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TechHelper.Services;
|
||||
using TechHelper.Services.Beta;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
[Route("api/submission-detail")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class SubmissionDetailController : ControllerBase
|
||||
{
|
||||
private readonly UserManager<User> _userManager;
|
||||
private readonly ISubmissionDetailService _submissionDetailService;
|
||||
|
||||
public SubmissionDetailController(UserManager<User> userManager, ISubmissionDetailService submissionDetailService)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_submissionDetailService = submissionDetailService;
|
||||
}
|
||||
|
||||
#region 基本CRUD操作
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有提交详情
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <returns>提交详情列表</returns>
|
||||
[HttpGet()]
|
||||
[Authorize(Roles = "Admin,Teacher")]
|
||||
public async Task<IActionResult> GetAllAsync([FromQuery] QueryParameter query)
|
||||
{
|
||||
var result = await _submissionDetailService.GetAllAsync(query);
|
||||
return result.Status ? Ok(result) : BadRequest(result.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取提交详情
|
||||
/// </summary>
|
||||
/// <param name="id">提交详情ID</param>
|
||||
/// <returns>提交详情详情</returns>
|
||||
[HttpGet("{id:guid}")]
|
||||
public async Task<IActionResult> GetAsync(Guid id)
|
||||
{
|
||||
var result = await _submissionDetailService.GetAsync(id);
|
||||
return result.Status ? Ok(result) : BadRequest(result.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建提交详情
|
||||
/// </summary>
|
||||
/// <param name="model">提交详情数据传输对象</param>
|
||||
/// <returns>创建结果</returns>
|
||||
[HttpPost()]
|
||||
public async Task<IActionResult> AddAsync([FromBody] SubmissionDetailDto model)
|
||||
{
|
||||
var result = await _submissionDetailService.AddAsync(model);
|
||||
return result.Status ? StatusCode(201, result) : BadRequest(result.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新提交详情
|
||||
/// </summary>
|
||||
/// <param name="id">提交详情ID</param>
|
||||
/// <param name="model">提交详情数据传输对象</param>
|
||||
/// <returns>更新结果</returns>
|
||||
[HttpPut("{id:guid}")]
|
||||
public async Task<IActionResult> UpdateAsync(Guid id, [FromBody] SubmissionDetailDto model)
|
||||
{
|
||||
if (id != model.Id)
|
||||
{
|
||||
return BadRequest("路由ID与请求体中的ID不匹配。");
|
||||
}
|
||||
|
||||
var result = await _submissionDetailService.UpdateAsync(model);
|
||||
return result.Status ? Ok(result) : BadRequest(result.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除提交详情
|
||||
/// </summary>
|
||||
/// <param name="id">提交详情ID</param>
|
||||
/// <returns>删除结果</returns>
|
||||
[HttpDelete("delete/{id:guid}")]
|
||||
public async Task<IActionResult> DeleteAsync(Guid id)
|
||||
{
|
||||
var result = await _submissionDetailService.DeleteAsync(id);
|
||||
return result.Status ? NoContent() : BadRequest(result.Message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 特殊操作
|
||||
|
||||
/// <summary>
|
||||
/// 根据提交ID获取提交详情列表
|
||||
/// </summary>
|
||||
/// <param name="submissionId">提交ID</param>
|
||||
/// <returns>提交详情列表</returns>
|
||||
[HttpGet("by-submission/{submissionId:guid}")]
|
||||
public async Task<IActionResult> GetBySubmissionIdAsync(Guid submissionId)
|
||||
{
|
||||
var result = await _submissionDetailService.GetBySubmissionIdAsync(submissionId);
|
||||
return result.Status ? Ok(result) : BadRequest(result.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据学生ID和考试ID获取提交详情
|
||||
/// </summary>
|
||||
/// <param name="studentId">学生ID</param>
|
||||
/// <param name="examId">考试ID</param>
|
||||
/// <returns>提交详情列表</returns>
|
||||
[HttpGet("by-student-exam")]
|
||||
public async Task<IActionResult> GetByStudentAndExamAsync([FromQuery] Guid studentId, [FromQuery] Guid examId)
|
||||
{
|
||||
var result = await _submissionDetailService.GetByStudentAndExamAsync(studentId, examId);
|
||||
return result.Status ? Ok(result) : BadRequest(result.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量创建提交详情
|
||||
/// </summary>
|
||||
/// <param name="submissionId">提交ID</param>
|
||||
/// <param name="details">提交详情列表</param>
|
||||
/// <returns>创建结果</returns>
|
||||
[HttpPost("batch-create/{submissionId:guid}")]
|
||||
public async Task<IActionResult> BatchCreateAsync(Guid submissionId, [FromBody] List<SubmissionDetailDto> details)
|
||||
{
|
||||
var result = await _submissionDetailService.BatchCreateAsync(submissionId, details);
|
||||
return result.Status ? StatusCode(201, result) : BadRequest(result.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量更新提交详情
|
||||
/// </summary>
|
||||
/// <param name="details">提交详情列表</param>
|
||||
/// <returns>更新结果</returns>
|
||||
[HttpPut("batch-update")]
|
||||
public async Task<IActionResult> BatchUpdateAsync([FromBody] List<SubmissionDetailDto> details)
|
||||
{
|
||||
var result = await _submissionDetailService.BatchUpdateAsync(details);
|
||||
return result.Status ? Ok(result) : BadRequest(result.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新提交详情评分
|
||||
/// </summary>
|
||||
/// <param name="detailId">提交详情ID</param>
|
||||
/// <param name="points">分数</param>
|
||||
/// <param name="feedback">反馈</param>
|
||||
/// <returns>更新结果</returns>
|
||||
[HttpPut("{detailId:guid}/score")]
|
||||
public async Task<IActionResult> UpdateScoreAsync(Guid detailId, [FromQuery] float? points, [FromQuery] string? feedback)
|
||||
{
|
||||
var result = await _submissionDetailService.UpdateScoreAsync(detailId, points, feedback);
|
||||
return result.Status ? Ok(result) : BadRequest(result.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取错题详情
|
||||
/// </summary>
|
||||
/// <param name="studentId">学生ID</param>
|
||||
/// <param name="examId">考试ID</param>
|
||||
/// <returns>错题详情列表</returns>
|
||||
[HttpGet("error-details")]
|
||||
[Authorize(Roles = "Student,Teacher")]
|
||||
public async Task<IActionResult> GetErrorDetailsAsync([FromQuery] Guid studentId, [FromQuery] Guid examId)
|
||||
{
|
||||
var result = await _submissionDetailService.GetErrorDetailsAsync(studentId, examId);
|
||||
return result.Status ? Ok(result) : BadRequest(result.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取正确题详情
|
||||
/// </summary>
|
||||
/// <param name="studentId">学生ID</param>
|
||||
/// <param name="examId">考试ID</param>
|
||||
/// <returns>正确题详情列表</returns>
|
||||
[HttpGet("correct-details")]
|
||||
[Authorize(Roles = "Student,Teacher")]
|
||||
public async Task<IActionResult> GetCorrectDetailsAsync([FromQuery] Guid studentId, [FromQuery] Guid examId)
|
||||
{
|
||||
var result = await _submissionDetailService.GetCorrectDetailsAsync(studentId, examId);
|
||||
return result.Status ? Ok(result) : BadRequest(result.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取未批改的提交详情
|
||||
/// </summary>
|
||||
/// <returns>未批改的提交详情列表</returns>
|
||||
[HttpGet("ungraded")]
|
||||
[Authorize(Roles = "Teacher")]
|
||||
public async Task<IActionResult> GetUngradedDetailsAsync()
|
||||
{
|
||||
var user = await _userManager.FindByEmailAsync(User.Identity.Name);
|
||||
if (user == null)
|
||||
{
|
||||
return NotFound("未找到当前用户信息。");
|
||||
}
|
||||
|
||||
var result = await _submissionDetailService.GetUngradedDetailsAsync(user.Id);
|
||||
return result.Status ? Ok(result) : BadRequest(result.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量更新提交详情状态
|
||||
/// </summary>
|
||||
/// <param name="submissionId">提交ID</param>
|
||||
/// <param name="status">状态</param>
|
||||
/// <returns>更新结果</returns>
|
||||
[HttpPut("{submissionId:guid}/status")]
|
||||
public async Task<IActionResult> UpdateStatusAsync(Guid submissionId, [FromQuery] SubmissionStatus status)
|
||||
{
|
||||
var result = await _submissionDetailService.UpdateStatusAsync(submissionId, status);
|
||||
return result.Status ? Ok(result) : BadRequest(result.Message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
209
TechHelper.Server/Controllers/TextbookController.cs
Normal file
209
TechHelper.Server/Controllers/TextbookController.cs
Normal file
@@ -0,0 +1,209 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TechHelper.Services;
|
||||
using TechHelper.Services.Beta;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 教材管理控制器
|
||||
/// 处理教材相关的操作,如创建、更新、删除教材等
|
||||
/// </summary>
|
||||
[Route("api/textbook")]
|
||||
[ApiController]
|
||||
public class TextbookController : ControllerBase
|
||||
{
|
||||
private readonly ITextbookService _textbookService;
|
||||
private readonly UserManager<User> _userManager;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化教材控制器
|
||||
/// </summary>
|
||||
/// <param name="textbookService">教材服务</param>
|
||||
/// <param name="userManager">用户管理服务</param>
|
||||
public TextbookController(ITextbookService textbookService, UserManager<User> userManager)
|
||||
{
|
||||
_textbookService = textbookService;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
#region 教材基本信息CRUD操作
|
||||
|
||||
/// <summary>
|
||||
/// 获取教材列表(支持搜索)
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <returns>教材列表</returns>
|
||||
/// <response code="200">成功获取教材列表</response>
|
||||
/// <response code="400">获取失败</response>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetAll([FromQuery] QueryParameter query)
|
||||
{
|
||||
var result = await _textbookService.GetAllAsync(query);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取教材详细信息
|
||||
/// </summary>
|
||||
/// <param name="id">教材ID</param>
|
||||
/// <returns>教材详细信息</returns>
|
||||
/// <response code="200">成功获取教材信息</response>
|
||||
/// <response code="400">教材未找到或获取失败</response>
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = "Teacher,Admin")]
|
||||
public async Task<IActionResult> GetById(Guid id)
|
||||
{
|
||||
var result = await _textbookService.GetAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建新教材
|
||||
/// </summary>
|
||||
/// <param name="model">教材数据传输对象</param>
|
||||
/// <returns>创建结果</returns>
|
||||
/// <response code="200">创建成功</response>
|
||||
/// <response code="400">创建失败</response>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = "Admin,Teacher")]
|
||||
public async Task<IActionResult> Create([FromBody] TextbookDto model)
|
||||
{
|
||||
var result = await _textbookService.AddAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新教材信息
|
||||
/// </summary>
|
||||
/// <param name="model">教材数据传输对象</param>
|
||||
/// <returns>更新结果</returns>
|
||||
/// <response code="200">更新成功</response>
|
||||
/// <response code="400">更新失败</response>
|
||||
[HttpPut]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Update([FromBody] TextbookDto model)
|
||||
{
|
||||
var result = await _textbookService.UpdateAsync(model);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除教材
|
||||
/// </summary>
|
||||
/// <param name="id">教材ID</param>
|
||||
/// <returns>删除结果</returns>
|
||||
/// <response code="200">删除成功</response>
|
||||
/// <response code="400">删除失败</response>
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public async Task<IActionResult> Delete(Guid id)
|
||||
{
|
||||
var result = await _textbookService.DeleteAsync(id);
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 教材扩展操作
|
||||
|
||||
/// <summary>
|
||||
/// 根据年级获取教材列表
|
||||
/// </summary>
|
||||
/// <param name="grade">年级</param>
|
||||
/// <returns>教材列表</returns>
|
||||
/// <response code="200">成功获取教材列表</response>
|
||||
/// <response code="400">获取失败</response>
|
||||
[HttpGet("grade/{grade}")]
|
||||
[Authorize(Roles = "Student,Teacher,Admin")]
|
||||
public async Task<IActionResult> GetByGrade(string grade)
|
||||
{
|
||||
var result = await _textbookService.GetAllAsync(new QueryParameter { Search = grade });
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据出版社获取教材列表
|
||||
/// </summary>
|
||||
/// <param name="publisher">出版社</param>
|
||||
/// <returns>教材列表</returns>
|
||||
/// <response code="200">成功获取教材列表</response>
|
||||
/// <response code="400">获取失败</response>
|
||||
[HttpGet("publisher/{publisher}")]
|
||||
[Authorize(Roles = "Student,Teacher,Admin")]
|
||||
public async Task<IActionResult> GetByPublisher(string publisher)
|
||||
{
|
||||
var result = await _textbookService.GetAllAsync(new QueryParameter { Search = publisher });
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据学科领域获取教材列表
|
||||
/// </summary>
|
||||
/// <param name="subjectArea">学科领域</param>
|
||||
/// <returns>教材列表</returns>
|
||||
/// <response code="200">成功获取教材列表</response>
|
||||
/// <response code="400">获取失败</response>
|
||||
[HttpGet("subjectArea/{subjectArea}")]
|
||||
[Authorize(Roles = "Student,Teacher,Admin")]
|
||||
public async Task<IActionResult> GetBySubjectArea(string subjectArea)
|
||||
{
|
||||
var result = await _textbookService.GetAllAsync(new QueryParameter { Search = subjectArea });
|
||||
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result.Message);
|
||||
}
|
||||
|
||||
return Ok(result.Result);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Entities.Contracts;
|
||||
using TechHelper.Services.Beta;
|
||||
|
||||
namespace TechHelper.Controllers
|
||||
{
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using TechHelper.Server.Services;
|
||||
using TechHelper.Services;
|
||||
using TechHelper.Services.Beta;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
[Route("api/user")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class UserController : ControllerBase
|
||||
{
|
||||
private IUserSerivces _userSerivces;
|
||||
private IClassService _classService;
|
||||
private UserManager<User> _userManager;
|
||||
private readonly IUserSerivces _userSerivces;
|
||||
private readonly IClassService _classService;
|
||||
private readonly UserManager<User> _userManager;
|
||||
|
||||
public UserController(IClassService classService, UserManager<User> userManager, IUserSerivces userSerivces)
|
||||
{
|
||||
_classService = classService;
|
||||
@@ -22,29 +25,186 @@ namespace TechHelper.Server.Controllers
|
||||
_userSerivces = userSerivces;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("get")]
|
||||
public async Task<IActionResult> GetAsync(
|
||||
[FromBody] UserRegistrationToClassDto toClass)
|
||||
/// <summary>
|
||||
/// 获取指定用户信息
|
||||
/// </summary>
|
||||
/// <param name="id">用户ID</param>
|
||||
/// <returns>用户信息</returns>
|
||||
[HttpGet("{id}")]
|
||||
public async Task<IActionResult> GetUserById(Guid id)
|
||||
{
|
||||
return Ok();
|
||||
var result = await _userSerivces.GetAsync(id);
|
||||
if (!result.Status)
|
||||
{
|
||||
return NotFound(result);
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有用户列表
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <returns>用户列表</returns>
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAllUsers([FromQuery] QueryParameter query)
|
||||
{
|
||||
var result = await _userSerivces.GetAllAsync(query);
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result);
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加新用户
|
||||
/// </summary>
|
||||
/// <param name="userDto">用户数据</param>
|
||||
/// <returns>操作结果</returns>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> AddUser([FromBody] UserDto userDto)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
var result = await _userSerivces.AddAsync(userDto);
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result);
|
||||
}
|
||||
return CreatedAtAction(nameof(GetUserById), new { id = userDto.Id }, result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新用户信息
|
||||
/// </summary>
|
||||
/// <param name="id">用户ID</param>
|
||||
/// <param name="userDto">用户数据</param>
|
||||
/// <returns>操作结果</returns>
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> UpdateUser(Guid id, [FromBody] UserDto userDto)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
if (id != userDto.Id)
|
||||
{
|
||||
return BadRequest("用户ID不匹配");
|
||||
}
|
||||
|
||||
var result = await _userSerivces.UpdateAsync(userDto);
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result);
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除用户
|
||||
/// </summary>
|
||||
/// <param name="id">用户ID</param>
|
||||
/// <returns>操作结果</returns>
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteUser(Guid id)
|
||||
{
|
||||
var result = await _userSerivces.DeleteAsync(id);
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result);
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取学生详细信息
|
||||
/// </summary>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <returns>学生详细信息</returns>
|
||||
[HttpGet("student/{userId}")]
|
||||
public async Task<IActionResult> GetStudentDetailInfo(Guid userId)
|
||||
{
|
||||
var result = await _userSerivces.GetStudentDetailInfo(userId);
|
||||
if (!result.Status)
|
||||
{
|
||||
return NotFound(result);
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证用户信息
|
||||
/// </summary>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <returns>验证结果</returns>
|
||||
[HttpPost("verify/{userId}")]
|
||||
public async Task<IActionResult> VerifyUserInformation(Guid userId)
|
||||
{
|
||||
var result = await _userSerivces.VerifyUserInformation(userId);
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result);
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复用户角色信息
|
||||
/// </summary>
|
||||
/// <returns>操作结果</returns>
|
||||
[HttpGet("restoreUserRole")]
|
||||
public async Task<IActionResult> RestoreUserRole()
|
||||
{
|
||||
var user = await _userManager.FindByEmailAsync(User.Identity.Name);
|
||||
|
||||
if (user == null) return NotFound();
|
||||
if (user == null) return NotFound("用户不存在");
|
||||
|
||||
if (User.IsInRole("Teacher") || User.IsInRole("Student"))
|
||||
return Ok();
|
||||
return Ok(new ApiResponse(true, "用户角色已正确设置"));
|
||||
|
||||
var result = await _userSerivces.RestoreUserRoleInformation(user);
|
||||
if (result.Status)
|
||||
return Ok();
|
||||
return Ok(result);
|
||||
else
|
||||
return Unauthorized();
|
||||
return Unauthorized(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册新用户
|
||||
/// </summary>
|
||||
/// <param name="registrationDto">注册数据</param>
|
||||
/// <returns>注册结果</returns>
|
||||
[HttpPost("register")]
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> RegisterNewUser([FromBody] UserForRegistrationDto registrationDto)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
var result = await _userSerivces.RegisterNewUserAsync(registrationDto);
|
||||
if (!result.Status)
|
||||
{
|
||||
return BadRequest(result);
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定用户信息(旧接口)
|
||||
/// </summary>
|
||||
/// <param name="toClass">班级注册数据</param>
|
||||
/// <returns>操作结果</returns>
|
||||
[HttpPost("get")]
|
||||
[Obsolete("请使用 GET /api/user/{id} 接口")]
|
||||
public async Task<IActionResult> GetAsync([FromBody] UserRegistrationToClassDto toClass)
|
||||
{
|
||||
return Ok(new ApiResponse(false, "此接口已弃用,请使用新的接口"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace TechHelper.Server.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user