From eba4eb850f0ecfb5839395aa125955ceaa2a454f Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期四, 19 十月 2023 16:39:07 +0800
Subject: [PATCH] Merge branch 'feat-serf'

---
 model/device_plc.go |   31 ++++++++++++++-----------------
 1 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/model/device_plc.go b/model/device_plc.go
index fc8330e..9ce9bbc 100644
--- a/model/device_plc.go
+++ b/model/device_plc.go
@@ -5,25 +5,22 @@
 	"apsClient/pkg/sqlitex"
 	"encoding/json"
 	"fmt"
-	"gorm.io/gorm"
+	"github.com/jinzhu/gorm"
 )
 
 type (
 
 	// DevicePlc 璁惧鐨凱LC閰嶇疆
 	DevicePlc struct {
-		gorm.Model `json:"-"`
-		Id         int                `gorm:"primarykey;type:int;" json:"id"`
-		Brand      string             `gorm:"type:varchar(191);comment:PLC鍝佺墝" json:"brand"`
-		Method     constvar.PlcMethod `gorm:"type:varchar(191);comment:鎺ュ彛鏂瑰紡" json:"method"`
-		//PortName   string `gorm:"type:varchar(191);comment:绔彛鍚嶇О" json:"portName"`
-		//Frequency  int    `gorm:"comment:鏁版嵁鏇存柊棰戠巼 0-瀹炴椂鏇存柊 1-1娆�/绉�" json:"frequency"`
-		Address    string `gorm:"type:varchar(191);comment:PLC鍦板潃" json:"address"` //plc ip鍦板潃锛� method = modbusTCP鐢�
-		Port       int    `gorm:"comment:绔彛" json:"port"`                         //plc 绔彛鍙凤紝  method =  modbusTCP鐢�
-		BaudRate   int    `gorm:"comment:娉㈢壒鐜�"  json:"baudRate"`                   //涓插彛娉㈢壒鐜囷紝 method = serial鏃� 鐢�
-		SerialName string `gorm:"comment:涓插彛鍚嶇О"  json:"serialName"`                //涓插彛鍚嶇О锛宮ethod = serial鏃� 鐢�
-		IsOpen     bool   `gorm:"comment:鏄惁寮�鍚�" json:"isOpen"`
-		Detail     string `gorm:"type:varchar(2048);comment:鏁版嵁璇︽儏" json:"-"`
+		gorm.Model
+		Brand      string             `gorm:"type:varchar(191)" json:"brand"`
+		Method     constvar.PlcMethod `gorm:"type:varchar(191)" json:"method"`
+		Address    string             `gorm:"type:varchar(191)" json:"address"` //plc ip鍦板潃锛� method = modbusTCP鐢�
+		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:"-"`
 
 		Details []*DevicePlcAddress `gorm:"-" json:"details"`
 
@@ -82,16 +79,16 @@
 	return slf
 }
 
-func (slf *DevicePlcSearch) SetId(id int) *DevicePlcSearch {
-	slf.Id = id
+func (slf *DevicePlcSearch) SetId(id uint) *DevicePlcSearch {
+	slf.ID = id
 	return slf
 }
 
 func (slf *DevicePlcSearch) build() *gorm.DB {
 	var db = slf.Orm.Table(slf.TableName())
 
-	if slf.Id > 0 {
-		db = db.Where("id = ?", slf.Id)
+	if slf.ID > 0 {
+		db = db.Where("id = ?", slf.ID)
 	}
 
 	if slf.Order != "" {

--
Gitblit v1.8.0