202 lines
6.7 KiB
C#
202 lines
6.7 KiB
C#
![]() |
using Microsoft.AspNetCore.Http;
|
|||
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using VOL.Business.IServices;
|
|||
|
using VOL.Business.IServices.School;
|
|||
|
using VOL.Business.Services;
|
|||
|
using VOL.Business.Services.School;
|
|||
|
using VOL.Core.Filters;
|
|||
|
using VOL.Core.ManageUser;
|
|||
|
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 TeacherController : ControllerBase
|
|||
|
{
|
|||
|
#region 初始化
|
|||
|
|
|||
|
private readonly IS_TeacherService _teacherService;
|
|||
|
public TeacherController(
|
|||
|
IS_TeacherService teacherService)
|
|||
|
{
|
|||
|
_teacherService = teacherService;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取所有老师名称
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpGet(nameof(GetTeacherNames))]
|
|||
|
public async Task<List<TeacherNameModel>> GetTeacherNames()
|
|||
|
{
|
|||
|
return await _teacherService.GetTeacherNames();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据年级Id或班级Id获取老师
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpGet(nameof(GetTeacherNamesByGradeId))]
|
|||
|
public async Task<List<TeacherListByGradeIdModel>> GetTeacherNamesByGradeId(TeacherListByGradeIdParam paramDto)
|
|||
|
{
|
|||
|
return await _teacherService.GetTeacherNamesByGradeId(paramDto);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 分页获教师列表
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpGet(nameof(GetTeacherPageList))]
|
|||
|
public async Task<PageDataDto<TeacherPageListModel>> GetTeacherPageList(TeacherPageListParam paramDto)
|
|||
|
{
|
|||
|
return await _teacherService.GetTeacherPageList(paramDto);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 新增
|
|||
|
/// </summary>
|
|||
|
/// <param name="paramDto"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost(nameof(AddTeacher))]
|
|||
|
public async Task<ActionResult> AddTeacher([FromBody] AddTeacherParam paramDto)
|
|||
|
{
|
|||
|
await _teacherService.AddTeacher(paramDto);
|
|||
|
return Ok("新增成功");
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 修改密码
|
|||
|
/// </summary>
|
|||
|
/// <param name="paramDto"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost(nameof(ResetPassword))]
|
|||
|
public async Task<ActionResult> ResetPassword(int teacherId)
|
|||
|
{
|
|||
|
await _teacherService.ResetPassword(teacherId);
|
|||
|
return Ok("修改成功");
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 更新
|
|||
|
/// </summary>
|
|||
|
/// <param name="paramDto"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost(nameof(ModifyTeacher))]
|
|||
|
public async Task<ActionResult> ModifyTeacher([FromBody] AddTeacherParam paramDto)
|
|||
|
{
|
|||
|
await _teacherService.ModifyTeacher(paramDto);
|
|||
|
return Ok("更新成功");
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 更新老师状态
|
|||
|
/// </summary>
|
|||
|
/// <param name="paramDto"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost(nameof(UpdateTeacherStatus))]
|
|||
|
public async Task<ActionResult> UpdateTeacherStatus([FromBody] UpdateTeacherStatusParam paramDto)
|
|||
|
{
|
|||
|
await _teacherService.UpdateTeacherStatus(paramDto);
|
|||
|
return Ok("更新成功");
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 更新老师小程序密码
|
|||
|
/// </summary>
|
|||
|
/// <param name="paramDto"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost(nameof(UpdateTeacherPwd))]
|
|||
|
public async Task<ActionResult> UpdateTeacherPwd([FromBody] UpdateTeacherPwdParam paramDto)
|
|||
|
{
|
|||
|
await _teacherService.UpdateTeacherPwd(paramDto);
|
|||
|
return Ok("更新成功");
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 上传老师头像
|
|||
|
/// </summary>
|
|||
|
/// <param name="file"></param>
|
|||
|
/// <param name="teacherPhoneNo">老师手机号</param>
|
|||
|
/// <param name="teacherName">老师姓名</param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost(nameof(UploadTeacherPhoto))]
|
|||
|
public async Task<string> UploadTeacherPhoto(IFormFile file, string teacherPhoneNo, string teacherName)
|
|||
|
{
|
|||
|
var url = await _teacherService.UploadTeacherPhoto(file, teacherPhoneNo, teacherName);
|
|||
|
|
|||
|
return url;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 导出老师列表
|
|||
|
/// </summary>
|
|||
|
/// <param name="paramDto"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpGet(nameof(TeacherExport))]
|
|||
|
public async Task<ActionResult> TeacherExport(TeacherExportParam paramDto)
|
|||
|
{
|
|||
|
var rseList = await _teacherService.GetTeacherList(paramDto);
|
|||
|
|
|||
|
var disList = new Dictionary<string, List<TeacherPageListModel>>
|
|||
|
{
|
|||
|
{ "老师数据", rseList }
|
|||
|
};
|
|||
|
|
|||
|
var exportColumns = Tool.GetPropertyNames<TeacherPageListModel>();
|
|||
|
|
|||
|
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(TeacherDataStats))]
|
|||
|
public async Task<TeacherDataStatsModel> TeacherDataStats(TeacherDataStatsParam paramDto)
|
|||
|
{
|
|||
|
return await _teacherService.TeacherDataStats(paramDto);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 各班级授课次数占比
|
|||
|
/// </summary>
|
|||
|
/// <param name="paramDto"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpGet(nameof(ClassTeachingCountRatio))]
|
|||
|
public async Task<Dictionary<string, float>> ClassTeachingCountRatio(QuarterlyParam paramDto)
|
|||
|
{
|
|||
|
return await _teacherService.ClassTeachingCountRatio(paramDto);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 班级体测平均成绩
|
|||
|
/// </summary>
|
|||
|
/// <param name="paramDto"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpGet(nameof(TestResultAvg))]
|
|||
|
public async Task<Dictionary<string, float>> TestResultAvg(ClassDataStatsParam paramDto)
|
|||
|
{
|
|||
|
return await _teacherService.TestResultAvg(paramDto);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|