AdminGroupCategoryController.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 AdminGroupCategoryController : Controller
  16. {
  17. private readonly IGroupCategoryRepository groupCategoryRepository;
  18. public AdminGroupCategoryController(IGroupCategoryRepository GroupCategoryRepository)
  19. {
  20. this.groupCategoryRepository = GroupCategoryRepository;
  21. }
  22. /// <summary>
  23. /// 添加小组广场
  24. /// </summary>
  25. /// <param name="GroupCategory"></param>
  26. /// <returns></returns>
  27. [HttpPost("add")]
  28. public async Task<bool> InsertAsync(Entity.tede2.Group.GroupCategory GroupCategory)
  29. {
  30. return await groupCategoryRepository.InsertAsync(GroupCategory) > 0;
  31. }
  32. /// <summary>
  33. /// 修改
  34. /// </summary>
  35. /// <param name="GroupCategory"></param>
  36. /// <returns></returns>
  37. [HttpPut]
  38. public async Task<bool> UpdateAsync(Entity.tede2.Group.GroupCategory GroupCategory)
  39. {
  40. return await groupCategoryRepository.UpdateAsync(GroupCategory);
  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.GroupCategory> GetAsync(int id)
  49. {
  50. return await groupCategoryRepository.GetAsync(id);
  51. }
  52. /// <summary>
  53. /// 删除
  54. /// </summary>
  55. /// <param name="id"></param>
  56. /// <returns></returns>
  57. [HttpDelete("{id}")]
  58. public async Task<bool> DeleteAsync(int id)
  59. {
  60. return await groupCategoryRepository.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 groupCategoryRepository.GetAllAsync(parentId);
  71. }
  72. }
  73. }