AdminGroupCategroyController.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using GxPress.Repository.Interface.Group;
  4. using GxPress.Result.Web;
  5. using Microsoft.AspNetCore.Authorization;
  6. using Microsoft.AspNetCore.Mvc;
  7. namespace GxPress.Api.AdminControllers
  8. {
  9. /// <summary>
  10. /// 小组广场
  11. /// </summary>
  12. [Route("api/admin/group-categroy")]
  13. [ApiController]
  14. [Authorize]
  15. public class AdminGroupCategroyController : Controller
  16. {
  17. private readonly IGroupCategroyRepository groupCategroyRepository;
  18. public AdminGroupCategroyController(IGroupCategroyRepository groupCategroyRepository)
  19. {
  20. this.groupCategroyRepository = groupCategroyRepository;
  21. }
  22. /// <summary>
  23. /// 添加小组广场
  24. /// </summary>
  25. /// <param name="groupCategroy"></param>
  26. /// <returns></returns>
  27. [HttpPost("add")]
  28. public async Task<bool> InsertAsync(Entity.tede2.Group.GroupCategroy groupCategroy)
  29. {
  30. return await groupCategroyRepository.InsertAsync(groupCategroy) > 0;
  31. }
  32. /// <summary>
  33. /// 修改
  34. /// </summary>
  35. /// <param name="groupCategroy"></param>
  36. /// <returns></returns>
  37. [HttpPut]
  38. public async Task<bool> UpdateAsync(Entity.tede2.Group.GroupCategroy groupCategroy)
  39. {
  40. return await groupCategroyRepository.UpdateAsync(groupCategroy);
  41. }
  42. /// <summary>
  43. /// 根据ID查询详情
  44. /// </summary>
  45. /// <param name="id"></param>
  46. /// <returns></returns>
  47. [HttpGet("{id}")]
  48. public async Task<Entity.tede2.Group.GroupCategroy> GetAsync(int id)
  49. {
  50. return await groupCategroyRepository.GetAsync(id);
  51. }
  52. /// <summary>
  53. /// 删除
  54. /// </summary>
  55. /// <param name="id"></param>
  56. /// <returns></returns>
  57. [HttpDelete]
  58. public async Task<bool> DeleteAsync(int id)
  59. {
  60. return await groupCategroyRepository.DeleteAsync(id);
  61. }
  62. /// <summary>
  63. /// 根据parendId获取
  64. /// </summary>
  65. /// <param name="parentId"></param>
  66. /// <returns></returns>
  67. [HttpGet("list/{parentId}")]
  68. public async Task<IEnumerable<GroupCategoryResult>> GetAllAsync(int parentId)
  69. {
  70. return await groupCategroyRepository.GetAllAsync(parentId);
  71. }
  72. }
  73. }