mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-04-17 21:34:45 +08:00
fix: remove unused preload/snapshot functions and fix gofmt
This commit is contained in:
@@ -10,23 +10,23 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type stubAdminService struct {
|
type stubAdminService struct {
|
||||||
users []service.User
|
users []service.User
|
||||||
apiKeys []service.APIKey
|
apiKeys []service.APIKey
|
||||||
groups []service.Group
|
groups []service.Group
|
||||||
accounts []service.Account
|
accounts []service.Account
|
||||||
proxies []service.Proxy
|
proxies []service.Proxy
|
||||||
proxyCounts []service.ProxyWithAccountCount
|
proxyCounts []service.ProxyWithAccountCount
|
||||||
redeems []service.RedeemCode
|
redeems []service.RedeemCode
|
||||||
createdAccounts []*service.CreateAccountInput
|
createdAccounts []*service.CreateAccountInput
|
||||||
createdProxies []*service.CreateProxyInput
|
createdProxies []*service.CreateProxyInput
|
||||||
updatedProxyIDs []int64
|
updatedProxyIDs []int64
|
||||||
updatedProxies []*service.UpdateProxyInput
|
updatedProxies []*service.UpdateProxyInput
|
||||||
testedProxyIDs []int64
|
testedProxyIDs []int64
|
||||||
createAccountErr error
|
createAccountErr error
|
||||||
updateAccountErr error
|
updateAccountErr error
|
||||||
bulkUpdateAccountErr error
|
bulkUpdateAccountErr error
|
||||||
checkMixedErr error
|
checkMixedErr error
|
||||||
lastMixedCheck struct {
|
lastMixedCheck struct {
|
||||||
accountID int64
|
accountID int64
|
||||||
platform string
|
platform string
|
||||||
groupIDs []int64
|
groupIDs []int64
|
||||||
|
|||||||
@@ -2119,6 +2119,35 @@ func (s *adminServiceImpl) checkMixedChannelRisk(ctx context.Context, currentAcc
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *adminServiceImpl) validateGroupIDsExist(ctx context.Context, groupIDs []int64) error {
|
||||||
|
if len(groupIDs) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if s.groupRepo == nil {
|
||||||
|
return errors.New("group repository not configured")
|
||||||
|
}
|
||||||
|
|
||||||
|
if batchReader, ok := s.groupRepo.(groupExistenceBatchReader); ok {
|
||||||
|
existsByID, err := batchReader.ExistsByIDs(ctx, groupIDs)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("check groups exists: %w", err)
|
||||||
|
}
|
||||||
|
for _, groupID := range groupIDs {
|
||||||
|
if groupID <= 0 || !existsByID[groupID] {
|
||||||
|
return fmt.Errorf("get group: %w", ErrGroupNotFound)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, groupID := range groupIDs {
|
||||||
|
if _, err := s.groupRepo.GetByID(ctx, groupID); err != nil {
|
||||||
|
return fmt.Errorf("get group: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// CheckMixedChannelRisk checks whether target groups contain mixed channels for the current account platform.
|
// CheckMixedChannelRisk checks whether target groups contain mixed channels for the current account platform.
|
||||||
func (s *adminServiceImpl) CheckMixedChannelRisk(ctx context.Context, currentAccountID int64, currentAccountPlatform string, groupIDs []int64) error {
|
func (s *adminServiceImpl) CheckMixedChannelRisk(ctx context.Context, currentAccountID int64, currentAccountPlatform string, groupIDs []int64) error {
|
||||||
return s.checkMixedChannelRisk(ctx, currentAccountID, currentAccountPlatform, groupIDs)
|
return s.checkMixedChannelRisk(ctx, currentAccountID, currentAccountPlatform, groupIDs)
|
||||||
|
|||||||
Reference in New Issue
Block a user