From 288d78f66ecd1b628e8d1df7a3da99fc5e6880ec Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 08 十二月 2023 14:13:37 +0800
Subject: [PATCH] debug

---
 model/device_plc.go |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/model/device_plc.go b/model/device_plc.go
index 134e48b..a6e7331 100644
--- a/model/device_plc.go
+++ b/model/device_plc.go
@@ -20,8 +20,13 @@
 		Port       int                `json:"port"`                             //plc 绔彛鍙凤紝  method =  modbusTCP鐢�
 		BaudRate   int                `json:"baudRate"`                         //涓插彛娉㈢壒鐜囷紝 method = serial鏃� 鐢�
 		SerialName string             `json:"serialName"`                       //涓插彛鍚嶇О锛宮ethod = serial鏃� 鐢�
-		IsOpen     bool               `json:"isOpen"`
-		Detail     string             `gorm:"type:varchar(2048)" json:"-"`
+
+		DataBit int             `gorm:"type:int(11)"  json:"dataBit"` //鏁版嵁浣嶏紝method = modbusRTU 鐢�
+		StopBit int             `gorm:"type:int(11)"  json:"stopBit"` //鍋滄浣嶏紝method = modbusRTU 鐢�
+		Parity  constvar.Parity `gorm:"type:int(11)"  json:"parity"`  //鏍¢獙鏂瑰紡锛宮ethod = modbusRTU 鐢�
+
+		IsOpen bool   `json:"isOpen"`
+		Detail string `gorm:"type:varchar(2048)" json:"-"`
 
 		Details []*DevicePlcAddress `gorm:"-" json:"details"`
 
@@ -52,12 +57,15 @@
 }
 
 func (slf *DevicePlc) AfterFind(tx *gorm.DB) error {
-	details := make([]*DevicePlcAddress, 0)
-	err := json.Unmarshal([]byte(slf.Detail), &details)
-	if err != nil {
-		return err
+	if slf.Detail != "" {
+		details := make([]*DevicePlcAddress, 0)
+		err := json.Unmarshal([]byte(slf.Detail), &details)
+		if err != nil {
+			return err
+		}
+		slf.Details = details
 	}
-	slf.Details = details
+
 	return nil
 }
 

--
Gitblit v1.8.0