From f99b8a6d2ec0fc2414b939c3fef4d9338d13fce4 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期三, 12 二月 2025 14:07:07 +0800
Subject: [PATCH] 调整场所分析身份条件

---
 pkg/mysqlx/mysqlx.go |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/pkg/mysqlx/mysqlx.go b/pkg/mysqlx/mysqlx.go
index fc5c043..326b2c5 100644
--- a/pkg/mysqlx/mysqlx.go
+++ b/pkg/mysqlx/mysqlx.go
@@ -1,12 +1,13 @@
 package mysqlx
 
 import (
+	"time"
+
 	"go.uber.org/zap"
 	"gorm.io/driver/mysql"
 	"gorm.io/gorm"
 	"gorm.io/gorm/logger"
 	"gorm.io/gorm/schema"
-	"time"
 )
 
 type Conf struct {
@@ -29,16 +30,21 @@
 		},
 		DisableForeignKeyConstraintWhenMigrating: true,
 	}
-	dbLogger := New(log).LogMode(logger.Info)
-	if !conf.LogMode {
-		dbLogger = dbLogger.LogMode(logger.Silent)
+
+	if log != nil {
+		dbLogger := New(log).LogMode(logger.Info)
+		if !conf.LogMode {
+			dbLogger = dbLogger.LogMode(logger.Silent)
+		}
+
+		gConfig.Logger = dbLogger
 	}
 
-	gConfig.Logger = dbLogger
 	db, err := gorm.Open(mysql.Open(conf.Dsn), gConfig)
 	if err != nil {
 		return err
 	}
+
 	sqlDb, err := db.DB()
 	if err != nil {
 		return err

--
Gitblit v1.8.0