1
0

EmployeeController.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using ZhonTai.Common.Domain.Dto;
  2. using ZhonTai.Plate.Personnel.Service.Employee;
  3. using Microsoft.AspNetCore.Mvc;
  4. using System.Threading.Tasks;
  5. using ZhonTai.Plate.Personnel.Service.Employee.Input;
  6. using Microsoft.AspNetCore.Mvc.ModelBinding;
  7. namespace ZhonTai.Plate.Personnel.HttpApi.Controllers
  8. {
  9. /// <summary>
  10. /// 员工管理
  11. /// </summary>
  12. public class EmployeeController : AreaController
  13. {
  14. private readonly IEmployeeService _employeeService;
  15. public EmployeeController(IEmployeeService employeeService)
  16. {
  17. _employeeService = employeeService;
  18. }
  19. /// <summary>
  20. /// 查询单条员工
  21. /// </summary>
  22. /// <param name="id"></param>
  23. /// <returns></returns>
  24. [HttpGet]
  25. public async Task<IResultOutput> Get([BindRequired] long id)
  26. {
  27. return await _employeeService.GetAsync(id);
  28. }
  29. /// <summary>
  30. /// 查询分页员工
  31. /// </summary>
  32. /// <param name="input"></param>
  33. /// <returns></returns>
  34. [HttpPost]
  35. //[ResponseCache(Duration = 60)]
  36. public async Task<IResultOutput> GetPage(PageInput input)
  37. {
  38. return await _employeeService.GetPageAsync(input);
  39. }
  40. /// <summary>
  41. /// 新增员工
  42. /// </summary>
  43. /// <param name="input"></param>
  44. /// <returns></returns>
  45. [HttpPost]
  46. public async Task<IResultOutput> Add(EmployeeAddInput input)
  47. {
  48. return await _employeeService.AddAsync(input);
  49. }
  50. /// <summary>
  51. /// 修改员工
  52. /// </summary>
  53. /// <param name="input"></param>
  54. /// <returns></returns>
  55. [HttpPut]
  56. public async Task<IResultOutput> Update(EmployeeUpdateInput input)
  57. {
  58. return await _employeeService.UpdateAsync(input);
  59. }
  60. /// <summary>
  61. /// 删除员工
  62. /// </summary>
  63. /// <param name="id"></param>
  64. /// <returns></returns>
  65. [HttpDelete]
  66. public async Task<IResultOutput> SoftDelete(long id)
  67. {
  68. return await _employeeService.SoftDeleteAsync(id);
  69. }
  70. /// <summary>
  71. /// 批量删除员工
  72. /// </summary>
  73. /// <param name="ids"></param>
  74. /// <returns></returns>
  75. [HttpPut]
  76. public async Task<IResultOutput> BatchSoftDelete(long[] ids)
  77. {
  78. return await _employeeService.BatchSoftDeleteAsync(ids);
  79. }
  80. }
  81. }