RoleController.cs 2.4 KB

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