using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Znyc.CloudCar.IServices.Equipment;
using Znyc.CloudCar.Model.Dtos.Equipment;
using Znyc.CloudCar.Model.ViewModels.ReportsCallBack;
namespace Znyc.CloudCar.Controller
{
[ApiController]
public class EquipmentController : ControllerBase
{
private readonly IEquipmentService _equipmentService;
public EquipmentController(
IEquipmentService equipmentService
)
{
_equipmentService = equipmentService;
}
///
/// 添加设备信息
///
///
///
[HttpPost]
[Authorize]
[Route("api/v1/equipment")]
public async Task AddAsync([FromBody] EquipmentAddInput input)
{
return await _equipmentService.AddAsync(input);
}
///
/// 编辑设备信息
///
///
///
[HttpPut]
[Authorize]
[Route("api/v1/equipment")]
public async Task UpdateAsync([FromBody] EquipmentUpdateInput input)
{
return await _equipmentService.UpdateAsync(input);
}
///
/// 根据Id获取设备信息
///
///
///
[HttpGet]
[Route("api/v1/equipment/{id}")]
public async Task GetAsync(long id)
{
return await _equipmentService.GetAsync(id);
}
///
/// 分页查询设备列表
///
///
///
///
///
///
///
///
[HttpGet]
[Route("api/v1/equipment/search")]
public async Task PageAsync(string key, long categoryId,
long brandId, long yearId, int currentPage = 1, int pageSize = 10)
{
return await _equipmentService.PageAsync(key, categoryId, brandId, yearId, currentPage, pageSize);
}
///
/// 刷新设备信息
///
///
///
[HttpPut]
[Authorize]
[Route("api/v1/equipment/refresh/{id}")]
public async Task RefreshAsync(long id)
{
return await _equipmentService.RefreshAsync(id);
}
///
/// 置顶设备信息
///
///
///
[HttpPut]
[Authorize]
[Route("api/v1/equipment/top/{id}")]
public async Task TopAsync(long id)
{
return await _equipmentService.TopAsync(id);
}
///
/// 取消置顶设备信息
///
///
[HttpPut]
[Route("api/v1/equipment/cancel/top")]
[AllowAnonymous]
public async Task CancelTopAsync()
{
return await _equipmentService.CancelTopAsync();
}
///
/// 更改设备信息状态
///
///
/// 设备状态
///
[HttpPut]
[Authorize]
[Route("api/v1/equipment/state/{state}/{id}")]
public async Task UpdateStateAsync(long id, int state)
{
return await _equipmentService.UpdateStateAsync(id, state);
}
///
/// 是否公开设备信息
///
///
///
///
[HttpPut]
[Authorize]
[Route("api/v1/equipment/public/{isPublic}/{id}")]
public async Task IsPublicAsync(long id, bool isPublic)
{
return await _equipmentService.IsPublicAsync(id, isPublic);
}
///
/// 获取手机号码
///
///
///
[HttpGet]
[Authorize]
[Route("api/v1/equipment/phone/{id}")]
public async Task GetPhoneAsync(long id)
{
return await _equipmentService.GetPhoneAsync(id);
}
///
/// 同步浏览量
///
///
[HttpGet]
[Route("api/v1/equipment/pageview")]
public async Task PageViewAsync()
{
return await _equipmentService.PageViewAsync();
}
///
/// 我的设备信息
///
/// 全部-1/审核中10/出售中20/已成交30/审核失败0
///
///
///
[HttpGet]
[Authorize]
[Route("api/v1/my/equipment")]
public async Task MyEquipmentPageAsync(
int state = -1, int currentPage = 1, int pageSize = 10)
{
return await _equipmentService.MyEquipmentPageAsync(state, currentPage, pageSize);
}
///
/// 根据UserId查询设备信息
///
///
///
///
///
[HttpGet]
[Route("api/v1/equipment/userid")]
public async Task GetEquipmentByUserIdAsync(long userId, int currentPage = 1, int pageSize = 10)
{
return await _equipmentService.GetEquipmentByUserIdAsync(userId, currentPage, pageSize);
}
///
/// 获取用户上次保存信息
///
///
[HttpGet]
[Authorize]
[Route("api/v1/equipment/history")]
public Task GetLastEquipmentAsync()
{
return _equipmentService.GetLastEquipmentAsync();
}
}
}