fix: time-zone issue, localhost issue
This commit is contained in:
@@ -45,7 +45,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",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,6 @@ database:
|
||||
host: 172.25.97.150
|
||||
port: 33066
|
||||
name: omc_db
|
||||
connParam: charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ database:
|
||||
host: 127.0.0.1
|
||||
port: 33066
|
||||
name: omc_db
|
||||
backup: /usr/local/omc/database
|
||||
connParam: charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True
|
||||
|
||||
# northbound interface, cm/pm
|
||||
# duration(day): saved days
|
||||
|
||||
@@ -45,6 +45,7 @@ database:
|
||||
host: 127.0.0.1
|
||||
port: 33066
|
||||
name: omc_db
|
||||
connParam: charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True
|
||||
backup: /usr/local/omc/database
|
||||
|
||||
# Redis data cache
|
||||
|
||||
@@ -37,6 +37,7 @@ database:
|
||||
host: 127.0.0.1
|
||||
port: 33066
|
||||
name: omc_db
|
||||
connParam: charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True
|
||||
|
||||
omc:
|
||||
httpUri: http://127.0.0.1:33030
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -86,6 +86,7 @@ func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName, dbParam st
|
||||
DbClient.dbConnMaxLifetime = 0
|
||||
DbClient.dbMaxIdleConns = 0
|
||||
DbClient.dbMaxOpenConns = 0
|
||||
|
||||
if log.GetLevel() == log.LOG_TRACE {
|
||||
DbClient.IsShowSQL = true
|
||||
}
|
||||
@@ -100,6 +101,8 @@ func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName, dbParam st
|
||||
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 // 必须
|
||||
if DbClient.IsShowSQL {
|
||||
//DbClient.XEngine.SetLogger(&log.Elogger)
|
||||
DbClient.XEngine.ShowSQL(true)
|
||||
@@ -301,7 +304,7 @@ func ExtDatabaseGetData(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if s != "" {
|
||||
// err = XEngine.SQL(s).Find(&rows)
|
||||
if IsQuerySQL(s) == false {
|
||||
if !IsQuerySQL(s) {
|
||||
services.ResponseNotAcceptable406QuerySQLError(w)
|
||||
return
|
||||
}
|
||||
@@ -561,7 +564,7 @@ func DatabaseGetData(w http.ResponseWriter, r *http.Request) {
|
||||
log.Debug("querySQL:", querySQL)
|
||||
rows, err = DbClient.XEngine.QueryInterface(querySQL)
|
||||
if err != nil {
|
||||
log.Error("SQL failed:", err)
|
||||
log.Error("QueryInterface failed:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -172,6 +172,8 @@ func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName, dbParam st
|
||||
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 // 必须
|
||||
if DbClient.IsShowSQL {
|
||||
DbClient.XEngine.ShowSQL(true)
|
||||
}
|
||||
|
||||
@@ -71,6 +71,8 @@ func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName, dbParam st
|
||||
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 // 必须
|
||||
if DbClient.IsShowSQL {
|
||||
DbClient.XEngine.ShowSQL(true)
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ func SqlClient(w http.ResponseWriter, r *http.Request) {
|
||||
if isConnet == "connet" && dborm.DbClient.XEngine == nil {
|
||||
conf := config.GetYamlConfig()
|
||||
err := dborm.InitDbClient(conf.Database.Type, conf.Database.User, conf.Database.Password,
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name)
|
||||
conf.Database.Host, conf.Database.Port, conf.Database.Name, conf.Database.ConnParam)
|
||||
if err != nil {
|
||||
fmt.Println("dborm.initDbClient err:", err)
|
||||
services.ResponseInternalServerError500DatabaseOperationFailed(w)
|
||||
|
||||
@@ -117,6 +117,8 @@ func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName, dbParam st
|
||||
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 // 必须
|
||||
if DbClient.IsShowSQL {
|
||||
DbClient.XEngine.ShowSQL(true)
|
||||
}
|
||||
|
||||
@@ -857,7 +857,8 @@ func GetStateFromNFOld(w http.ResponseWriter, r *http.Request) {
|
||||
case "all":
|
||||
// query all NFs
|
||||
// create rest client
|
||||
restHostPort := fmt.Sprintf("http://127.0.0.1:%d", config.GetYamlConfig().Rest[0].Port)
|
||||
|
||||
restHostPort := config.GetOMCHostUrl()
|
||||
getNeInfoPattern := fmt.Sprintf(config.DefaultUriPrefix+"/databaseManagement/v1/elementType/%s/objectType/ne_info",
|
||||
config.GetYamlConfig().Database.Name)
|
||||
getNeInfoURI := restHostPort + getNeInfoPattern + "?WHERE=status+in+('0','3')"
|
||||
@@ -878,7 +879,7 @@ func GetStateFromNFOld(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
neList, _ = dborm.XormParseResult(resp.Body())
|
||||
default:
|
||||
restHostPort := fmt.Sprintf("http://127.0.0.1:%d", config.GetYamlConfig().Rest[0].Port)
|
||||
restHostPort := config.GetOMCHostUrl()
|
||||
getNeInfoPattern := fmt.Sprintf(config.DefaultUriPrefix+"/databaseManagement/v1/elementType/%s/objectType/ne_info",
|
||||
config.GetYamlConfig().Database.Name)
|
||||
getNeInfoURI := restHostPort + getNeInfoPattern
|
||||
|
||||
@@ -66,9 +66,12 @@ func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName, dbParam st
|
||||
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 // 必须
|
||||
if DbClient.IsShowSQL {
|
||||
DbClient.XEngine.ShowSQL(true)
|
||||
}
|
||||
|
||||
xEngine = DbClient.XEngine
|
||||
|
||||
return nil
|
||||
@@ -1423,7 +1426,7 @@ type NeVersion struct {
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
@@ -209,7 +209,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",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,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
|
||||
|
||||
# Redis 缓存数据,数据源声明全小写
|
||||
|
||||
@@ -202,7 +202,8 @@ func (s *BarProcessor) Execute(data any) (any, error) {
|
||||
|
||||
var response *resty.Response
|
||||
requestURI := fmt.Sprintf("/api/rest/faultManagement/v1/elementType/%s/objectType/alarms", ne.NeType)
|
||||
restHost := fmt.Sprintf("http://127.0.0.1:%d", config.GetYamlConfig().Rest[0].Port)
|
||||
//restHost := fmt.Sprintf("http://127.0.0.1:%d", config.GetYamlConfig().Rest[0].Port)
|
||||
restHost := config.GetOMCHostUrl()
|
||||
requestURL := fmt.Sprintf("%s%s", restHost, requestURI)
|
||||
log.Debug("requestURL: POST ", requestURL)
|
||||
response, err = client.R().
|
||||
@@ -269,7 +270,8 @@ func (s *BarProcessor) Execute(data any) (any, error) {
|
||||
|
||||
var response *resty.Response
|
||||
requestURI := fmt.Sprintf("/api/rest/faultManagement/v1/elementType/%s/objectType/alarms", ne.NeType)
|
||||
restHost := fmt.Sprintf("http://127.0.0.1:%d", config.GetYamlConfig().Rest[0].Port)
|
||||
//restHost := fmt.Sprintf("http://127.0.0.1:%d", config.GetYamlConfig().Rest[0].Port)
|
||||
restHost := config.GetOMCHostUrl()
|
||||
requestURL := fmt.Sprintf("%s%s", restHost, requestURI)
|
||||
log.Debug("requestURL: POST ", requestURL)
|
||||
response, err = client.R().
|
||||
|
||||
@@ -65,7 +65,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",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ database:
|
||||
host: 127.0.0.1
|
||||
port: 33066
|
||||
name: omc_db
|
||||
connParam: charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&interpolateParams=True
|
||||
|
||||
omc:
|
||||
httpUri: http://127.0.0.1:3040
|
||||
|
||||
Reference in New Issue
Block a user