mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-31 10:36:35 +08:00
v1.4.1
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user