Explorar o código

refactor(internal/task): 简化 WAF 续费请求结构

- 移除了 RenewalRequest 结构中的 PlanId 字段- 删除了未使用的 wafPlanMap 变量和相关逻辑- 优化了代码结构,提高了代码的可读性和维护性
fusu hai 2 semanas
pai
achega
dfb12abe9b
Modificáronse 1 ficheiros con 4 adicións e 9 borrados
  1. 4 9
      internal/task/waf.go

+ 4 - 9
internal/task/waf.go

@@ -85,7 +85,6 @@ const (
 
 type RenewalRequest struct {
 	HostId    int
-	PlanId    int
 	ExpiredAt int64
 }
 
@@ -192,12 +191,12 @@ func (t *wafTask) findPlansNeedingSync(ctx context.Context, wafLimits []model.Gl
 		return nil, nil
 	}
 	wafExpiredMap := make(map[int]int64, len(wafLimits))
-	wafPlanMap := make(map[int]int, len(wafLimits))
+
 	var hostIds []int
 	for _, limit := range wafLimits {
 		hostIds = append(hostIds, limit.HostId)
 		wafExpiredMap[limit.HostId] = limit.ExpiredAt
-		//wafPlanMap[limit.HostId] = limit.RuleId
+
 	}
 
 	hostExpirations, err := t.hostRep.GetExpireTimeByHostId(ctx, hostIds)
@@ -213,12 +212,8 @@ func (t *wafTask) findPlansNeedingSync(ctx context.Context, wafLimits []model.Gl
 	for hostId, wafExpiredTime := range wafExpiredMap {
 		hostTime, ok := hostExpiredMap[hostId]
 		if !ok || hostTime != wafExpiredTime {
-			planId, planOk := wafPlanMap[hostId]
-			if !planOk {
-				t.logger.Warn("数据不一致:在waf_limits中找不到hostId对应的套餐ID", zap.Int("hostId", hostId))
-				continue
-			}
-			renewalRequests = append(renewalRequests, RenewalRequest{HostId: hostId, ExpiredAt: hostTime, PlanId: planId})
+
+			renewalRequests = append(renewalRequests, RenewalRequest{HostId: hostId, ExpiredAt: hostTime})
 		}
 	}
 	return renewalRequests, nil