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