Merge remote-tracking branch 'origin/main' into multi-tenant

This commit is contained in:
TsMask
2025-01-22 19:43:58 +08:00
17 changed files with 353 additions and 23 deletions

View File

@@ -12,6 +12,7 @@ import (
"be.ems/src/framework/logger"
"be.ems/src/framework/redis"
"be.ems/src/framework/telnet"
"be.ems/src/framework/utils/generate"
"be.ems/src/framework/utils/parse"
"be.ems/src/framework/utils/ssh"
neFetchlink "be.ems/src/modules/network_element/fetch_link"
@@ -243,9 +244,10 @@ func (r *NeInfo) SelectById(infoId string, bandHost bool) model.NeInfo {
func (r *NeInfo) Insert(neInfo model.NeInfo) string {
// 主机信息新增
if neInfo.Hosts != nil {
uuid := generate.Code(4)
var hostIDs []string
for _, host := range neInfo.Hosts {
host.Title = fmt.Sprintf("%s_%s_%d", strings.ToUpper(neInfo.NeType), neInfo.NeId, host.Port)
host.Title = neInfo.NeName + "_" + uuid
host.GroupID = "1"
host.CreateBy = neInfo.CreateBy
hostId := NewNeHost.Insert(host)
@@ -268,9 +270,10 @@ func (r *NeInfo) Insert(neInfo model.NeInfo) string {
func (r *NeInfo) Update(neInfo model.NeInfo) int64 {
// 主机信息更新
if neInfo.Hosts != nil {
uuid := generate.Code(4)
for _, host := range neInfo.Hosts {
if host.HostID != "" {
host.Title = fmt.Sprintf("%s_%s_%d", strings.ToUpper(neInfo.NeType), neInfo.NeId, host.Port)
host.Title = neInfo.NeName + "_" + uuid
host.GroupID = "1"
host.UpdateBy = neInfo.UpdateBy
NewNeHost.Update(host)