time
This commit is contained in:
@@ -3,15 +3,51 @@ package sm
|
|||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"ems.agt/lib/log"
|
"ems.agt/lib/log"
|
||||||
|
"ems.agt/lib/services"
|
||||||
"ems.agt/restagent/config"
|
"ems.agt/restagent/config"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Get OMC local time
|
||||||
|
UriOMCLocalTime = config.DefaultUriPrefix + "systemManagement/{apiVersion}/elementType/OMC/objectType/time"
|
||||||
|
|
||||||
|
CustomUriOMCLocalTime = config.UriPrefix + "/systemManagement/{apiVersion}/elementType/OMC/objectType/time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type OMCLocalTime struct {
|
||||||
|
Timestamp int64 `json:"timestamp"` // 时间戳 (单位:毫秒)
|
||||||
|
TimeZone int `json:"timeZone"` // 本地时区偏移(单位:秒)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetOMCLocalTime(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log.Debug("GetOMCLocalTime processing... ")
|
||||||
|
|
||||||
|
_, err := services.CheckFrontValidRequest(w, r)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Http request error:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
t := time.Now()
|
||||||
|
_, offset := t.Zone()
|
||||||
|
|
||||||
|
localTime := OMCLocalTime{
|
||||||
|
Timestamp: t.UnixMilli(),
|
||||||
|
TimeZone: offset,
|
||||||
|
}
|
||||||
|
response := services.DataResponse{
|
||||||
|
Data: localTime,
|
||||||
|
}
|
||||||
|
services.ResponseWithJson(w, http.StatusOK, response)
|
||||||
|
}
|
||||||
|
|
||||||
var dbConfig = config.GetYamlConfig().Database
|
var dbConfig = config.GetYamlConfig().Database
|
||||||
|
|
||||||
func DatabaseWhoreBackup() {
|
func DatabaseWhoreBackup() {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
"ems.agt/features/nbi"
|
"ems.agt/features/nbi"
|
||||||
"ems.agt/features/pm"
|
"ems.agt/features/pm"
|
||||||
"ems.agt/features/security"
|
"ems.agt/features/security"
|
||||||
|
"ems.agt/features/sm"
|
||||||
"ems.agt/features/state"
|
"ems.agt/features/state"
|
||||||
sysconfig "ems.agt/features/sys_config"
|
sysconfig "ems.agt/features/sys_config"
|
||||||
sysdictdata "ems.agt/features/sys_dict_data"
|
sysdictdata "ems.agt/features/sys_dict_data"
|
||||||
@@ -66,6 +67,9 @@ func init() {
|
|||||||
Register("GET", state.CustomUriLicenseInfoAll, state.GetAllLicenseInfoFromNF, nil)
|
Register("GET", state.CustomUriLicenseInfoAll, state.GetAllLicenseInfoFromNF, nil)
|
||||||
Register("GET", state.CustomUriLicenseInfoOne, state.GetOneLicenseInfoFromNF, nil)
|
Register("GET", state.CustomUriLicenseInfoOne, state.GetOneLicenseInfoFromNF, nil)
|
||||||
|
|
||||||
|
Register("GET", sm.UriOMCLocalTime, sm.GetOMCLocalTime, nil)
|
||||||
|
Register("GET", sm.CustomUriOMCLocalTime, sm.GetOMCLocalTime, nil)
|
||||||
|
|
||||||
// 数据库直连操作权限
|
// 数据库直连操作权限
|
||||||
selectPermission := midware.Authorize(map[string][]string{
|
selectPermission := midware.Authorize(map[string][]string{
|
||||||
"hasRoles": {"dba"},
|
"hasRoles": {"dba"},
|
||||||
|
|||||||
@@ -319,8 +319,8 @@ func init() {
|
|||||||
pv := flag.Bool("version", false, "print version")
|
pv := flag.Bool("version", false, "print version")
|
||||||
ph := flag.Bool("help", false, "print help")
|
ph := flag.Bool("help", false, "print help")
|
||||||
|
|
||||||
global.BuildTime = "Wed May 31 18:24:04 CST 2023"
|
//global.BuildTime = "Wed May 31 18:24:04 CST 2023"
|
||||||
global.GoVer = "go version go1.15.7 linux/arm64"
|
//global.GoVer = "go version go1.15.7 linux/arm64"
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if *pv {
|
if *pv {
|
||||||
fmt.Printf("OMC restagent version: %s\n%s\n%s\n\n", global.Version, global.BuildTime, global.GoVer)
|
fmt.Printf("OMC restagent version: %s\n%s\n%s\n\n", global.Version, global.BuildTime, global.GoVer)
|
||||||
|
|||||||
Reference in New Issue
Block a user