diff --git a/.gitignore b/.gitignore
old mode 100644
new mode 100755
diff --git a/.idea/go_mqtt.iml b/.idea/go_mqtt.iml
old mode 100644
new mode 100755
diff --git a/.idea/modules.xml b/.idea/modules.xml
old mode 100644
new mode 100755
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
old mode 100644
new mode 100755
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
old mode 100644
new mode 100755
index 2894444..5203c7b
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,9 +4,23 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -52,14 +66,25 @@
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -69,6 +94,16 @@
+
+
+
+
+
+
+
+
+
+
@@ -95,7 +130,8 @@
-
+
+
true
diff --git a/README.md b/README.md
old mode 100644
new mode 100755
diff --git a/go.mod b/go.mod
old mode 100644
new mode 100755
index 3964690..041c442
--- a/go.mod
+++ b/go.mod
@@ -1,20 +1,22 @@
module go_mqtt
-go 1.21.3
+go 1.24.1
-require github.com/eclipse/paho.mqtt.golang v1.4.2
+require (
+ github.com/eclipse/paho.mqtt.golang v1.4.2
+ github.com/go-sql-driver/mysql v1.9.0
+ github.com/google/uuid v1.6.0
+ github.com/shopspring/decimal v1.4.0
+ gorm.io/driver/mysql v1.5.7
+ gorm.io/gorm v1.25.12
+)
require (
filippo.io/edwards25519 v1.1.0 // indirect
- github.com/go-sql-driver/mysql v1.9.0 // indirect
- github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
- github.com/shopspring/decimal v1.4.0 // indirect
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/text v0.22.0 // indirect
- gorm.io/driver/mysql v1.5.7 // indirect
- gorm.io/gorm v1.25.12 // indirect
)
diff --git a/go.sum b/go.sum
old mode 100644
new mode 100755
diff --git a/main.go b/main.go
old mode 100644
new mode 100755
diff --git a/models/Order.go b/models/Order.go
old mode 100644
new mode 100755
diff --git a/models/Product.go b/models/Product.go
old mode 100644
new mode 100755
diff --git a/models/Temperature.go b/models/Temperature.go
old mode 100644
new mode 100755
diff --git a/models/User.go b/models/User.go
old mode 100644
new mode 100755
diff --git a/mydb/ManageDb.go b/mydb/ManageDb.go
old mode 100644
new mode 100755
diff --git a/mydb/initialize.go b/mydb/initialize.go
old mode 100644
new mode 100755
index 4652a74..c4bb4b8
--- a/mydb/initialize.go
+++ b/mydb/initialize.go
@@ -17,8 +17,10 @@ var DB *gorm.DB
func initDatabase() {
- dsn := "root:Skyinno251,@tcp(192.168.2.18:3306)/gorm?charset=utf8mb4&parseTime=True&loc=Local"
+ //dsn := "root:Skyinno251,@tcp(192.168.2.18:3306)/gorm?charset=utf8mb4&parseTime=True&loc=Local"
//dsn := "root:Skyinno251,@tcp(47.242.184.139:3306)/appserver?charset=utf8mb4&parseTime=True&loc=Local"
+ //dsn := "root:Skyinno251,@tcp(localhost:3306)/gorm?charset=utf8mb4&parseTime=True&loc=Local"
+ dsn := "root:Skyinno251,@tcp(192.168.3.29:3306)/gorm?charset=utf8mb4&parseTime=True&loc=Local"
db, err := gorm.Open(mysql.New(mysql.Config{
DSN: dsn, // DSN data source name
@@ -41,16 +43,16 @@ func initDatabase() {
}
// SetMaxIdleConns 用于设置连接池中空闲连接的最大数量。
- sqlDB.SetMaxIdleConns(10)
+ sqlDB.SetMaxIdleConns(5)
// SetMaxOpenConns 设置打开数据库连接的最大数量。
- sqlDB.SetMaxOpenConns(50)
+ sqlDB.SetMaxOpenConns(20)
// SetConnMaxLifetime 设置了连接可复用的最大时间。
sqlDB.SetConnMaxLifetime(time.Minute * 5) // 连接最大生命周期
err = sqlDB.Ping() // 检查连接是否成功建立。如果失败,则返回错误。
if err != nil {
// 处理连接失败的情况。例如,打印错误信息并退出程序。
- log.Println("192.168.2.18:3306连接失败")
+ log.Println("数据库连接失败")
fmt.Println("Connection failed:", err)
return
}
diff --git a/utils/RandomNumber.go b/utils/RandomNumber.go
old mode 100644
new mode 100755