You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

70 lines
2.1 KiB

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;
}
/// <summary>
/// 分页查询收藏记录列表
/// </summary>
/// <param name="currentPage"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
[Route("api/v1/collection/search")]
public async Task<ResponseOutput> PageAsync(int currentPage, int pageSize)
{
return await _collectionService.PageAsync(currentPage, pageSize);
}
/// <summary>
/// 添加收藏
/// </summary>
/// <param name="equipmentId"></param>
/// <returns></returns>
[HttpPost]
[Authorize]
[Route("api/v1/collection/add/{equipmentId}")]
public async Task<ResponseOutput> AddAsync(long equipmentId)
{
return await _collectionService.AddAsync(equipmentId);
}
/// <summary>
/// 取消收藏
/// </summary>
/// <param name="equipmentId"></param>
/// <returns></returns>
[HttpPut]
[Authorize]
[Route("api/v1/collection/cancel/{equipmentId}")]
public async Task<ResponseOutput> CancelAsync(long equipmentId)
{
return await _collectionService.CancelAsync(equipmentId);
}
/// <summary>
/// 是否收藏
/// </summary>
/// <param name="equipmentId"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
[Route("api/v1/collection/iscollection/{equipmentId}")]
public async Task<bool> IsCollection(long equipmentId)
{
return await _collectionService.IsCollection(equipmentId);
}
}
}