节点配置增加产品信息

This commit is contained in:
GoEdgeLab
2022-01-09 10:44:17 +08:00
parent cd25e08962
commit c493350c32
2 changed files with 43 additions and 0 deletions

View File

@@ -917,6 +917,18 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64, cacheMap *utils
config.MetricItems = metricItems config.MetricItems = metricItems
// 产品
adminUIConfig, err := SharedSysSettingDAO.ReadAdminUIConfig(tx, cacheMap)
if err != nil {
return nil, err
}
if adminUIConfig != nil {
config.ProductConfig = &nodeconfigs.ProductConfig{
Name: adminUIConfig.ProductName,
Version: adminUIConfig.Version,
}
}
return config, nil return config, nil
} }

View File

@@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
"github.com/TeaOSLab/EdgeAPI/internal/zero" "github.com/TeaOSLab/EdgeAPI/internal/zero"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
@@ -157,6 +158,36 @@ func (this *SysSettingDAO) ReadUserServerConfig(tx *dbs.Tx) (*userconfigs.UserSe
return config, nil return config, nil
} }
// ReadAdminUIConfig 读取管理员界面配置
func (this *SysSettingDAO) ReadAdminUIConfig(tx *dbs.Tx, cacheMap *utils.CacheMap) (*systemconfigs.AdminUIConfig, error) {
var cacheKey = this.Table + ":ReadAdminUIConfig"
if cacheMap != nil {
cache, ok := cacheMap.Get(cacheKey)
if ok && cache != nil {
return cache.(*systemconfigs.AdminUIConfig), nil
}
}
valueJSON, err := this.ReadSetting(tx, systemconfigs.SettingCodeAdminUIConfig)
if err != nil {
return nil, err
}
if len(valueJSON) > 0 {
var config = &systemconfigs.AdminUIConfig{}
err = json.Unmarshal(valueJSON, config)
if err != nil {
return nil, err
}
if cacheMap != nil {
cacheMap.Put(cacheKey, config)
}
return config, nil
}
return &systemconfigs.AdminUIConfig{}, nil
}
// NotifyUpdate 通知更改 // NotifyUpdate 通知更改
func (this *SysSettingDAO) NotifyUpdate(tx *dbs.Tx, code string) error { func (this *SysSettingDAO) NotifyUpdate(tx *dbs.Tx, code string) error {
switch code { switch code {