feat: 网元信息支持通过rmUID查询网元信息,程序启动清除并重新加载缓存信息
This commit is contained in:
@@ -323,4 +323,5 @@ func Setup(router *gin.Engine) {
|
||||
func InitLoad() {
|
||||
// 启动时,清除缓存-网元类型
|
||||
service.NewNeInfoImpl.ClearNeCacheByNeType("*")
|
||||
service.NewNeInfoImpl.SelectNeInfoByRmuid("")
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ type INeInfo interface {
|
||||
// ClearNeCacheByNeType 清除网元类型缓存
|
||||
ClearNeCacheByNeType(neType string) bool
|
||||
|
||||
// SelectNeInfoByRmuid 通过rmUID查询网元信息
|
||||
SelectNeInfoByRmuid(rmUid string) model.NeInfo
|
||||
|
||||
// SelectPage 根据条件分页查询
|
||||
//
|
||||
// bandStatus 带状态信息
|
||||
|
||||
@@ -73,6 +73,37 @@ func (r *NeInfoImpl) ClearNeCacheByNeType(neType string) bool {
|
||||
return delOk
|
||||
}
|
||||
|
||||
// SelectNeInfoByRmuid 通过rmUID查询网元信息
|
||||
func (r *NeInfoImpl) SelectNeInfoByRmuid(rmUid string) model.NeInfo {
|
||||
var neInfo model.NeInfo
|
||||
cacheKeys, _ := redis.GetKeys("", cachekey.NE_KEY+"*")
|
||||
if len(cacheKeys) > 0 {
|
||||
for _, key := range cacheKeys {
|
||||
var v model.NeInfo
|
||||
jsonStr, _ := redis.Get("", key)
|
||||
if len(jsonStr) > 7 {
|
||||
json.Unmarshal([]byte(jsonStr), &v)
|
||||
}
|
||||
if v.RmUID == rmUid {
|
||||
neInfo = v
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
neInfos := r.SelectList(neInfo, false)
|
||||
for _, v := range neInfos {
|
||||
key := fmt.Sprintf("%s%s:%s", cachekey.NE_KEY, v.NeType, v.NeId)
|
||||
redis.Del("", key)
|
||||
values, _ := json.Marshal(v)
|
||||
redis.Set("", key, string(values))
|
||||
if v.RmUID == rmUid {
|
||||
neInfo = v
|
||||
}
|
||||
}
|
||||
}
|
||||
return neInfo
|
||||
}
|
||||
|
||||
// SelectPage 根据条件分页查询
|
||||
//
|
||||
// bandStatus 带状态信息
|
||||
|
||||
Reference in New Issue
Block a user