教练提交学生体质数据前校验任教班级关系,调用评估服务生成报告并复用现有报告持久化逻辑。 新增当前登录学员或家长的最新报告查询接口,按令牌中的学校与学号限定查询范围;补充请求 DTO 与服务接口。 验证:dotnet build WeChatApplet/YD_WeChatApplet.Api.csproj --no-restore --nologo -clp:ErrorsOnly(0 错误)。
211 lines
7.6 KiB
C#
211 lines
7.6 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Newtonsoft.Json;
|
|
using System.Text;
|
|
using System.ComponentModel.Design;
|
|
using YD_WeChatApplet.Api.Dto.Teacher;
|
|
using YD_WeChatApplet.Api.Services.Impl;
|
|
using YD_WeChatApplet.Commons.Dto;
|
|
using YD_WeChatApplet.Commons.Dto.ClassRoomRecord;
|
|
using YD_WeChatApplet.Commons.Dto.HomeWork;
|
|
using YD_WeChatApplet.Commons.Dto.Patriarch;
|
|
using YD_WeChatApplet.Commons.Dto.Resource;
|
|
using YD_WeChatApplet.Commons.Dto.Teacher;
|
|
using YD_WeChatApplet.Services;
|
|
|
|
namespace YD_WeChatApplet.Api.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 老师端
|
|
/// </summary>
|
|
[ApiController]
|
|
[ApiExplorerSettings(GroupName = "v1")]
|
|
[Route("[controller]")]
|
|
public class TeacherController : ControllerBase
|
|
{
|
|
private readonly ITeacherService _teacherService;
|
|
private readonly IHttpClientFactory _httpClientFactory;
|
|
private readonly IConfiguration _configuration;
|
|
public TeacherController(ITeacherService teacherService, IHttpClientFactory httpClientFactory, IConfiguration configuration)
|
|
{
|
|
_teacherService = teacherService;
|
|
_httpClientFactory = httpClientFactory;
|
|
_configuration = configuration;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 老师个人信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("TeacherProfile")]
|
|
public async Task<TeacherProfileDto> TeacherProfile()
|
|
{
|
|
var res = await _teacherService.TeacherProfile();
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改个人信息
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("ModifyTeacherProfile")]
|
|
public async Task<IActionResult> ModifyTeacherProfile([FromBody] TeacherProfileDto paramDto)
|
|
{
|
|
await _teacherService.ModifyTeacherProfile(paramDto);
|
|
return Ok("修改成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改密码
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("ModifyTeacherPwd")]
|
|
public async Task<IActionResult> ModifyTeacherPwd([FromBody] ModifyTeacherPwdDto paramDto)
|
|
{
|
|
await _teacherService.ModifyTeacherPwd(paramDto);
|
|
return Ok("修改成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 项目列表
|
|
/// </summary>
|
|
/// <param name="gradeId"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("CategoryList")]
|
|
public async Task<List<ComboBoxDto>> CategoryList(int gradeId)
|
|
{
|
|
var res = await _teacherService.CategoryList(gradeId);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 数据统计接口
|
|
/// </summary>
|
|
/// <param name="dto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("DataStatistics")]
|
|
public async Task<DataStatisticsDto> DataStatistics([FromQuery] DataStatisticsFilterDto dto)
|
|
{
|
|
var res = await _teacherService.DataStatistics(dto);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 统计接口详情
|
|
/// </summary>
|
|
/// <param name="dto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("DataStatisticsDetails")]
|
|
public async Task<DataStatisticsDetailsDto> DataStatisticsDetails([FromQuery] DataStatisticsDetailsFilterDto dto)
|
|
{
|
|
var res = await _teacherService.DataStatisticsDetails(dto);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 课堂记录
|
|
/// </summary>
|
|
/// <param name="dto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("ClassRoomRecord")]
|
|
public async Task<PageDataDto<ClassRoomRecordPageDto>> ClassRoomRecord([FromQuery] ClassRoomRecordDto dto)
|
|
{
|
|
var res = await _teacherService.ClassRoomRecord(dto);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 课堂详情
|
|
/// </summary>
|
|
/// <param name="classRoomId"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("ClassRoomReportDetails")]
|
|
public async Task<ClassReportDetailsDto> ClassRoomReportDetails(int classRoomId)
|
|
{
|
|
var res = await _teacherService.ClassRoomReportDetails(classRoomId);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 学员课堂报告
|
|
/// </summary>
|
|
/// <param name="dto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("StudentClassRoomReport")]
|
|
public async Task<StudentClassRoomReportDto> StudentClassRoomReport([FromQuery] StudentClassRoomReportRequestDto dto)
|
|
{
|
|
var res = await _teacherService.StudentClassRoomReport(dto);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 班级报告
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("ClassReport")]
|
|
public async Task<ClassReportDto> ClassReport(int classId)
|
|
{
|
|
var res = await _teacherService.ClassReport(classId);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 生成并保存学生体质报告
|
|
/// </summary>
|
|
[HttpPost("GeneratePostureReport")]
|
|
public async Task<PostureReportContentDto> GeneratePostureReport([FromBody] GeneratePostureReportDto dto)
|
|
{
|
|
if (dto?.Input == null || string.IsNullOrWhiteSpace(dto.StudentNo))
|
|
throw new Exception("学生和体质信息不能为空");
|
|
|
|
var studentNo = dto.StudentNo.Trim();
|
|
await _teacherService.VerifyPostureStudent(studentNo);
|
|
dto.Input.StudentId = studentNo;
|
|
var evaluateUrl = _configuration["PostureEvaluateUrl"] ?? "http://8.153.108.90:10001/api/evaluate";
|
|
using var client = _httpClientFactory.CreateClient();
|
|
client.Timeout = TimeSpan.FromSeconds(30);
|
|
using var body = new StringContent(JsonConvert.SerializeObject(dto.Input), Encoding.UTF8, "application/json");
|
|
using var response = await client.PostAsync(evaluateUrl, body);
|
|
if (!response.IsSuccessStatusCode)
|
|
throw new Exception("体质评价服务暂不可用");
|
|
|
|
var responseText = await response.Content.ReadAsStringAsync();
|
|
var report = JsonConvert.DeserializeObject<PostureReportContentDto>(responseText);
|
|
if (report?.Success != true || report.Result == null)
|
|
throw new Exception("体质评价服务未返回有效报告");
|
|
|
|
await _teacherService.AddPostureReport(new AddPostureReportDto
|
|
{
|
|
StudentNo = studentNo,
|
|
ReportContent = report
|
|
});
|
|
return report;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增学生体态报告
|
|
/// </summary>
|
|
/// <param name="dto">学生学号及 fitcamp365 评价接口的完整成功响应</param>
|
|
/// <returns></returns>
|
|
[HttpPost("AddPostureReport")]
|
|
public async Task<IActionResult> AddPostureReport([FromBody] AddPostureReportDto dto)
|
|
{
|
|
var reportId = await _teacherService.AddPostureReport(dto);
|
|
return Ok(new { ReportId = reportId });
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据学生学号获取最新体态报告内容
|
|
/// </summary>
|
|
/// <param name="studentNo">学生学号</param>
|
|
/// <returns>报告内容对象</returns>
|
|
[HttpGet("GetPostureReport")]
|
|
public async Task<PostureReportContentDto> GetPostureReport([FromQuery] string studentNo)
|
|
{
|
|
return await _teacherService.GetPostureReport(studentNo);
|
|
}
|
|
}
|
|
}
|