From 5036de7ca06a7a04a45642b80db644a55062cd68 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 11 十月 2023 14:10:39 +0800 Subject: [PATCH] debug --- model/net_config.go | 17 +++++++---------- 1 files changed, 7 insertions(+), 10 deletions(-) diff --git a/model/net_config.go b/model/net_config.go index eacd0c4..5c8c4a9 100644 --- a/model/net_config.go +++ b/model/net_config.go @@ -3,14 +3,13 @@ import ( "apsClient/pkg/sqlitex" "fmt" - "gorm.io/gorm" + "github.com/jinzhu/gorm" "sync" ) type ( NetConfig struct { - gorm.Model `json:"-"` - Id int `gorm:"primarykey;type:int;" json:"id"` + gorm.Model NetworkCard string `gorm:"type:varchar(100);not null;default '';comment:缃戝崱" json:"networkCard" binding:"required"` //缃戝崱 IP string `gorm:"type:varchar(100);not null;default '';comment:鏈満ip" json:"ip" binding:"required"` //鏈満ip MASK string `gorm:"type:varchar(100);not null;default '';comment:瀛愮綉鎺╃爜" json:"mask" binding:"required"` //瀛愮綉鎺╃爜 @@ -53,15 +52,15 @@ return slf } -func (slf *NetConfigSearch) SetId(id int) *NetConfigSearch { - slf.Id = id +func (slf *NetConfigSearch) SetId(id uint) *NetConfigSearch { + slf.ID = id return slf } func (slf *NetConfigSearch) build() *gorm.DB { var db = slf.Orm.Model(&NetConfig{}) - if slf.Id > 0 { - db = db.Where("id = ?", slf.Id) + if slf.ID > 0 { + db = db.Where("id = ?", slf.ID) } return db } @@ -193,7 +192,6 @@ } records := []*NetConfig{ { - Id: 1, NetworkCard: "enp3s0", IP: "", MASK: "", @@ -202,8 +200,7 @@ Status: 0, }, { - Id: 2, - NetworkCard: "", + NetworkCard: "enp2s0", IP: "", MASK: "", Gateway: "", -- Gitblit v1.8.0