Преглед на файлове

refactor(internal): 重构 WAF 任务处理

- 替换 GateWayGroupIpRepository 为 GatewayipRepository
- 更新全局限制重置逻辑,使用 CleanIPByHostId 方法
fusu преди 3 седмици
родител
ревизия
fd642802b0
променени са 1 файла, в които са добавени 4 реда и са изтрити 7 реда
  1. 4 7
      internal/task/waf.go

+ 4 - 7
internal/task/waf.go

@@ -40,7 +40,7 @@ func NewWafTask(
 	globalLimitRep repository.GlobalLimitRepository,
 	expiredRep repository.ExpiredRepository,
 	task *Task,
-	gatewayGroupIpRep repository.GateWayGroupIpRepository,
+	gatewayIpRep repository.GatewayipRepository,
 	tcp service.TcpforwardingService,
 	udp service.UdpForWardingService,
 	web service.WebForwardingService,
@@ -54,7 +54,7 @@ func NewWafTask(
 		hostRep:           hostRep,
 		globalLimitRep:    globalLimitRep,
 		expiredRep:        expiredRep,
-		gatewayGroupIpRep: gatewayGroupIpRep,
+		gatewayIpRep:      gatewayIpRep,
 		tcp:               tcp,
 		udp:               udp,
 		web:               web,
@@ -70,7 +70,7 @@ type wafTask struct {
 	hostRep           repository.HostRepository
 	globalLimitRep    repository.GlobalLimitRepository
 	expiredRep        repository.ExpiredRepository
-	gatewayGroupIpRep repository.GateWayGroupIpRepository
+	gatewayIpRep      repository.GatewayipRepository
 	tcp               service.TcpforwardingService
 	udp               service.UdpForWardingService
 	web               service.WebForwardingService
@@ -296,10 +296,7 @@ func (t *wafTask) executeSinglePlanCleanup(ctx context.Context, limit model.Glob
 	// 只有在上述所有步骤都没有出错的情况下,才执行最终的数据库更新和Redis标记
 	if allErrors.ErrorOrNil() == nil {
 		// 执行您指定的数据库“重置”操作
-		err = t.globalLimitRep.UpdateGlobalLimitByHostId(ctx, &model.GlobalLimit{
-			HostId:         limit.HostId,
-			State:          true,
-		})
+		err := t.gatewayIpRep.CleanIPByHostId(ctx, []int64{hostId})
 		if err != nil {
 			allErrors = multierror.Append(allErrors, err)
 		}