using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using GxPress.Repository.Interface.Teacher; using System.Threading.Tasks; using System.Collections.Generic; using GxPress.Common.Page; using GxPress.Request.TeacherRequest; using GxPress.Auth; using GxPress.Service.Interface.Teacher; namespace GxPress.Api.AdminControllers { /// /// 名师 /// [Route("/api/admin/teacher")] [ApiController] [Authorize] public class AdminTeacherController : Controller { private readonly ITeacherRepository teacherRepository; private readonly ITeacherService service; private readonly ILoginContext _loginContext; public AdminTeacherController(ITeacherRepository teacherRepository, ILoginContext _loginContext, ITeacherService service) { this.teacherRepository = teacherRepository; this._loginContext = _loginContext; this.service = service; } /// /// 删除 /// /// /// [HttpDelete("{id}")] public async Task DeleteAsync(int id) { return await teacherRepository.DeleteAsync(id); } /// /// 获取所有名师 /// /// [HttpPost("list")] public async Task> GetAllAsync(TeacherRequest request) { return await teacherRepository.GetAllAsync(request); } /// /// 搜索名师 /// /// [HttpPost("search")] public async Task> GetSearchAllAsync(TeacherRequest request) { return await teacherRepository.GetSearchAllAsync(request); } /// /// 获取名师详情 /// /// /// [HttpGet("{id}")] public async Task GetAsync(int id) { return await teacherRepository.GetAsync(id); } /// /// 添加 /// /// /// [HttpPost] public async Task InsertAsync(Entity.tede2.Teacher.Teacher note) { note.AdminId = _loginContext.AccountId; note.Creator = _loginContext.Name; return await service.InsertAsync(note); } /// /// 修改 /// /// /// [HttpPut] public async Task UpdateAsync(Entity.tede2.Teacher.Teacher note) { note.AdminId = _loginContext.AccountId; note.Creator = _loginContext.Name; return await service.UpdateAsync(note); } } }