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/net_config.go |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/model/net_config.go b/model/net_config.go
index 70fd169..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,7 +200,6 @@
 			Status:      0,
 		},
 		{
-			Id:          2,
 			NetworkCard: "enp2s0",
 			IP:          "",
 			MASK:        "",

--
Gitblit v1.8.0