306 lines
10 KiB
C#
306 lines
10 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using VOL.Business.IServices;
|
|
using VOL.Business.IServices.School;
|
|
using VOL.Business.Services.School;
|
|
using VOL.Core.Enums;
|
|
using VOL.Core.Extensions;
|
|
using VOL.Core.Filters;
|
|
using VOL.Core.ManageUser;
|
|
using VOL.Core.Services;
|
|
using VOL.Core.Utilities;
|
|
using VOL.Model;
|
|
using VOL.Model.School.Request;
|
|
using VOL.Model.School.Response;
|
|
|
|
namespace VOL.WebApi.Controllers.Business
|
|
{
|
|
/// <summary>
|
|
/// 学生管理
|
|
/// </summary>
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
[ApiExplorerSettings(GroupName = "v3")]
|
|
[TypeFilter(typeof(CustomApiResponseFilter))]
|
|
public class StudentController : ControllerBase
|
|
{
|
|
#region 初始化
|
|
|
|
private readonly IS_StudentService _studentService;
|
|
private readonly IFaceDetectService _faceDetectService;
|
|
|
|
public StudentController(
|
|
IS_StudentService studentService, IFaceDetectService faceDetectService)
|
|
{
|
|
_studentService = studentService;
|
|
_faceDetectService = faceDetectService;
|
|
}
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 分页获学生列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(GetStudentPageList))]
|
|
public async Task<PageDataDto<StudentPageListModel>> GetStudentPageList(StudentPageListParam paramDto)
|
|
{
|
|
return await _studentService.GetStudentPageList(paramDto);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取全部学生
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(GetStudentList))]
|
|
public async Task<List<StudentPageListModel>> GetStudentList(StudentExportParam paramDto)
|
|
{
|
|
return await _studentService.GetStudentListBySportsHall(paramDto);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
|
|
[HttpPost(nameof(AddStudent))]
|
|
public async Task<ActionResult> AddStudent([FromBody] AddStudentParam paramDto)
|
|
{
|
|
await _studentService.AddStudent(paramDto);
|
|
return Ok("新增成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(ModifyStudent))]
|
|
public async Task<ActionResult> ModifyStudent([FromBody] AddStudentParam paramDto)
|
|
{
|
|
await _studentService.ModifyStudent(paramDto);
|
|
return Ok("更新成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新学生状态
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(UpdateStudentStatus))]
|
|
public async Task<ActionResult> UpdateStudentStatus([FromBody] UpdateStudentStatusParam paramDto)
|
|
{
|
|
await _studentService.UpdateStudentStatus(paramDto);
|
|
return Ok("更新成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新学生小程序密码
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(UpdateStudentPwd))]
|
|
public async Task<ActionResult> UpdateStudentPwd([FromBody] UpdateStudentPwdParam paramDto)
|
|
{
|
|
await _studentService.UpdateStudentPwd(paramDto);
|
|
|
|
return Ok("更新成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 转班
|
|
/// </summary>
|
|
/// <param name="studentNo"></param>
|
|
/// <param name="classId"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(ChangeClasses))]
|
|
public async Task<ActionResult> ChangeClasses(string studentNo, int classId)
|
|
{
|
|
await _studentService.ChangeClasses(studentNo, classId);
|
|
return Ok("更新成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取导入学生模板
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(GetImportStudentsTemplate))]
|
|
public ActionResult GetImportStudentsTemplate()
|
|
{
|
|
var disList = new Dictionary<string, List<ImportStudentParam>>
|
|
{
|
|
{ "导入学生模板", new List<ImportStudentParam>() }
|
|
};
|
|
|
|
var exportColumns = Tool.GetPropertyNames<ImportStudentParam>();
|
|
|
|
var excelBytes = Tool.ExportToExcel(disList, exportColumns);
|
|
Response.Headers.Add("Content-Disposition", "attachment; filename=ExportedData.xlsx");
|
|
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
return File(excelBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "导入学生模板");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导入学生
|
|
/// </summary>
|
|
/// <param name="file"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="Exception"></exception>
|
|
[HttpPost(nameof(ImportStudents))]
|
|
public async Task<ActionResult> ImportStudents(IFormFile file)
|
|
{
|
|
await _studentService.ImportStudents(file);
|
|
return Ok("导入成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 上传学生头像
|
|
/// </summary>
|
|
/// <param name="file"></param>
|
|
/// <param name="gradeId">年级Id</param>
|
|
/// <param name="classId">班级Id</param>
|
|
/// <param name="studentNo">学生学号</param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(UploadPhoto))]
|
|
|
|
public async Task<string> UploadPhoto(IFormFile file, int gradeId, int classId, string studentNo, string studentName)
|
|
{
|
|
var url = await _studentService.UploadPhoto(file, gradeId, classId, studentNo, studentName);
|
|
|
|
return url;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 批量上传学生头像
|
|
/// </summary>
|
|
/// <param name="files"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(BatchUploadPhoto))]
|
|
public async Task<ActionResult> BatchUploadPhoto(IFormFile zipFile)
|
|
{
|
|
await _studentService.BatchUploadPhoto(zipFile);
|
|
return Ok("导入成功");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导出学生列表
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(StudentExport))]
|
|
public async Task<ActionResult> StudentExport(StudentExportParam paramDto)
|
|
{
|
|
var rseList = await _studentService.GetStudentList(paramDto);
|
|
|
|
var disList = new Dictionary<string, List<StudentPageListModel>>
|
|
{
|
|
{ "学生数据", rseList }
|
|
};
|
|
|
|
var exportColumns = Tool.GetPropertyNames<StudentPageListModel>();
|
|
|
|
var excelBytes = Tool.ExportToExcel(disList, exportColumns);
|
|
|
|
Response.Headers.Add("Content-Disposition", "attachment; filename=ExportedData.xlsx");
|
|
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
return File(excelBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $"学生数据{DateTime.Now.ToString("yyyyMMddHHmmss")}");
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 学生整体数据统计
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(StudentWholeDataStats))]
|
|
public async Task<StudentDataStatsModel> StudentWholeDataStats(StudentDataStatsParam paramDto)
|
|
{
|
|
return await _studentService.StudentWholeDataStats(paramDto);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 各项目平均成绩
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(TestResultAvg))]
|
|
public async Task<Dictionary<string, float>> TestResultAvg(StudentCategoryParam paramDto)
|
|
{
|
|
return await _studentService.TestResultAvg(paramDto);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 个人成绩对比
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(TestResultContrast))]
|
|
public async Task<Dictionary<string, float>> TestResultContrast(StudentCategoryParam paramDto)
|
|
{
|
|
return await _studentService.TestResultContrast(paramDto);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 成绩趋势
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(ResultTrends))]
|
|
public async Task<VariousSportsProportion> ResultTrends(StudentResultTrendsParam paramDto)
|
|
{
|
|
return await _studentService.ResultTrends(paramDto);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 训练记录
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(TrainingRecords))]
|
|
public async Task<PageDataDto<StudentTrainingRecordsModel>> TrainingRecords(StudentTrainingRecordsParam paramDto)
|
|
{
|
|
return await _studentService.TrainingRecords(paramDto);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 体测数据
|
|
/// </summary>
|
|
/// <param name="paramDto"></param>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(TestRecords))]
|
|
public async Task<PageDataDto<StudentTestRecordsModel>> TestRecords(StudentTrainingRecordsParam paramDto)
|
|
{
|
|
return await _studentService.TestRecords(paramDto);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取学生名单
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(GetStudentNamePageList))]
|
|
public async Task<List<StudentNamePageListModel>> GetStudentNamePageList(StudentNamePageListParam paramDto)
|
|
{
|
|
return await _studentService.GetStudentNamePageList(paramDto);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更换班级
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(ReplaceClasses))]
|
|
public async Task<ActionResult> ReplaceClasses(List<string> studentNoList, int classId)
|
|
{
|
|
await _studentService.ReplaceClasses(studentNoList, classId);
|
|
return Ok("修改成功");
|
|
}
|
|
}
|
|
}
|