87 lines
2.6 KiB
C#
87 lines
2.6 KiB
C#
|
|
using Microsoft.AspNetCore.Mvc;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
using VOL.Business.IServices.Device;
|
||
|
|
using VOL.Core.Filters;
|
||
|
|
using VOL.Entity.Enum;
|
||
|
|
using VOL.Model;
|
||
|
|
using VOL.Model.Device.Request;
|
||
|
|
using VOL.Model.Device.Response;
|
||
|
|
|
||
|
|
namespace VOL.WebApi.Controllers.Business
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// 学校设备管理。
|
||
|
|
/// </summary>
|
||
|
|
[Route("api/[controller]")]
|
||
|
|
[ApiController]
|
||
|
|
[ApiExplorerSettings(GroupName = "v3")]
|
||
|
|
[TypeFilter(typeof(CustomApiResponseFilter))]
|
||
|
|
public class DeviceManageController : ControllerBase
|
||
|
|
{
|
||
|
|
private readonly IDeviceManageService _deviceManageService;
|
||
|
|
|
||
|
|
public DeviceManageController(IDeviceManageService deviceManageService)
|
||
|
|
{
|
||
|
|
_deviceManageService = deviceManageService;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 获取设备分页列表。
|
||
|
|
/// </summary>
|
||
|
|
[HttpGet(nameof(GetPageList))]
|
||
|
|
public Task<PageDataDto<DeviceManageModel>> GetPageList([FromQuery] DevicePageListParam param)
|
||
|
|
{
|
||
|
|
return _deviceManageService.GetPageList(param);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 获取当前账号可管理的学校。
|
||
|
|
/// </summary>
|
||
|
|
[HttpGet(nameof(GetSchoolOptions))]
|
||
|
|
public Task<List<DeviceSchoolOption>> GetSchoolOptions([FromQuery] string keyword = null)
|
||
|
|
{
|
||
|
|
return _deviceManageService.GetSchoolOptions(keyword);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 获取设备详情。
|
||
|
|
/// </summary>
|
||
|
|
[HttpGet(nameof(Details))]
|
||
|
|
public Task<DeviceManageModel> Details([FromQuery] long id, [FromQuery] DeviceSourceType sourceType)
|
||
|
|
{
|
||
|
|
return _deviceManageService.Details(id, sourceType);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 新增并绑定设备。
|
||
|
|
/// </summary>
|
||
|
|
[HttpPost(nameof(Add))]
|
||
|
|
public async Task<ActionResult> Add([FromBody] SaveDeviceParam param)
|
||
|
|
{
|
||
|
|
await _deviceManageService.Add(param);
|
||
|
|
return Ok("新增成功");
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 修改设备及学校绑定。
|
||
|
|
/// </summary>
|
||
|
|
[HttpPost(nameof(Update))]
|
||
|
|
public async Task<ActionResult> Update([FromBody] SaveDeviceParam param)
|
||
|
|
{
|
||
|
|
await _deviceManageService.Update(param);
|
||
|
|
return Ok("修改成功");
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 删除设备。
|
||
|
|
/// </summary>
|
||
|
|
[HttpPost(nameof(Delete))]
|
||
|
|
public async Task<ActionResult> Delete([FromBody] DeleteDeviceParam param)
|
||
|
|
{
|
||
|
|
await _deviceManageService.Delete(param);
|
||
|
|
return Ok("删除成功");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|