12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using GxPress.Auth;
- using GxPress.Repository.Interface;
- using GxPress.Request.ArticleGroupUser;
- using GxPress.Result.ArticleGroupUser;
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc;
- namespace GxPress.Api.AppControllers
- {
- /// <summary>
- /// 我的频道
- /// </summary>
- [Route("api/app/article-group-user")]
- [ApiController]
- [Authorize]
- public class ArticleGroupUserController : ControllerBase
- {
- private readonly IArticleGroupUserRepository _articleGroupUserRepository;
- private readonly ILoginContext _loginContext;
- public ArticleGroupUserController(IArticleGroupUserRepository articleGroupUserRepository, ILoginContext loginContext)
- {
- _articleGroupUserRepository = articleGroupUserRepository;
- _loginContext = loginContext;
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("{id}")]
- public async Task<bool> Delete(int id)
- {
- return await _articleGroupUserRepository.DeleteAsync(id);
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("add")]
- public async Task<bool> Add([FromBody] ArticleGroupUserInRequest request)
- {
- request.UserId = _loginContext.AccountId;
- return await _articleGroupUserRepository.InsertAsync(request) > 0;
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<bool> InsertAsync(ArticleGroupUserInNewRequest request)
- {
- request.UserId = _loginContext.AccountId;
- return await _articleGroupUserRepository.InsertAsync(request);
- }
- /// <summary>
- /// 获取用户的频道
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("list")]
- public async Task<IEnumerable<ArticleGroupUserListResult>> GetArticleGroupUserListByUserId(
- [FromBody] ArticleGroupUserSearchRequest request)
- {
- request.UserId = _loginContext.AccountId;
- return await _articleGroupUserRepository.GetListAsync(request);
- }
- }
- }
|