ArticleGroupUserController.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using GxPress.Auth;
  4. using GxPress.Repository.Interface;
  5. using GxPress.Request.ArticleGroupUser;
  6. using GxPress.Result.ArticleGroupUser;
  7. using Microsoft.AspNetCore.Authorization;
  8. using Microsoft.AspNetCore.Mvc;
  9. namespace GxPress.Api.AppControllers
  10. {
  11. /// <summary>
  12. /// 我的频道
  13. /// </summary>
  14. [Route("api/app/article-group-user")]
  15. [ApiController]
  16. [Authorize]
  17. public class ArticleGroupUserController : ControllerBase
  18. {
  19. private readonly IArticleGroupUserRepository _articleGroupUserRepository;
  20. private readonly ILoginContext _loginContext;
  21. public ArticleGroupUserController(IArticleGroupUserRepository articleGroupUserRepository, ILoginContext loginContext)
  22. {
  23. _articleGroupUserRepository = articleGroupUserRepository;
  24. _loginContext = loginContext;
  25. }
  26. /// <summary>
  27. /// 删除
  28. /// </summary>
  29. /// <param name="id"></param>
  30. /// <returns></returns>
  31. [HttpDelete("{id}")]
  32. public async Task<bool> Delete(int id)
  33. {
  34. return await _articleGroupUserRepository.DeleteAsync(id);
  35. }
  36. /// <summary>
  37. /// 添加
  38. /// </summary>
  39. /// <param name="request"></param>
  40. /// <returns></returns>
  41. [HttpPost("add")]
  42. public async Task<bool> Add([FromBody] ArticleGroupUserInRequest request)
  43. {
  44. request.UserId = _loginContext.AccountId;
  45. return await _articleGroupUserRepository.InsertAsync(request) > 0;
  46. }
  47. /// <summary>
  48. /// 添加
  49. /// </summary>
  50. /// <param name="request"></param>
  51. /// <returns></returns>
  52. [HttpPost]
  53. public async Task<bool> InsertAsync(ArticleGroupUserInNewRequest request)
  54. {
  55. request.UserId = _loginContext.AccountId;
  56. return await _articleGroupUserRepository.InsertAsync(request);
  57. }
  58. /// <summary>
  59. /// 获取用户的频道
  60. /// </summary>
  61. /// <param name="request"></param>
  62. /// <returns></returns>
  63. [HttpPost("list")]
  64. public async Task<IEnumerable<ArticleGroupUserListResult>> GetArticleGroupUserListByUserId(
  65. [FromBody] ArticleGroupUserSearchRequest request)
  66. {
  67. request.UserId = _loginContext.AccountId;
  68. return await _articleGroupUserRepository.GetListAsync(request);
  69. }
  70. }
  71. }