fix: 网元信息操作同步更新主机
This commit is contained in:
@@ -175,11 +175,34 @@ func (r *NeInfoImpl) SelectById(infoId string, bandHost bool) model.NeInfo {
|
||||
|
||||
// Insert 新增信息
|
||||
func (r *NeInfoImpl) Insert(neInfo model.NeInfo) string {
|
||||
// 主机信息新增
|
||||
if neInfo.Hosts != nil {
|
||||
var hostIDs []string
|
||||
for _, host := range neInfo.Hosts {
|
||||
host.Title = fmt.Sprintf("%s_%s_%d", strings.ToUpper(neInfo.NeType), neInfo.NeId, host.Port)
|
||||
host.GroupID = "1"
|
||||
hostId := r.neHostRepository.Insert(host)
|
||||
if hostId != "" {
|
||||
hostIDs = append(hostIDs, hostId)
|
||||
}
|
||||
}
|
||||
neInfo.HostIDs = strings.Join(hostIDs, ",")
|
||||
}
|
||||
return r.neInfoRepository.Insert(neInfo)
|
||||
}
|
||||
|
||||
// Update 修改信息
|
||||
func (r *NeInfoImpl) Update(neInfo model.NeInfo) int64 {
|
||||
// 主机信息更新
|
||||
if neInfo.Hosts != nil {
|
||||
for _, host := range neInfo.Hosts {
|
||||
if host.HostID != "" {
|
||||
host.Title = fmt.Sprintf("%s_%s_%d", strings.ToUpper(neInfo.NeType), neInfo.NeId, host.Port)
|
||||
host.GroupID = "1"
|
||||
r.neHostRepository.Update(host)
|
||||
}
|
||||
}
|
||||
}
|
||||
return r.neInfoRepository.Update(neInfo)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user