2026-01-16 11:26:08 +08:00

168 lines
5.5 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using VOL.Ai.IServices;
using VOL.Ai.Services;
using VOL.Business.IServices;
using VOL.Business.IServices.Training;
using VOL.Core.Filters;
using VOL.Core.Utilities;
using VOL.Entity.DomainModels;
using VOL.Entity.Enum;
using VOL.Model;
using VOL.Model.HomeWork;
using VOL.Model.Training.Response;
using VOL.System.IRepositories;
using VOL.System.Repositories;
namespace VOL.WebApi.Controllers.JingShiTiJiao
{
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "v3")]
[TypeFilter(typeof(CustomApiResponseFilter))]
[AllowAnonymous]
public class JingShiTiJiaoController : ControllerBase
{
#region 初始化
private readonly IS_HomeWorkService _homeWorkService;
private readonly IJingShiTiJiaoService _jingShiTiJiaoService;
private readonly II_TrainingDataService _trainingDataService;
private readonly S_StudentRepository _studentRepository;
public JingShiTiJiaoController(
IS_HomeWorkService homeWorkService, II_TrainingDataService trainingDataService,IJingShiTiJiaoService jingShiTiJiaoService, S_StudentRepository studentRepository)
{
_homeWorkService = homeWorkService;
_trainingDataService = trainingDataService;
_jingShiTiJiaoService = jingShiTiJiaoService;
_studentRepository = studentRepository;
}
#endregion
#region 作业
/// <summary>
/// 作业列表
/// </summary>
/// <returns></returns>
[HttpGet(nameof(GetHomeWorkPageList))]
public async Task<PageDataDto<HomeWorkListModel>> GetHomeWorkPageList(HomeWorkPageListParam paramDto)
{
return await _homeWorkService.GetHomeWorkPageList(paramDto);
}
/// <summary>
/// 作业下学生列表
/// </summary>
/// <returns></returns>
[HttpGet(nameof(GetHomeWorkStudents))]
public async Task<PageDataDto<HomeWorkStudentsModel>> GetHomeWorkStudents(HomeWorkStudentsParam paramDto)
{
return await _homeWorkService.GetHomeWorkStudents(paramDto);
}
/// <summary>
/// 作业详情
/// </summary>
/// <returns></returns>
[HttpGet(nameof(GetSubmittedAssignments))]
public async Task<List<SubmittedAssignmentsModel>> GetSubmittedAssignments(int homeWorkId, string studentNo)
{
return await _homeWorkService.GetSubmittedAssignments(homeWorkId, studentNo);
}
#endregion
#region 课堂报告
/// <summary>
/// 课堂报告列表
/// </summary>
/// <returns></returns>
[HttpGet(nameof(GetClassReportList))]
public async Task<PageDataDto<ClassReportModel>> GetClassReportList(ClassReportListParam paramDto)
{
return await _trainingDataService.GetClassReportList(paramDto);
}
/// <summary>
/// 课堂报告详情
/// </summary>
/// <returns></returns>
[HttpGet(nameof(GetClassReportDetails))]
public async Task<GetClassReportDetailsModel> GetClassReportDetails(int id)
{
return await _trainingDataService.GetClassReportDetails(id);
}
/// <summary>
/// 学生课堂报告详情
/// </summary>
/// <returns></returns>
[HttpGet(nameof(GetStudentClassReportDetails))]
public async Task<GetStudentClassReportDetailsModel> GetStudentClassReportDetails(GetStudentClassReportDetailsDto paramDto)
{
return await _trainingDataService.GetStudentClassReportDetails(paramDto);
}
#endregion
/// <summary>
/// 获取所有年级名称
/// </summary>
/// <returns></returns>
/// <summary>
/// 获取年级列表
/// </summary>
/// <returns></returns>
[HttpGet(nameof(GetGradeList))]
public async Task<List<GradeNameModel>> GetGradeList(string schoolCode)
{
if (string.IsNullOrWhiteSpace(schoolCode))
return new List<GradeNameModel>();
// 1️⃣ 从数据库读取年级
var grades = await _studentRepository.DbContext.Set<JS_Grade>()
.Where(x => x.SchoolCode == schoolCode)
.ToListAsync();
if (grades == null || !grades.Any())
return new List<GradeNameModel>();
// 2️⃣ 从数据库读取班级
var allGradeNos = grades.Select(x => x.GradeNo).ToList();
var classes = await _studentRepository.DbContext.Set<JS_Class>()
.Where(x => x.SchoolCode == schoolCode && allGradeNos.Contains(x.GradeNo))
.ToListAsync();
// 3️⃣ 按年级分组班级
var result = grades.Select(g => new GradeNameModel
{
Id = (int)g.Id,
GradeName = g.GradeName,
Class = classes
.Where(c => c.GradeNo == g.GradeNo)
.Select(c => new ClassNameModel
{
Id = (int)c.Id,
ClassName = c.ClassName
})
.ToList()
}).ToList();
return result;
}
}
}