This commit is contained in:
GoEdgeLab
2024-07-27 14:15:25 +08:00
parent be70925770
commit 5a17ae9d79
520 changed files with 2515 additions and 762 deletions

View File

@@ -11,6 +11,7 @@ import (
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/types"
mrand "math/rand"
)
const (
@@ -209,3 +210,17 @@ func (this *ACMEUserDAO) CheckACMEUser(tx *dbs.Tx, acmeUserId int64, adminId int
State(ACMEUserStateEnabled).
Exist()
}
func (this *ACMEUserDAO) FindRandomACMEUserWithSameProvider(tx *dbs.Tx, providerCode string) (*ACMEUser, error) {
results, err := this.Query(tx).
Attr("providerCode", providerCode).
Attr("userId", 0).
FindAll()
if results == nil {
return nil, err
}
if len(results) == 0 {
return nil, errors.New("no acme user found")
}
idx := mrand.Intn(len(results))
return results[idx].(*ACMEUser), err
}