99 lines
2.8 KiB
C#
99 lines
2.8 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using YD_AllHeartRates.Api.Entitys;
|
|
using YD_AllHeartRates.Api.Services.Impl;
|
|
using YD_AllHeartRates.Api.Services.Interface;
|
|
using YD_AllHeartRates.Commons.Dto.Device;
|
|
using YD_AllHeartRates.Commons.Dto;
|
|
using YD_AllHeartRates.Commons.Dto.LargeScreen;
|
|
|
|
namespace YD_AllHeartRates.Api.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 设备
|
|
/// </summary>
|
|
[ApiVersion("1.0")]
|
|
[AllowAnonymous]
|
|
public class DeviceController : ControllerBase
|
|
{
|
|
private readonly IDeviceService _deviceService;
|
|
|
|
/// <summary>
|
|
/// 构造
|
|
/// </summary>
|
|
/// <param name="deviceService"></param>
|
|
public DeviceController(IDeviceService deviceService)
|
|
{
|
|
_deviceService = deviceService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取设备列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(DevicePageList))]
|
|
public async Task<PageDataDto<DevicePageListDto>> DevicePageList(DevicePageDto dto)
|
|
{
|
|
var res = await _deviceService.DevicePageList(dto);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设备数量
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet(nameof(DeviceNumber))]
|
|
public async Task<Dictionary<string, DeviceNumberDto>> DeviceNumber()
|
|
{
|
|
var res = await _deviceService.DeviceNumber();
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增设备
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(AddDevice))]
|
|
public async Task<bool> AddDevice([FromBody] AddDeviceDto dto)
|
|
{
|
|
var res = await _deviceService.AddDevice(dto);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑设备
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(UpdateDevice))]
|
|
public async Task<bool> UpdateDevice([FromBody] AddDeviceDto dto)
|
|
{
|
|
var res = await _deviceService.UpdateDevice(dto);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除设备
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(DeleteDevice))]
|
|
public async Task<bool> DeleteDevice(string code)
|
|
{
|
|
var res = await _deviceService.DeleteDevice(code);
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 批量导入
|
|
/// </summary>
|
|
/// <param name="file"></param>
|
|
/// <returns></returns>
|
|
[HttpPost(nameof(ImportDevice))]
|
|
public async Task<bool> ImportDevice(IFormFile file)
|
|
{
|
|
var res = await _deviceService.ImportDevice(file);
|
|
return res;
|
|
}
|
|
}
|
|
}
|