AdminTeacherController.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using Microsoft.AspNetCore.Authorization;
  2. using Microsoft.AspNetCore.Mvc;
  3. using GxPress.Repository.Interface.Teacher;
  4. using System.Threading.Tasks;
  5. using System.Collections.Generic;
  6. using GxPress.Common.Page;
  7. using GxPress.Request.TeacherRequest;
  8. namespace GxPress.Api.AdminControllers
  9. {
  10. /// <summary>
  11. /// 名师
  12. /// </summary>
  13. [Route("/api/admin/teacher")]
  14. [ApiController]
  15. [Authorize]
  16. public class AdminTeacherController : Controller
  17. {
  18. private readonly ITeacherRepository teacherRepository;
  19. public AdminTeacherController(ITeacherRepository teacherRepository)
  20. {
  21. this.teacherRepository = teacherRepository;
  22. }
  23. /// <summary>
  24. /// 删除
  25. /// </summary>
  26. /// <param name="id"></param>
  27. /// <returns></returns>
  28. [HttpDelete("{id}")]
  29. public async Task<bool> DeleteAsync(int id)
  30. {
  31. return await teacherRepository.DeleteAsync(id);
  32. }
  33. /// <summary>
  34. /// 获取所有名师
  35. /// </summary>
  36. /// <returns></returns>
  37. [HttpPost("list")]
  38. public async Task<PagedList<Entity.tede2.Teacher.Teacher>> GetAllAsync(TeacherRequest request)
  39. {
  40. return await teacherRepository.GetAllAsync(request);
  41. }
  42. /// <summary>
  43. /// 搜索名师
  44. /// </summary>
  45. /// <returns></returns>
  46. [HttpPost("search")]
  47. public async Task<IEnumerable<Entity.tede2.Teacher.Teacher>> GetSearchAllAsync(TeacherRequest request)
  48. {
  49. return await teacherRepository.GetSearchAllAsync(request);
  50. }
  51. /// <summary>
  52. /// 获取名师详情
  53. /// </summary>
  54. /// <param name="id"></param>
  55. /// <returns></returns>
  56. [HttpGet("{id}")]
  57. public async Task<Entity.tede2.Teacher.Teacher> GetAsync(int id)
  58. {
  59. return await teacherRepository.GetAsync(id);
  60. }
  61. /// <summary>
  62. /// 添加
  63. /// </summary>
  64. /// <param name="note"></param>
  65. /// <returns></returns>
  66. [HttpPost]
  67. public async Task<int> InsertAsync(Entity.tede2.Teacher.Teacher note)
  68. {
  69. return await teacherRepository.InsertAsync(note);
  70. }
  71. /// <summary>
  72. /// 修改
  73. /// </summary>
  74. /// <param name="note"></param>
  75. /// <returns></returns>
  76. [HttpPut]
  77. public async Task<bool> UpdateAsync(Entity.tede2.Teacher.Teacher note)
  78. {
  79. return await teacherRepository.UpdateAsync(note);
  80. }
  81. }
  82. }