fix: 处理兼容旧网元查询函数

This commit is contained in:
TsMask
2025-03-24 19:25:29 +08:00
parent b7b994db4d
commit 04ca8accaf

View File

@@ -11,6 +11,7 @@ import (
"strings" "strings"
"be.ems/lib/log" "be.ems/lib/log"
neService "be.ems/src/modules/network_element/service"
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"
"xorm.io/xorm" "xorm.io/xorm"
@@ -206,19 +207,24 @@ type NeInfo struct {
} }
func XormGetNeInfo(neType string, neId string) (*NeInfo, error) { func XormGetNeInfo(neType string, neId string) (*NeInfo, error) {
neInfox := neService.NewNeInfo.FindByNeTypeAndNeID(neType, neId)
log.Debug("XormGetNeInfo processing... ") log.Debug("XormGetNeInfo processing... ")
neInfo := new(NeInfo) neInfo := new(NeInfo)
has, err := xEngine.Where("ne_type=? and ne_id=?", strings.ToUpper(neType), neId).Get(neInfo) neInfo.NeType = neType
if err != nil { neInfo.NeId = neId
log.Error("Failed to get table ne_info from database:", err) neInfo.RmUID = neInfox.RmUID
return nil, err neInfo.NeName = neInfox.NeName
} else if !has { neInfo.Ip = neInfox.IP
log.Infof("Not found ne_info from database, neType=%s, neId=%s", neType, neId) neInfo.Port = fmt.Sprint(neInfox.Port)
return nil, nil neInfo.PvFlag = neInfox.PvFlag
} neInfo.NeAddress = neInfox.NeAddress
neInfo.Province = neInfox.Province
neInfo.VendorName = neInfox.VendorName
neInfo.Dn = neInfox.Dn
neInfo.Status = int(neInfox.Status)
neInfo.UpdateTime = time.UnixMilli(neInfox.UpdateTime)
log.Debug("NE Info:", neInfo)
return neInfo, nil return neInfo, nil
} }