From 71b0e418839dda386043fb6cad1ec335bcdc06c6 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期四, 09 十一月 2023 14:08:21 +0800
Subject: [PATCH] 增加设置是否跳过设置工艺参数接口
---
api/v1/config.go | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/api/v1/config.go b/api/v1/config.go
index 4765bcf..ee22af0 100644
--- a/api/v1/config.go
+++ b/api/v1/config.go
@@ -32,7 +32,7 @@
ConfigData, err := service.NewConfigService().GetNetConfigList()
if err != nil {
logx.Errorf("get net config error: %v", err.Error())
- ctx.FailWithMsg(ecode.UnknownErr, "鑾峰彇缃戠粶閰嶇疆澶辫触")
+ ctx.FailWithMsg(ecode.DBErr, "鑾峰彇缃戠粶閰嶇疆澶辫触")
return
}
@@ -53,14 +53,14 @@
return
}
- _, err := service.NewConfigService().GetNetConfig(params.Id)
+ _, err := service.NewConfigService().GetNetConfig(params.ID)
if err != nil {
logx.Errorf("get net config error: %v", err.Error())
- ctx.FailWithMsg(ecode.UnknownErr, "鑾峰彇缃戠粶閰嶇疆澶辫触")
+ ctx.FailWithMsg(ecode.DBErr, "鑾峰彇缃戠粶閰嶇疆澶辫触")
return
}
- err = service.NewConfigService().SetNetConfig(params.Id, ¶ms)
+ err = service.NewConfigService().SetNetConfig(params.ID, ¶ms)
if err != nil {
logx.Errorf("SetNetConfig error: %v", err.Error())
ctx.FailWithMsg(ecode.DBErr, "璁剧疆澶辫触")
@@ -125,12 +125,18 @@
return
}
+ params.DeviceID = conf.Conf.CurrentDeviceID
if params.Method == constvar.PlcMethodModbusTCP && (params.Address == "" || params.Port == 0) {
- ctx.FailWithMsg(ecode.ParamsErr, "褰撴帴鍙f柟寮忎负modbusTCP鏃讹紝address鍜宲ort涓嶈兘涓虹┖")
+ ctx.FailWithMsg(ecode.ParamsErr, "褰撴帴鍙f柟寮忎负modbusTCP鏃讹紝鍦板潃鍜岀鍙e彿涓嶈兘涓虹┖")
return
}
if params.Method == constvar.PlcMethodSerial && (params.BaudRate == 0 || params.SerialName == "") {
- ctx.FailWithMsg(ecode.ParamsErr, "褰撴帴鍙f柟寮忎负serial鏃讹紝baudRate鍜宻erialName涓嶈兘涓虹┖")
+ ctx.FailWithMsg(ecode.ParamsErr, "褰撴帴鍙f柟寮忎负serial鏃讹紝娉㈢壒鐜囧拰涓插彛鍚嶇О涓嶈兘涓虹┖")
+ return
+ }
+
+ if params.Method == constvar.PlcMethodModbusRTU && (params.DataBit == 0 || params.StopBit == 0 || params.Parity == 0) {
+ ctx.FailWithMsg(ecode.ParamsErr, "褰撴帴鍙f柟寮忎负modbusRTU鏃讹紝鏁版嵁浣嶏紝鍋滄浣嶏紝鏍¢獙浣嶄笉鑳戒负绌�")
return
}
--
Gitblit v1.8.0