From 3ca8f1290232818ca2720fa3a9a736ca1d52a1a8 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期六, 07 十月 2023 20:42:32 +0800
Subject: [PATCH] gorm版本v2改成v1

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

diff --git a/model/device_plc.go b/model/device_plc.go
index fc8330e..830b4cb 100644
--- a/model/device_plc.go
+++ b/model/device_plc.go
@@ -5,17 +5,16 @@
 	"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"`
+		gorm.Model
+		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鐢�
@@ -82,16 +81,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