This commit is contained in:
2023-10-13 11:38:35 +08:00
parent 4100e07a28
commit 159fd4ce33
3 changed files with 42 additions and 2 deletions

View File

@@ -3,15 +3,51 @@ package sm
import (
"database/sql"
"fmt"
"net/http"
"os"
"os/exec"
"time"
"ems.agt/lib/log"
"ems.agt/lib/services"
"ems.agt/restagent/config"
_ "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
func DatabaseWhoreBackup() {

View File

@@ -17,6 +17,7 @@ import (
"ems.agt/features/nbi"
"ems.agt/features/pm"
"ems.agt/features/security"
"ems.agt/features/sm"
"ems.agt/features/state"
sysconfig "ems.agt/features/sys_config"
sysdictdata "ems.agt/features/sys_dict_data"
@@ -66,6 +67,9 @@ func init() {
Register("GET", state.CustomUriLicenseInfoAll, state.GetAllLicenseInfoFromNF, 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{
"hasRoles": {"dba"},

View File

@@ -319,8 +319,8 @@ func init() {
pv := flag.Bool("version", false, "print version")
ph := flag.Bool("help", false, "print help")
global.BuildTime = "Wed May 31 18:24:04 CST 2023"
global.GoVer = "go version go1.15.7 linux/arm64"
//global.BuildTime = "Wed May 31 18:24:04 CST 2023"
//global.GoVer = "go version go1.15.7 linux/arm64"
flag.Parse()
if *pv {
fmt.Printf("OMC restagent version: %s\n%s\n%s\n\n", global.Version, global.BuildTime, global.GoVer)