1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- using System.Threading.Tasks;
- using GxPress.Auth;
- using GxPress.Common.Page;
- using GxPress.Repository.Interface.Collection;
- using GxPress.Request.App.Collection;
- using GxPress.Result.App.Collection;
- using GxPress.Service.Interface.Collection;
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Logging;
- namespace GxPress.Api.WebControllers
- {
- /// <summary>
- /// 收藏
- /// </summary>
- [Route("api/web/collection")]
- [ApiController]
- [Authorize]
- public class WebCollectionController : Controller
- {
- private readonly ILogger<WebCollectionController> _logger;
- private readonly ICollectionService _collectionService;
- private readonly ILoginContext _loginContext;
- private readonly ICollectionRepository collectionRepository;
- public WebCollectionController(ILogger<WebCollectionController> logger, ICollectionService collectionService, ILoginContext loginContext, ICollectionRepository collectionRepository)
- {
- _logger = logger;
- _collectionService = collectionService;
- _loginContext = loginContext;
- this.collectionRepository = collectionRepository;
- }
- /// <summary>
- /// 添加收藏
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPut("add")]
- public async Task<bool> Insert(CollectionInRequest request)
- {
- request.UserId = _loginContext.AccountId;
- return await _collectionService.Insert(request);
- }
- /// <summary>
- /// 收藏
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("search")]
- public async Task<PagedList<CollectionListPageResult>> PageList(CollectionPageSearchRequest request)
- {
- request.UserId = _loginContext.AccountId;
- return await _collectionService.PageListAsync(request);
- }
- /// <summary>
- /// 获取收藏详情
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("{id}")]
- public async Task<CollectionResult> GetCollectionDetail(int id)
- {
- return await _collectionService.GetCollectionDetailAsync(id);
- }
- /// <summary>
- /// 收藏无文件夹分页列表
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("list")]
- public async Task<PagedList<CollectionNoFolderResult>> GetCollectionNoFolderPageListAsync(CollectionPageSearchRequest request)
- {
- request.UserId = _loginContext.AccountId;
- return await _collectionService.GetCollectionNoFolderPageListAsync(request);
- }
- /// <summary>
- /// 设置收藏置顶
- /// </summary>
- /// <param name="id"></param>
- /// <return></returns>
- [HttpPut("{id}")]
- public async Task<bool> SetTopAsync(int id)
- {
- return await collectionRepository.SetTopAsync(id);
- }
- }
- }
|