mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-05 01:20:25 +08:00
修改管理界面设置中的时区时同时也会应用到API节点/API节点默认时区为Asia/Shanghai
This commit is contained in:
@@ -206,7 +206,14 @@ Loop:
|
|||||||
|
|
||||||
// CreateHTTPAccessLog 写入单条访问日志
|
// CreateHTTPAccessLog 写入单条访问日志
|
||||||
func (this *HTTPAccessLogDAO) CreateHTTPAccessLog(tx *dbs.Tx, dao *HTTPAccessLogDAO, accessLog *pb.HTTPAccessLog) error {
|
func (this *HTTPAccessLogDAO) CreateHTTPAccessLog(tx *dbs.Tx, dao *HTTPAccessLogDAO, accessLog *pb.HTTPAccessLog) error {
|
||||||
var day = timeutil.FormatTime("Ymd", accessLog.Timestamp)
|
var day = ""
|
||||||
|
// 注意:如果你修改了 TimeISO8601 的逻辑,这里也需要同步修改
|
||||||
|
if len(accessLog.TimeISO8601) > 10 {
|
||||||
|
day = strings.ReplaceAll(accessLog.TimeISO8601[:10], "-", "")
|
||||||
|
} else {
|
||||||
|
timeutil.FormatTime("Ymd", accessLog.Timestamp)
|
||||||
|
}
|
||||||
|
|
||||||
tableDef, err := SharedHTTPAccessLogManager.FindLastTable(dao.Instance, day, true)
|
tableDef, err := SharedHTTPAccessLogManager.FindLastTable(dao.Instance, day, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
|
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/utils"
|
"github.com/TeaOSLab/EdgeAPI/internal/utils"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/zero"
|
"github.com/TeaOSLab/EdgeAPI/internal/zero"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
|
||||||
@@ -13,6 +14,7 @@ import (
|
|||||||
"github.com/iwind/TeaGo/Tea"
|
"github.com/iwind/TeaGo/Tea"
|
||||||
"github.com/iwind/TeaGo/dbs"
|
"github.com/iwind/TeaGo/dbs"
|
||||||
"github.com/iwind/TeaGo/types"
|
"github.com/iwind/TeaGo/types"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SysSettingDAO dbs.DAO
|
type SysSettingDAO dbs.DAO
|
||||||
@@ -211,6 +213,18 @@ func (this *SysSettingDAO) NotifyUpdate(tx *dbs.Tx, code string) error {
|
|||||||
switch code {
|
switch code {
|
||||||
case systemconfigs.SettingCodeAccessLogQueue:
|
case systemconfigs.SettingCodeAccessLogQueue:
|
||||||
accessLogQueueChanged <- zero.New()
|
accessLogQueueChanged <- zero.New()
|
||||||
|
case systemconfigs.SettingCodeAdminUIConfig:
|
||||||
|
// 修改当前时区
|
||||||
|
config, err := this.ReadAdminUIConfig(nil, nil)
|
||||||
|
if err == nil && config != nil {
|
||||||
|
if len(config.TimeZone) == 0 {
|
||||||
|
config.TimeZone = nodeconfigs.DefaultTimeZoneLocation
|
||||||
|
}
|
||||||
|
location, err := time.LoadLocation(config.TimeZone)
|
||||||
|
if err == nil && time.Local != location {
|
||||||
|
time.Local = location
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeAPI/internal/setup"
|
"github.com/TeaOSLab/EdgeAPI/internal/setup"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/utils"
|
"github.com/TeaOSLab/EdgeAPI/internal/utils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/iplibrary"
|
"github.com/TeaOSLab/EdgeCommon/pkg/iplibrary"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||||
"github.com/go-sql-driver/mysql"
|
"github.com/go-sql-driver/mysql"
|
||||||
"github.com/iwind/TeaGo/Tea"
|
"github.com/iwind/TeaGo/Tea"
|
||||||
"github.com/iwind/TeaGo/dbs"
|
"github.com/iwind/TeaGo/dbs"
|
||||||
@@ -132,6 +133,9 @@ func (this *APINode) Start() {
|
|||||||
logs.Println("[API_NODE]notify ready ...")
|
logs.Println("[API_NODE]notify ready ...")
|
||||||
dbs.NotifyReady()
|
dbs.NotifyReady()
|
||||||
|
|
||||||
|
// 设置时区
|
||||||
|
this.setupTimeZone()
|
||||||
|
|
||||||
// 读取配置
|
// 读取配置
|
||||||
this.setProgress("DATABASE", "加载API配置")
|
this.setProgress("DATABASE", "加载API配置")
|
||||||
logs.Println("[API_NODE]reading api config ...")
|
logs.Println("[API_NODE]reading api config ...")
|
||||||
@@ -811,3 +815,17 @@ func (this *APINode) setProgress(name, description string) {
|
|||||||
Description: description,
|
Description: description,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置时区
|
||||||
|
func (this *APINode) setupTimeZone() {
|
||||||
|
config, err := models.SharedSysSettingDAO.ReadAdminUIConfig(nil, nil)
|
||||||
|
if err == nil && config != nil {
|
||||||
|
if len(config.TimeZone) == 0 {
|
||||||
|
config.TimeZone = nodeconfigs.DefaultTimeZoneLocation
|
||||||
|
}
|
||||||
|
location, err := time.LoadLocation(config.TimeZone)
|
||||||
|
if err == nil && time.Local != location {
|
||||||
|
time.Local = location
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user