87 lines
2.4 KiB
C#
87 lines
2.4 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Dlhis.Basic.Device.Request;
|
|
using Dlhis.Basic.Device.Response;
|
|
using Dlhis.Basic.Device.Services;
|
|
using Dlhis.Entity.Device.Enums;
|
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Dlhis.Basic.Device.Controllers;
|
|
|
|
/// <summary>
|
|
/// 设备分组
|
|
/// </summary>
|
|
[Authorize]
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class DeviceGroupsController : ControllerBase
|
|
{
|
|
private readonly IDeviceGroupService _deviceGroupService;
|
|
|
|
public DeviceGroupsController(IDeviceGroupService deviceGroupService)
|
|
{
|
|
_deviceGroupService = deviceGroupService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取设备组树
|
|
/// </summary>
|
|
/// <param name="type">分组类型</param>
|
|
/// <returns></returns>
|
|
[HttpGet("tree")]
|
|
[IgnoreTenant]
|
|
public async Task<List<DeviceGroupTreeResponse>> GetTreeAsync(
|
|
[EnumDataType(typeof(DeviceTypeEnumType), ErrorMessage = "请选择正确的类型")]
|
|
DeviceTypeEnumType type
|
|
)
|
|
{
|
|
return await _deviceGroupService.GetTreeAsync(type);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设备分组保存
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("save")]
|
|
[IgnoreTenant]
|
|
public async Task SaveAsync(DeviceGroupSaveRequest request)
|
|
{
|
|
await _deviceGroupService.SaveAsync(request);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取分组下的设备
|
|
/// </summary>
|
|
/// <param name="code"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("devices")]
|
|
public async Task<List<DeviceUnderGroupResponse>> GetDevicesByGroupCodeAsync(Guid code)
|
|
{
|
|
return await _deviceGroupService.GetDevicesByGroupCodeAsync(code);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分配设备
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("assign")]
|
|
[Transactional]
|
|
[DataPermission]
|
|
public async Task AssignDevicesAsync(DeviceAssignRequest request)
|
|
{
|
|
await _deviceGroupService.AssignDevicesAsync(request);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取用于预约的设备组
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("type/appointment")]
|
|
public async Task<List<DeviceGroupResponse>> GetAppointmentGroupsAsync()
|
|
{
|
|
return await _deviceGroupService.GetAppointmentGroupsAsync();
|
|
}
|
|
} |