using Application.Models; using IoT.Shared.Controllers; using Microsoft.AspNetCore.Mvc; using Swashbuckle.AspNetCore.Annotations; using System; namespace SerialPortService.Controllers { [SwaggerTag("串口")] public class SerialPortController : BaseDeviceController { private readonly DeviceService _deviceService; public SerialPortController(IServiceProvider applicationServices, DeviceService deviceService) : base(applicationServices) { this._deviceService = deviceService; } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("添加命令")] public ApiResponse AddButton([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number, [SwaggerParameter("名称")]string key, [SwaggerParameter("消息")]string value) { return this.AsyncAction(() => { //this._deviceService.UpdateButtons(number, buttons); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("修改命令")] public ApiResponse EditButton([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number, [SwaggerParameter("名称")]string key, [SwaggerParameter("消息")]string value) { return this.AsyncAction(() => { //this._deviceService.UpdateButtons(number, buttons); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("删除命令")] public ApiResponse DeleteButton([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number, [SwaggerParameter("名称")]string key) { return this.AsyncAction(() => { //this._deviceService.UpdateButtons(number, buttons); }); } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("执行命令")] public ApiResponse PressButton([SwaggerParameter("网关编号")]string gateway, [SwaggerParameter("设备编号")]string number, [SwaggerParameter("按键码")]string key) { return this.AsyncAction(() => { this._deviceService.Exec(number, key); }); } } }