1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- 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;
- namespace GxPress.Api.AdminControllers
- {
- /// <summary>
- /// 名师
- /// </summary>
- [Route("/api/admin/teacher")]
- [ApiController]
- [Authorize]
- public class AdminTeacherController : Controller
- {
- private readonly ITeacherRepository teacherRepository;
- public AdminTeacherController(ITeacherRepository teacherRepository)
- {
- this.teacherRepository = teacherRepository;
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("{id}")]
- public async Task<bool> DeleteAsync(int id)
- {
- return await teacherRepository.DeleteAsync(id);
- }
- /// <summary>
- /// 获取所有名师
- /// </summary>
- /// <returns></returns>
- [HttpPost("list")]
- public async Task<PagedList<Entity.tede2.Teacher.Teacher>> GetAllAsync(TeacherRequest request)
- {
- return await teacherRepository.GetAllAsync(request);
- }
- /// <summary>
- /// 搜索名师
- /// </summary>
- /// <returns></returns>
- [HttpPost("search")]
- public async Task<IEnumerable<Entity.tede2.Teacher.Teacher>> GetSearchAllAsync(TeacherRequest request)
- {
- return await teacherRepository.GetSearchAllAsync(request);
- }
- /// <summary>
- /// 获取名师详情
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("{id}")]
- public async Task<Entity.tede2.Teacher.Teacher> GetAsync(int id)
- {
- return await teacherRepository.GetAsync(id);
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="note"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<int> InsertAsync(Entity.tede2.Teacher.Teacher note)
- {
- return await teacherRepository.InsertAsync(note);
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <param name="note"></param>
- /// <returns></returns>
- [HttpPut]
- public async Task<bool> UpdateAsync(Entity.tede2.Teacher.Teacher note)
- {
- return await teacherRepository.UpdateAsync(note);
- }
- }
- }
|