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

This commit is contained in:
TsMask
2025-03-26 16:19:59 +08:00
parent 9ffb07bbfd
commit 94ed370efa

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"
@@ -207,18 +208,23 @@ type NeInfo struct {
func XormGetNeInfo(neType string, neId string) (*NeInfo, error) { func XormGetNeInfo(neType string, neId string) (*NeInfo, error) {
log.Debug("XormGetNeInfo processing... ") log.Debug("XormGetNeInfo processing... ")
neInfox := neService.NewNeInfo.FindByNeTypeAndNeID(neType, neId)
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
} }