fix: time-zone issue, localhost issue

This commit is contained in:
2024-04-01 17:22:26 +08:00
parent 83cd653545
commit 954493a5f2
20 changed files with 38 additions and 15 deletions

View File

@@ -68,7 +68,7 @@ func NewYamlConfig() YamlConfig {
return YamlConfig{
Database: DbConfig{
Type: "mysql",
ConnParam: "charset=utf8mb4&collation=utf8mb4_general_ci&loc=Local",
ConnParam: "charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True",
},
}
}

View File

@@ -51,12 +51,14 @@ func initDbClient() error {
//}
// defer dbClient.xEngine.Close() // 退出后关闭
if dbClient.IsShowSQL == true {
if dbClient.IsShowSQL {
dbClient.xEngine.ShowSQL(true)
}
dbClient.xEngine.SetConnMaxLifetime(dbClient.dbConnMaxLifetime)
dbClient.xEngine.SetMaxIdleConns(dbClient.dbMaxIdleConns)
dbClient.xEngine.SetMaxOpenConns(dbClient.dbMaxOpenConns)
dbClient.xEngine.DatabaseTZ = time.Local // 必须
dbClient.xEngine.TZLocation = time.Local // 必须
return nil
}
@@ -447,7 +449,7 @@ func XormInsertTalbeOne(tbInfo interface{}) (int64, error) {
}
func XormGetDataBySQL(sql string) (*[]map[string]string, error) {
log.Debug("XormGetDataBySQL processing... ")
//log.Debug("XormGetDataBySQL processing... ")
rows := make([]map[string]string, 0)
rows, err := dbClient.xEngine.QueryString(sql)

View File

@@ -25,6 +25,7 @@ database:
host: 127.0.0.1
port: 33066
name: omc_db
connParam: charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True
backup: d:/local.git/be.ems/restagent/database
# northbound interface, cm/pm