using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Znyc.CloudCar.IServices.Collection;
using Znyc.CloudCar.Model.ViewModels.ReportsCallBack;
namespace Znyc.CloudCar.Controller
{
public class CollectionController : ControllerBase
{
private readonly ICollectionService _collectionService;
public CollectionController(ICollectionService collectionService)
{
_collectionService = collectionService;
}
///
/// 分页查询收藏记录列表
///
///
///
///
[HttpGet]
[Authorize]
[Route("api/v1/collection/search")]
public async Task PageAsync(int currentPage, int pageSize)
{
return await _collectionService.PageAsync(currentPage, pageSize);
}
///
/// 添加收藏
///
///
///
[HttpPost]
[Authorize]
[Route("api/v1/collection/add/{equipmentId}")]
public async Task AddAsync(long equipmentId)
{
return await _collectionService.AddAsync(equipmentId);
}
///
/// 取消收藏
///
///
///
[HttpPut]
[Authorize]
[Route("api/v1/collection/cancel/{equipmentId}")]
public async Task CancelAsync(long equipmentId)
{
return await _collectionService.CancelAsync(equipmentId);
}
///
/// 是否收藏
///
///
///
[HttpGet]
[Authorize]
[Route("api/v1/collection/iscollection/{equipmentId}")]
public async Task IsCollection(long equipmentId)
{
return await _collectionService.IsCollection(equipmentId);
}
}
}