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