Sfoglia il codice sorgente

fix(waf): 处理网关 IP 获取时的续费逻辑

- 在获取网关 IP列表为空时,增加实例续费检查
- 如果实例已过期且未续费,返回错误提示用户续费
- 续费逻辑通过调用 host.CheckExpired 方法实现
fusu 2 settimane fa
parent
commit
bc35fba553
1 ha cambiato i file con 9 aggiunte e 0 eliminazioni
  1. 9 0
      internal/service/api/waf/gatewayip.go

+ 9 - 0
internal/service/api/waf/gatewayip.go

@@ -3,6 +3,7 @@ package waf
 import (
 	"context"
 	"encoding/json"
+	"fmt"
 	v1 "github.com/go-nunu/nunu-layout-advanced/api/v1"
 	"github.com/go-nunu/nunu-layout-advanced/internal/model"
 	"github.com/go-nunu/nunu-layout-advanced/internal/repository/api/waf"
@@ -93,6 +94,14 @@ func (s *gatewayipService) GetGatewayipOnlyIpByHostIdAll(ctx context.Context, ho
 	}
 
 	if len(gatewayIps) == 0 {
+		expire, err := s.host.CheckExpired(ctx, uid, hostId)
+		if err != nil {
+			return nil, err
+		}
+		if !expire {
+			return nil, fmt.Errorf("请续费该实例")
+		}
+
 		err = s.AddIpWhereHostIdNull(ctx, hostId,uid)
 		if err != nil {
 			return nil, err