package sm import ( "net/http" "time" "be.ems/lib/config" "be.ems/lib/log" "be.ems/lib/services" _ "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) }