This commit is contained in:
unknown
2026-02-04 20:27:13 +08:00
commit 3b042d1dad
9410 changed files with 1488147 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
//go:build plus
package models
import "github.com/iwind/TeaGo/dbs"
// ResetServersTrafficLimitStatusWithUserPlanId 重置用户套餐相关网站限流状态
func (this *ServerDAO) ResetServersTrafficLimitStatusWithUserPlanId(tx *dbs.Tx, userPlanId int64) error {
servers, err := this.Query(tx).
State(ServerStateEnabled).
Attr("userPlanId", userPlanId).
Where("(trafficLimitStatus IS NOT NULL AND JSON_EXTRACT(trafficLimitStatus, '$.planId') IS NOT NULL)").
ResultPk().
FindAll()
if err != nil {
return err
}
if len(servers) == 0 {
return nil
}
err = this.Query(tx).
State(ServerStateEnabled).
Attr("userPlanId", userPlanId).
Where("(trafficLimitStatus IS NOT NULL AND JSON_EXTRACT(trafficLimitStatus, '$.planId') IS NOT NULL)").
Set("trafficLimitStatus", dbs.SQL("NULL")).
UpdateQuickly()
if err != nil {
return err
}
for _, server := range servers {
err = this.NotifyUpdate(tx, int64(server.(*Server).Id))
if err != nil {
return err
}
}
return nil
}