fix: 主机信息删除时禁止删除网元组

This commit is contained in:
TsMask
2025-05-16 17:43:03 +08:00
parent 82db21fffd
commit b325b4d5ac
3 changed files with 5 additions and 4 deletions

View File

@@ -169,7 +169,7 @@ func (s NeHostController) Remove(c *gin.Context) {
ids = append(ids, parse.Number(v)) ids = append(ids, parse.Number(v))
} }
rows, err := s.neHostService.DeleteByIds(ids) rows, err := s.neHostService.DeleteByIds(ids, true)
if err != nil { if err != nil {
c.JSON(200, resp.ErrMsg(i18n.TKey(language, err.Error()))) c.JSON(200, resp.ErrMsg(i18n.TKey(language, err.Error())))
return return

View File

@@ -137,7 +137,8 @@ func (r NeHost) Update(neHost model.NeHost) int64 {
} }
// DeleteByIds 批量删除网元主机连接信息 // DeleteByIds 批量删除网元主机连接信息
func (r NeHost) DeleteByIds(hostIds []int64) (int64, error) { // checkNeHost 是否检查网元主机
func (r NeHost) DeleteByIds(hostIds []int64, checkNeHost bool) (int64, error) {
// 检查是否存在 // 检查是否存在
ids := r.neHostRepository.SelectByIds(hostIds) ids := r.neHostRepository.SelectByIds(hostIds)
if len(ids) <= 0 { if len(ids) <= 0 {
@@ -145,7 +146,7 @@ func (r NeHost) DeleteByIds(hostIds []int64) (int64, error) {
} }
for _, v := range ids { for _, v := range ids {
if v.GroupID == "1" { if v.GroupID == "1" && checkNeHost {
// 主机信息操作【%s】失败禁止操作网元 // 主机信息操作【%s】失败禁止操作网元
return 0, fmt.Errorf("neHost.banNE") return 0, fmt.Errorf("neHost.banNE")
} }

View File

@@ -316,7 +316,7 @@ func (r NeInfo) DeleteByIds(ids []int64) (int64, error) {
for _, hostId := range arr { for _, hostId := range arr {
hostIds = append(hostIds, parse.Number(hostId)) hostIds = append(hostIds, parse.Number(hostId))
} }
r.neHostService.DeleteByIds(hostIds) r.neHostService.DeleteByIds(hostIds, false)
} }
// 删除License // 删除License
neLicense := NewNeLicense.FindByNeTypeAndNeID(v.NeType, v.NeId) neLicense := NewNeLicense.FindByNeTypeAndNeID(v.NeType, v.NeId)