using System.Threading.Tasks; using GxPress.Auth; using GxPress.Common.Page; 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; using GxPress.Repository.Interface.Collection; namespace GxPress.Api.AppControllers { /// /// 收藏 /// [Route("api/app/collection")] [ApiController] [Authorize] public class CollectionController : ControllerBase { private readonly ILogger _logger; private readonly ICollectionService _collectionService; private readonly ILoginContext _loginContext; private readonly ICollectionRepository collectionRepository; public CollectionController(ILogger logger, ICollectionService collectionService, ILoginContext loginContext, ICollectionRepository collectionRepository) { _logger = logger; _collectionService = collectionService; _loginContext = loginContext; this.collectionRepository = collectionRepository; } /// /// 添加收藏 /// /// /// [HttpPut("add")] public async Task Insert(CollectionInRequest request) { request.UserId = _loginContext.AccountId; return await _collectionService.Insert(request); } /// /// 收藏 /// /// /// [HttpPost("search")] public async Task> PageList(CollectionPageSearchRequest request) { request.UserId = _loginContext.AccountId; return await _collectionService.PageListAsync(request); } /// /// 获取收藏详情 /// /// /// [HttpGet("{id}")] public async Task GetCollectionDetail(int id) { return await _collectionService.GetCollectionDetailAsync(id); } /// /// 收藏无文件夹分页列表 /// /// /// [HttpPost("list")] public async Task> GetCollectionNoFolderPageListAsync(CollectionPageSearchRequest request) { request.UserId = _loginContext.AccountId; return await _collectionService.GetCollectionNoFolderPageListAsync(request); } /// /// 设置收藏置顶 /// /// /// [HttpPut("{id}")] public async Task SetTopAsync(int id) { return await collectionRepository.SetTopAsync(id); } [HttpGet("update-result")] [AllowAnonymous] public async Task UpdateResultJosnAsync() { return await _collectionService.UpdateResultJosnAsync(); } } }