feat: 网元版本支持通过网元类型和网元ID查询

This commit is contained in:
TsMask
2024-03-18 11:26:40 +08:00
parent f1e2aa59dc
commit e990676fca
2 changed files with 18 additions and 3 deletions

View File

@@ -22,6 +22,9 @@ type INeVersion interface {
// DeleteByIds 批量删除信息
DeleteByIds(ids []string) (int64, error)
// SelectByTypeAndID 通过网元类型和网元ID查询
SelectByTypeAndID(neType, neId string) model.NeVersion
// CheckUniqueTypeAndID 校验网元类型和网元ID是否唯一
CheckUniqueTypeAndID(neType, neId, id string) bool
}

View File

@@ -33,9 +33,9 @@ func (r *NeVersionImpl) SelectById(id string) model.NeVersion {
if id == "" {
return model.NeVersion{}
}
neHosts := r.neVersionRepository.SelectByIds([]string{id})
if len(neHosts) > 0 {
return neHosts[0]
neVersions := r.neVersionRepository.SelectByIds([]string{id})
if len(neVersions) > 0 {
return neVersions[0]
}
return model.NeVersion{}
}
@@ -66,6 +66,18 @@ func (r *NeVersionImpl) DeleteByIds(ids []string) (int64, error) {
return 0, fmt.Errorf("delete fail")
}
// SelectByTypeAndID 通过网元类型和网元ID查询
func (r *NeVersionImpl) SelectByTypeAndID(neType, neId string) model.NeVersion {
neVersions := r.neVersionRepository.SelectList(model.NeVersion{
NeType: neType,
NeId: neId,
})
if len(neVersions) > 0 {
return neVersions[0]
}
return model.NeVersion{}
}
// CheckUniqueTypeAndID 校验网元类型和网元ID是否唯一
func (r *NeVersionImpl) CheckUniqueTypeAndID(neType, neId, id string) bool {
uniqueId := r.neVersionRepository.CheckUniqueTypeAndID(model.NeVersion{