- 将判断条件反转,确保在 gatewayIp 为 nil时执行添加操作 - 移除了多余的 return 语句,简化了代码结构
@@ -392,12 +392,11 @@ func (s *globalLimitService) EditGlobalLimit(ctx context.Context, req v1.GlobalL
if err != nil {
return err
}
- if gatewayIp != nil {
+ if gatewayIp == nil {
err = s.gatewayIp.AddIpWhereHostIdNull(ctx, int64(req.HostId), int64(req.Uid))
return fmt.Errorf("获取网关组失败: %w", err)
- return nil