123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- 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
- {
- /// <summary>
- /// 收藏
- /// </summary>
- [Route("api/app/collection")]
- [ApiController]
- [Authorize]
- public class CollectionController : ControllerBase
- {
- private readonly ILogger<CollectionController> _logger;
- private readonly ICollectionService _collectionService;
- private readonly ILoginContext _loginContext;
- private readonly ICollectionRepository collectionRepository;
- public CollectionController(ILogger<CollectionController> 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);
- }
- [HttpGet("update-result")]
- [AllowAnonymous]
- public async Task<bool> UpdateResultJosnAsync()
- {
- return await _collectionService.UpdateResultJosnAsync();
- }
- }
- }
|