李昊 před 4 roky
rodič
revize
9983b7a9bc

+ 14 - 2
gx_api/GxPress/Api/GxPress.Api/WebControllers/WebCollectionController.cs

@@ -1,6 +1,7 @@
 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;
@@ -21,13 +22,14 @@ namespace GxPress.Api.WebControllers
         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)
+        public WebCollectionController(ILogger<WebCollectionController> logger, ICollectionService collectionService, ILoginContext loginContext, ICollectionRepository collectionRepository)
         {
             _logger = logger;
             _collectionService = collectionService;
             _loginContext = loginContext;
+            this.collectionRepository = collectionRepository;
         }
         /// <summary>
         /// 添加收藏
@@ -73,5 +75,15 @@ namespace GxPress.Api.WebControllers
             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);
+        }
     }
 }