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.
 
 

212 lines
6.6 KiB

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;
}
/// <summary>
/// 添加设备信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Authorize]
[Route("api/v1/equipment")]
public async Task<ResponseOutput> AddAsync([FromBody] EquipmentAddInput input)
{
return await _equipmentService.AddAsync(input);
}
/// <summary>
/// 编辑设备信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPut]
[Authorize]
[Route("api/v1/equipment")]
public async Task<ResponseOutput> UpdateAsync([FromBody] EquipmentUpdateInput input)
{
return await _equipmentService.UpdateAsync(input);
}
/// <summary>
/// 根据Id获取设备信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("api/v1/equipment/{id}")]
public async Task<ResponseOutput> GetAsync(long id)
{
return await _equipmentService.GetAsync(id);
}
/// <summary>
/// 分页查询设备列表
/// </summary>
/// <param name="key"></param>
/// <param name="categoryId"></param>
/// <param name="brandId"></param>
/// <param name="yearId"></param>
/// <param name="currentPage"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
[HttpGet]
[Route("api/v1/equipment/search")]
public async Task<ResponseOutput> 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);
}
/// <summary>
/// 刷新设备信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPut]
[Authorize]
[Route("api/v1/equipment/refresh/{id}")]
public async Task<ResponseOutput> RefreshAsync(long id)
{
return await _equipmentService.RefreshAsync(id);
}
/// <summary>
/// 置顶设备信息
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPut]
[Authorize]
[Route("api/v1/equipment/top/{id}")]
public async Task<ResponseOutput> TopAsync(long id)
{
return await _equipmentService.TopAsync(id);
}
/// <summary>
/// 取消置顶设备信息
/// </summary>
/// <returns></returns>
[HttpPut]
[Route("api/v1/equipment/cancel/top")]
[AllowAnonymous]
public async Task<ResponseOutput> CancelTopAsync()
{
return await _equipmentService.CancelTopAsync();
}
/// <summary>
/// 更改设备信息状态
/// </summary>
/// <param name="id"></param>
/// <param name="state">设备状态</param>
/// <returns></returns>
[HttpPut]
[Authorize]
[Route("api/v1/equipment/state/{state}/{id}")]
public async Task<ResponseOutput> UpdateStateAsync(long id, int state)
{
return await _equipmentService.UpdateStateAsync(id, state);
}
/// <summary>
/// 是否公开设备信息
/// </summary>
/// <param name="id"></param>
/// <param name="isPublic"></param>
/// <returns></returns>
[HttpPut]
[Authorize]
[Route("api/v1/equipment/public/{isPublic}/{id}")]
public async Task<ResponseOutput> IsPublicAsync(long id, bool isPublic)
{
return await _equipmentService.IsPublicAsync(id, isPublic);
}
/// <summary>
/// 获取手机号码
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
[Route("api/v1/equipment/phone/{id}")]
public async Task<ResponseOutput> GetPhoneAsync(long id)
{
return await _equipmentService.GetPhoneAsync(id);
}
/// <summary>
/// 同步浏览量
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("api/v1/equipment/pageview")]
public async Task<ResponseOutput> PageViewAsync()
{
return await _equipmentService.PageViewAsync();
}
/// <summary>
/// 我的设备信息
/// </summary>
/// <param name="state">全部-1/审核中10/出售中20/已成交30/审核失败0</param>
/// <param name="currentPage"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
[Route("api/v1/my/equipment")]
public async Task<ResponseOutput> MyEquipmentPageAsync(
int state = -1, int currentPage = 1, int pageSize = 10)
{
return await _equipmentService.MyEquipmentPageAsync(state, currentPage, pageSize);
}
/// <summary>
/// 根据UserId查询设备信息
/// </summary>
/// <param name="userId"></param>
/// <param name="currentPage"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
[HttpGet]
[Route("api/v1/equipment/userid")]
public async Task<ResponseOutput> GetEquipmentByUserIdAsync(long userId, int currentPage = 1, int pageSize = 10)
{
return await _equipmentService.GetEquipmentByUserIdAsync(userId, currentPage, pageSize);
}
/// <summary>
/// 获取用户上次保存信息
/// </summary>
/// <returns></returns>
[HttpGet]
[Authorize]
[Route("api/v1/equipment/history")]
public Task<ResponseOutput> GetLastEquipmentAsync()
{
return _equipmentService.GetLastEquipmentAsync();
}
}
}