feat: 网元信息查询带主机信息查询函数
This commit is contained in:
@@ -24,7 +24,9 @@ type INeInfo interface {
|
||||
SelectList(ne model.NeInfo, bandStatus bool) []model.NeInfo
|
||||
|
||||
// SelectByIds 通过ID查询
|
||||
SelectById(infoId string) model.NeInfo
|
||||
//
|
||||
// bandStatus 带主机信息
|
||||
SelectById(infoId string, bandHost bool) model.NeInfo
|
||||
|
||||
// Insert 新增信息
|
||||
Insert(neInfo model.NeInfo) string
|
||||
|
||||
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"ems.agt/src/framework/constants/cachekey"
|
||||
"ems.agt/src/framework/redis"
|
||||
@@ -13,12 +14,15 @@ import (
|
||||
// 实例化服务层 NeInfoImpl 结构体
|
||||
var NewNeInfoImpl = &NeInfoImpl{
|
||||
neInfoRepository: repository.NewNeInfoImpl,
|
||||
neHostRepository: repository.NewNeHostImpl,
|
||||
}
|
||||
|
||||
// 网元信息 服务层处理
|
||||
type NeInfoImpl struct {
|
||||
// 网元信息数据信息
|
||||
neInfoRepository repository.INeInfo
|
||||
// 网元主机连接表
|
||||
neHostRepository repository.INeHost
|
||||
}
|
||||
|
||||
// SelectNeInfoByNeTypeAndNeID 通过ne_type和ne_id查询网元信息
|
||||
@@ -123,13 +127,20 @@ func (r *NeInfoImpl) SelectList(ne model.NeInfo, bandStatus bool) []model.NeInfo
|
||||
}
|
||||
|
||||
// SelectByIds 通过ID查询
|
||||
func (r *NeInfoImpl) SelectById(infoId string) model.NeInfo {
|
||||
//
|
||||
// bandStatus 带主机信息
|
||||
func (r *NeInfoImpl) SelectById(infoId string, bandHost bool) model.NeInfo {
|
||||
if infoId == "" {
|
||||
return model.NeInfo{}
|
||||
}
|
||||
neInfos := r.neInfoRepository.SelectByIds([]string{infoId})
|
||||
if len(neInfos) > 0 {
|
||||
return neInfos[0]
|
||||
neInfo := neInfos[0]
|
||||
// 带主机信息
|
||||
if neInfo.HostIDs != "" && bandHost {
|
||||
neInfo.Hosts = r.neHostRepository.SelectByIds(strings.Split(neInfo.HostIDs, ","))
|
||||
}
|
||||
return neInfo
|
||||
}
|
||||
return model.NeInfo{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user