76 lines
2.0 KiB
C#
76 lines
2.0 KiB
C#
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 Kurisu.Core.DataAccess.Dto;
|
|
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="showDevices">是否显示设备</param>
|
|
/// <param name="type">分组类型</param>
|
|
/// <returns></returns>
|
|
[HttpGet("tree")]
|
|
[IgnoreTenant]
|
|
public async Task<List<DeviceGroupTreeResponse>> GetTreeAsync(bool showDevices, DeviceTypeEnumType? type)
|
|
{
|
|
return await _deviceGroupService.GetTreeAsync(showDevices, 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>> GetDevicesAsync(Guid code)
|
|
{
|
|
return await _deviceGroupService.GetDevicesAsync(code);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分配设备
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("assign")]
|
|
[IgnoreTenant]
|
|
[Transactional]
|
|
public async Task AssignDevicesAsync(DeviceAssignRequest request)
|
|
{
|
|
await _deviceGroupService.AssignDevicesAsync(request);
|
|
}
|
|
}
|