feat: 网元_参数配置可用属性值缓存并支持数据修改的功能接口
This commit is contained in:
@@ -13,6 +13,9 @@ type INeConfig interface {
|
||||
// SelectNeConfigByNeType 查询网元类型参数配置
|
||||
SelectNeConfigByNeType(neType string) []model.NeConfig
|
||||
|
||||
// SelectNeConfigByNeTypeAndParamName 查询网元类型参数配置By参数名
|
||||
SelectNeConfigByNeTypeAndParamName(neType, paramName string) model.NeConfig
|
||||
|
||||
// SelectNeHostPage 分页查询列表数据
|
||||
SelectPage(query map[string]any) map[string]any
|
||||
|
||||
|
||||
@@ -37,11 +37,11 @@ func (r *NeConfigImpl) RefreshByNeTypeAndNeID(neType string) []model.NeConfig {
|
||||
}
|
||||
}
|
||||
for k, v := range neConfigGroup {
|
||||
key := fmt.Sprintf("%sparam_config:%s", cachekey.NE_DATA_KEY, strings.ToUpper(k))
|
||||
key := fmt.Sprintf("%sNeConfig:%s", cachekey.NE_DATA_KEY, strings.ToUpper(k))
|
||||
redis.Del("", key)
|
||||
if len(v) > 0 {
|
||||
for i, item := range v {
|
||||
if err := json.Unmarshal([]byte(item.ParamJSONStr), &item.ParamData); err != nil {
|
||||
if err := json.Unmarshal([]byte(item.ParamJson), &item.ParamData); err != nil {
|
||||
continue
|
||||
}
|
||||
v[i] = item
|
||||
@@ -54,14 +54,14 @@ func (r *NeConfigImpl) RefreshByNeTypeAndNeID(neType string) []model.NeConfig {
|
||||
return neConfigList
|
||||
}
|
||||
// 单个
|
||||
key := fmt.Sprintf("%sparam_config:%s", cachekey.NE_DATA_KEY, strings.ToUpper(neType))
|
||||
key := fmt.Sprintf("%sNeConfig:%s", cachekey.NE_DATA_KEY, strings.ToUpper(neType))
|
||||
redis.Del("", key)
|
||||
neConfigList := r.neConfigRepository.SelectList(model.NeConfig{
|
||||
NeType: neType,
|
||||
})
|
||||
if len(neConfigList) > 0 {
|
||||
for i, v := range neConfigList {
|
||||
if err := json.Unmarshal([]byte(v.ParamJSONStr), &v.ParamData); err != nil {
|
||||
if err := json.Unmarshal([]byte(v.ParamJson), &v.ParamData); err != nil {
|
||||
continue
|
||||
}
|
||||
neConfigList[i] = v
|
||||
@@ -74,9 +74,9 @@ func (r *NeConfigImpl) RefreshByNeTypeAndNeID(neType string) []model.NeConfig {
|
||||
|
||||
// ClearNeCacheByNeType 清除网元类型参数配置缓存
|
||||
func (r *NeConfigImpl) ClearNeCacheByNeType(neType string) bool {
|
||||
key := fmt.Sprintf("%sparam_config:%s", cachekey.NE_DATA_KEY, neType)
|
||||
key := fmt.Sprintf("%sNeConfig:%s", cachekey.NE_DATA_KEY, neType)
|
||||
if neType == "*" {
|
||||
key = fmt.Sprintf("%sparam_config:*", cachekey.NE_DATA_KEY)
|
||||
key = fmt.Sprintf("%sNeConfig:*", cachekey.NE_DATA_KEY)
|
||||
}
|
||||
keys, err := redis.GetKeys("", key)
|
||||
if err != nil {
|
||||
@@ -89,7 +89,7 @@ func (r *NeConfigImpl) ClearNeCacheByNeType(neType string) bool {
|
||||
// SelectNeConfigByNeType 查询网元类型参数配置
|
||||
func (r *NeConfigImpl) SelectNeConfigByNeType(neType string) []model.NeConfig {
|
||||
var neConfigList []model.NeConfig
|
||||
key := fmt.Sprintf("%sparam_config:%s", cachekey.NE_DATA_KEY, strings.ToUpper(neType))
|
||||
key := fmt.Sprintf("%sNeConfig:%s", cachekey.NE_DATA_KEY, strings.ToUpper(neType))
|
||||
jsonStr, _ := redis.Get("", key)
|
||||
if len(jsonStr) > 7 {
|
||||
err := json.Unmarshal([]byte(jsonStr), &neConfigList)
|
||||
@@ -102,6 +102,19 @@ func (r *NeConfigImpl) SelectNeConfigByNeType(neType string) []model.NeConfig {
|
||||
return neConfigList
|
||||
}
|
||||
|
||||
// SelectNeConfigByNeTypeAndParamName 查询网元类型参数配置By参数名
|
||||
func (r *NeConfigImpl) SelectNeConfigByNeTypeAndParamName(neType, paramName string) model.NeConfig {
|
||||
neConfigList := r.SelectNeConfigByNeType(neType)
|
||||
var neConfig model.NeConfig
|
||||
for _, v := range neConfigList {
|
||||
if v.ParamName == paramName {
|
||||
neConfig = v
|
||||
break
|
||||
}
|
||||
}
|
||||
return neConfig
|
||||
}
|
||||
|
||||
// SelectNeHostPage 分页查询列表数据
|
||||
func (r *NeConfigImpl) SelectPage(query map[string]any) map[string]any {
|
||||
return r.neConfigRepository.SelectPage(query)
|
||||
|
||||
Reference in New Issue
Block a user