Former-commit-id: 92e8c463638f81a52745b0d38310b35f2beb24fd
Former-commit-id: 2caf52758ded7666164ee835acb4ef87ccb08bdb
TSXN
wanggang 5 years ago
parent b5247568ed
commit 543cc69a38

@ -4,13 +4,14 @@ using Infrastructure.Application.Models;
using Infrastructure.Application.Services.Settings; using Infrastructure.Application.Services.Settings;
using Infrastructure.Data; using Infrastructure.Data;
using Infrastructure.Extensions; using Infrastructure.Extensions;
using Infrastructure.Web.Mvc;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace Infrastructure.Web.Mvc namespace Infrastructure.Areas.Admin.Controllers
{ {
[Area("Admin")] [Area("Admin")]
public class SettingController : CrudController<Setting, EditSettingModel> public class SettingController : CrudController<Setting, EditSettingModel>
@ -107,6 +108,7 @@ namespace Infrastructure.Web.Mvc
} }
} }
[HttpGet]
public IActionResult Ajax(SettingType type) public IActionResult Ajax(SettingType type)
{ {
return PartialView("_Ajax", new EditSettingModel { Type = type }); return PartialView("_Ajax", new EditSettingModel { Type = type });

@ -19,7 +19,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse SetBrightness([SwaggerParameter("设备编号")]string number, [SwaggerParameter("亮度")][Range(0, 255)]int brightness) public ApiResponse SetBrightness([SwaggerParameter("设备编号"), Required] string number, [SwaggerParameter("亮度"), Range(0, 255), Required] int brightness)
{ {
if (number is null) if (number is null)
{ {
@ -40,7 +40,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse SetColor([SwaggerParameter("设备编号")]string number, [SwaggerParameter("色调")][Range(0, 255)]int hue, [SwaggerParameter("饱和度")][Range(0, 255)]int saturation) public ApiResponse SetColor([SwaggerParameter("设备编号"), Required] string number, [SwaggerParameter("色调"), Range(0, 255), Required] int hue, [SwaggerParameter("饱和度"), Range(0, 255), Required] int saturation)
{ {
try try
{ {
@ -55,8 +55,8 @@ namespace IoTNode.Controllers
return ApiResponse.AsyncSuccess(); return ApiResponse.AsyncSuccess();
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Change([SwaggerParameter("设备编号")]string number, [SwaggerParameter("亮度")][Range(0, 255)]int brightness, [SwaggerParameter("色调")][Range(0, 255)]int hue, [SwaggerParameter("饱和度")][Range(0, 255)]int saturation) public ApiResponse Change([SwaggerParameter("设备编号"), Required] string number, [SwaggerParameter("亮度"), Range(0, 255), Required] int brightness, [SwaggerParameter("色调"), Required][Range(0, 255)] int hue, [SwaggerParameter("饱和度"), Range(0, 255), Required] int saturation)
{ {
try try
{ {

@ -3,6 +3,7 @@ using IoTNode.DeviceServices.FBee;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations; using Swashbuckle.AspNetCore.Annotations;
using System; using System;
using System.ComponentModel.DataAnnotations;
namespace IoTNode.Controllers namespace IoTNode.Controllers
{ {
@ -17,7 +18,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Stop([SwaggerParameter("设备编号")]string number) public ApiResponse Stop([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {

@ -3,6 +3,7 @@ using IoTNode.DeviceServices.FBee;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations; using Swashbuckle.AspNetCore.Annotations;
using System; using System;
using System.ComponentModel.DataAnnotations;
namespace IoTNode.Controllers namespace IoTNode.Controllers
{ {
@ -16,7 +17,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Open([SwaggerParameter("设备编号")]string number,string password) public ApiResponse Open([SwaggerParameter("设备编号"), Required] string number, [SwaggerParameter("密码"), Required] string password)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -26,12 +27,12 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Close([SwaggerParameter("设备编号")] string number,string password) public ApiResponse Close([SwaggerParameter("设备编号"), Required] string number, [SwaggerParameter("密码"), Required] string password)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
var values = number.Split('-'); var values = number.Split('-');
this._deviceService.X82OpenDoor(values[0], values[1], password,0x00); this._deviceService.X82OpenDoor(values[0], values[1], password, 0x00);
}); });
} }
} }

@ -3,6 +3,7 @@ using IoTNode.DeviceServices.FBee;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations; using Swashbuckle.AspNetCore.Annotations;
using System; using System;
using System.ComponentModel.DataAnnotations;
namespace IoTNode.Controllers namespace IoTNode.Controllers
{ {
@ -27,7 +28,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse X9d([SwaggerParameter("网关Id")]string number) public ApiResponse X9d([SwaggerParameter("网关Id"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -36,7 +37,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse X81([SwaggerParameter("网关Id")]string number) public ApiResponse X81([SwaggerParameter("网关Id"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {

@ -19,7 +19,7 @@ namespace IoTNode.Controllers
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Send([SwaggerParameter("设备编号")]string number, [SwaggerParameter("按键类型")]byte type, [SwaggerParameter("键值")]ushort code) public ApiResponse Send([SwaggerParameter("设备编号"), Required] string number, [SwaggerParameter("按键类型"), Required] byte type, [SwaggerParameter("键值"), Required] ushort code)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -29,7 +29,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Study([SwaggerParameter("设备编号")]string number, [SwaggerParameter("按键类型")]byte type, [SwaggerParameter("键值"), Required, Range(603, 703)]ushort code) public ApiResponse Study([SwaggerParameter("设备编号"), Required] string number, [SwaggerParameter("按键类型"), Required] byte type, [SwaggerParameter("键值"), Required, Range(603, 703)] ushort code)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -39,7 +39,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Buttons([SwaggerParameter("设备编号")]string number, [SwaggerParameter("指令")]string buttons) public ApiResponse Buttons([SwaggerParameter("设备编号"), Required] string number, [SwaggerParameter("指令"), Required] string buttons)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -48,7 +48,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse MathAir1([SwaggerParameter("设备编号")]string number) public ApiResponse MathAir1([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -57,7 +57,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse MathAir2([SwaggerParameter("设备编号")]string number) public ApiResponse MathAir2([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -66,7 +66,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse MathAir3([SwaggerParameter("设备编号")]string number) public ApiResponse MathAir3([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {

@ -3,6 +3,7 @@ using IoTNode.DeviceServices.FBee;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations; using Swashbuckle.AspNetCore.Annotations;
using System; using System;
using System.ComponentModel.DataAnnotations;
namespace IoTNode.Controllers namespace IoTNode.Controllers
{ {
@ -17,7 +18,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse On([SwaggerParameter("设备编号")]string number) public ApiResponse On([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -28,7 +29,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Off([SwaggerParameter("设备编号")]string number) public ApiResponse Off([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -39,7 +40,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L1")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L1")]
public ApiResponse L1On([SwaggerParameter("设备编号")]string number) public ApiResponse L1On([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -49,7 +50,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L1")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L1")]
public ApiResponse L1Off([SwaggerParameter("设备编号")]string number) public ApiResponse L1Off([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -59,7 +60,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L2")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L2")]
public ApiResponse L2On([SwaggerParameter("设备编号")]string number) public ApiResponse L2On([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -69,7 +70,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L2")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L2")]
public ApiResponse L2Off([SwaggerParameter("设备编号")]string number) public ApiResponse L2Off([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {

@ -3,6 +3,7 @@ using IoTNode.DeviceServices.FBee;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations; using Swashbuckle.AspNetCore.Annotations;
using System; using System;
using System.ComponentModel.DataAnnotations;
namespace IoTNode.Controllers namespace IoTNode.Controllers
{ {
@ -17,7 +18,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse On([SwaggerParameter("设备编号")]string number) public ApiResponse On([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -29,7 +30,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Off([SwaggerParameter("设备编号")]string number) public ApiResponse Off([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -41,7 +42,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L1")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L1")]
public ApiResponse L1On([SwaggerParameter("设备编号")]string number) public ApiResponse L1On([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -51,7 +52,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L1")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L1")]
public ApiResponse L1Off([SwaggerParameter("设备编号")]string number) public ApiResponse L1Off([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -61,7 +62,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L2")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L2")]
public ApiResponse L2On([SwaggerParameter("设备编号")]string number) public ApiResponse L2On([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -71,7 +72,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L2")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L2")]
public ApiResponse L2Off([SwaggerParameter("设备编号")]string number) public ApiResponse L2Off([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -81,7 +82,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L3")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L3")]
public ApiResponse L3On([SwaggerParameter("设备编号")]string number) public ApiResponse L3On([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -91,7 +92,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L3")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("L3")]
public ApiResponse L3Off([SwaggerParameter("设备编号")]string number) public ApiResponse L3Off([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {

@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations; using Swashbuckle.AspNetCore.Annotations;
using System; using System;
using IoTNode.DeviceServices.FBee; using IoTNode.DeviceServices.FBee;
using System.ComponentModel.DataAnnotations;
namespace IoTNode.Controllers namespace IoTNode.Controllers
{ {
@ -17,7 +18,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse On([SwaggerParameter("设备编号")]string number) public ApiResponse On([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -27,7 +28,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Off([SwaggerParameter("设备编号")]string number) public ApiResponse Off([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {

@ -3,6 +3,7 @@ using IoTNode.DeviceServices.Onvif;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations; using Swashbuckle.AspNetCore.Annotations;
using System; using System;
using System.ComponentModel.DataAnnotations;
namespace IoTNode.Controllers namespace IoTNode.Controllers
{ {
@ -17,7 +18,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse ScreenShot([SwaggerParameter("设备编号")]string number) public ApiResponse ScreenShot([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.Action(() => return this.Action(() =>
{ {
@ -32,7 +33,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Up([SwaggerParameter("设备编号")]string number) public ApiResponse Up([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -41,7 +42,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Down([SwaggerParameter("设备编号")]string number) public ApiResponse Down([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -50,7 +51,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Left([SwaggerParameter("设备编号")]string number) public ApiResponse Left([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -59,7 +60,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Right([SwaggerParameter("设备编号")]string number) public ApiResponse Right([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -68,7 +69,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Zoomin([SwaggerParameter("设备编号")]string number) public ApiResponse Zoomin([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -77,7 +78,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Zoomout([SwaggerParameter("设备编号")]string number) public ApiResponse Zoomout([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -86,7 +87,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Stop([SwaggerParameter("设备编号")]string number) public ApiResponse Stop([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -95,7 +96,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse StartPush([SwaggerParameter("设备编号")]string number) public ApiResponse StartPush([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -104,7 +105,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse StopPush([SwaggerParameter("设备编号")]string number) public ApiResponse StopPush([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -113,7 +114,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse StartRecord([SwaggerParameter("设备编号")]string number) public ApiResponse StartRecord([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -122,7 +123,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse StopRecord([SwaggerParameter("设备编号")]string number) public ApiResponse StopRecord([SwaggerParameter("设备编号"), Required] string number)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {

@ -3,6 +3,7 @@ using IoTNode.DeviceServices.SerialPortManager;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations; using Swashbuckle.AspNetCore.Annotations;
using System; using System;
using System.ComponentModel.DataAnnotations;
namespace IoTNode.Controllers namespace IoTNode.Controllers
{ {
@ -18,7 +19,7 @@ namespace IoTNode.Controllers
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Send([SwaggerParameter("设备编号")]string number, [SwaggerParameter("命令")]string name) public ApiResponse Send([SwaggerParameter("设备编号"), Required] string number, [SwaggerParameter("命令"), Required] string name)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -27,7 +28,7 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Buttons([SwaggerParameter("设备编号")]string number, [SwaggerParameter("指令")]string buttons) public ApiResponse Buttons([SwaggerParameter("设备编号"), Required] string number, [SwaggerParameter("指令"), Required] string buttons)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {
@ -36,13 +37,13 @@ namespace IoTNode.Controllers
} }
[HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")] [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("")]
public ApiResponse Test([SwaggerParameter("设备编号")]string number, public ApiResponse Test([SwaggerParameter("设备编号"), Required] string number,
[SwaggerParameter("串口")]string port, [SwaggerParameter("串口"), Required] string port,
[SwaggerParameter("波特率")]int baud, [SwaggerParameter("波特率"), Required] int baud,
[SwaggerParameter("数据位")]int dataBits, [SwaggerParameter("数据位"), Required] int dataBits,
[SwaggerParameter("校验位")]int partity, [SwaggerParameter("校验位"), Required] int partity,
[SwaggerParameter("停止位")]int stopBits, [SwaggerParameter("停止位"), Required] int stopBits,
[SwaggerParameter("消息")]string message) [SwaggerParameter("消息"), Required] string message)
{ {
return this.AsyncAction(() => return this.AsyncAction(() =>
{ {

@ -95,10 +95,21 @@
<template v-if="data.model&&data.model.apiId&&data.model.parameters.length"> <template v-if="data.model&&data.model.apiId&&data.model.parameters.length">
<hr /> <hr />
<template v-if="deviceName==='红外转发器'"> <template v-if="deviceName==='红外转发器'">
{{deviceName}}
</template> </template>
<template v-else-if="deviceName==='串口控制器'"> <template v-else-if="deviceName==='串口控制器'">
{{deviceName}} <div class="form-group row">
<label class="col-sm-2 col-form-label">{{data.model.parameters[0].description}}:</label>
<div class="col-sm-6 form-control" style="border-color:transparent;height:auto;min-height:calc(2.25rem + 2px);">
<select class="form-control" v-model="data.model.parameters[0].value" @input="change2(0)">
<option value="null">请选择</option>
<option v-for="item in getSPCommands()" :value="item.name">{{item.name}}</option>
</select>
<div style="height:1em;">
<span v-if="hasErrors2(0)" class="field-validation-error text-danger">{{getPropertyErrors2(0)}}</span>
<span v-else class="text-danger field-validation-valid"></span>
</div>
</div>
</div>
</template> </template>
<template v-else v-for="(param,index) in data.model.parameters"> <template v-else v-for="(param,index) in data.model.parameters">
<div class="form-group row"> <div class="form-group row">
@ -239,8 +250,8 @@
messages = this.errors[index] = []; messages = this.errors[index] = [];
} }
if (item.required) { if (item.required) {
var message = "必须填写" + item.description; var message = "必须输入" + item.description;
this.updateErrorMessages2(messages, '必填项', o => !(o === 0 || o)); this.updateErrorMessages2(messages, message, o => value !== null && value !== '');
} }
if (item.minimum) { if (item.minimum) {
var minimum = parseFloat(item.minimum); var minimum = parseFloat(item.minimum);
@ -272,6 +283,15 @@
var permission = this.mode + '-' + this.entity; var permission = this.mode + '-' + this.entity;
return Enumerable.from(store.state.permissions).any(o => o.toLowerCase() === permission.toLowerCase()); return Enumerable.from(store.state.permissions).any(o => o.toLowerCase() === permission.toLowerCase());
}, },
getSPCommands: function () {
var commandData = Enumerable.from(this.data.data.device.data).where(o => o.name === '指令').firstOrDefault();
if (commandData) {
return Enumerable.from(JSON.parse(commandData.value))
.orderBy(function (o) { return o.order; })
.toArray();
}
return [];
},
getEditComponent: function (key) { getEditComponent: function (key) {
var property = this.data.schema.properties[key]; var property = this.data.schema.properties[key];
var template = 'edit-' + (property.ui || property.format || property.type); var template = 'edit-' + (property.ui || property.format || property.type);
@ -302,21 +322,6 @@
}); });
} }
}); });
//vm.$valid().then(function (value) {
// if (vm.data.errors.length === 0) {
// axios.post(e.target.action, vm.data.model).then(function (response) {
// if (response.status === 204) {
// var url = vm.base + 'index.html?area=' + vm.area + '&entity=' + vm.entity + '&model=' + vm.model;
// setTimeout(function () {
// router.push(url);
// }, 1000);
// }
// else {
// vm.data = response.data;
// }
// });
// }
//});
}, },
getValueComponent: function () { getValueComponent: function () {
var vm = this; var vm = this;
@ -347,12 +352,12 @@
watch: { watch: {
'data.model.apiId': function (val) { 'data.model.apiId': function (val) {
var vm = this; var vm = this;
if (val && this.data.model.deviceId) { if (val && val !== 'null' && this.data.model.deviceId) {
vm.errors = []; vm.errors = [];
var url = this.path + 'Api?apiId=' + val + '&deviceId=' + this.data.model.deviceId; var url = this.path + 'Api?apiId=' + val + '&deviceId=' + this.data.model.deviceId;
axios.get(url).then(function (response) { axios.get(url).then(function (response) {
console.log(response.data);
Vue.set(vm.data.data, vm.data.model.deviceId, response.data.data.device.name); Vue.set(vm.data.data, vm.data.model.deviceId, response.data.data.device.name);
Vue.set(vm.data.data, 'device', response.data.data.device);
vm.data.model.parameters = response.data.model; vm.data.model.parameters = response.data.model;
}); });
} }

@ -185,7 +185,7 @@
deleteAll: function () { deleteAll: function () {
var vm = this; var vm = this;
var url = this.baseUrl + this.path + 'DeleteApi'; var url = this.baseUrl + this.path + 'DeleteApi';
var list = $(this.$refs.list).find(':checked'); var list = $(this.$refs.list).find('tbody input:checked');
if (!list.length) { if (!list.length) {
Swal.fire('没有选中任何记录!'); Swal.fire('没有选中任何记录!');
} else { } else {

Loading…
Cancel
Save