Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
c08889b0
Commit
c08889b0
authored
Mar 01, 2026
by
erio
Browse files
fix: remove unused preload/snapshot functions and fix gofmt
parent
57ebe382
Changes
2
Hide whitespace changes
Inline
Side-by-side
backend/internal/handler/admin/admin_service_stub_test.go
View file @
c08889b0
...
@@ -10,23 +10,23 @@ import (
...
@@ -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
...
...
backend/internal/service/admin_service.go
View file @
c08889b0
...
@@ -2288,41 +2288,6 @@ func (s *adminServiceImpl) checkMixedChannelRisk(ctx context.Context, currentAcc
...
@@ -2288,41 +2288,6 @@ func (s *adminServiceImpl) checkMixedChannelRisk(ctx context.Context, currentAcc
return
nil
return
nil
}
}
func
(
s
*
adminServiceImpl
)
preloadMixedChannelRiskData
(
ctx
context
.
Context
,
groupIDs
[]
int64
)
(
map
[
int64
][]
Account
,
map
[
int64
]
string
,
error
)
{
accountsByGroup
:=
make
(
map
[
int64
][]
Account
)
groupNameByID
:=
make
(
map
[
int64
]
string
)
if
len
(
groupIDs
)
==
0
{
return
accountsByGroup
,
groupNameByID
,
nil
}
seen
:=
make
(
map
[
int64
]
struct
{},
len
(
groupIDs
))
for
_
,
groupID
:=
range
groupIDs
{
if
groupID
<=
0
{
continue
}
if
_
,
ok
:=
seen
[
groupID
];
ok
{
continue
}
seen
[
groupID
]
=
struct
{}{}
accounts
,
err
:=
s
.
accountRepo
.
ListByGroup
(
ctx
,
groupID
)
if
err
!=
nil
{
return
nil
,
nil
,
fmt
.
Errorf
(
"get accounts in group %d: %w"
,
groupID
,
err
)
}
accountsByGroup
[
groupID
]
=
accounts
group
,
err
:=
s
.
groupRepo
.
GetByID
(
ctx
,
groupID
)
if
err
!=
nil
{
continue
}
if
group
!=
nil
{
groupNameByID
[
groupID
]
=
group
.
Name
}
}
return
accountsByGroup
,
groupNameByID
,
nil
}
func
(
s
*
adminServiceImpl
)
validateGroupIDsExist
(
ctx
context
.
Context
,
groupIDs
[]
int64
)
error
{
func
(
s
*
adminServiceImpl
)
validateGroupIDsExist
(
ctx
context
.
Context
,
groupIDs
[]
int64
)
error
{
if
len
(
groupIDs
)
==
0
{
if
len
(
groupIDs
)
==
0
{
return
nil
return
nil
...
@@ -2352,71 +2317,6 @@ func (s *adminServiceImpl) validateGroupIDsExist(ctx context.Context, groupIDs [
...
@@ -2352,71 +2317,6 @@ func (s *adminServiceImpl) validateGroupIDsExist(ctx context.Context, groupIDs [
return
nil
return
nil
}
}
func
(
s
*
adminServiceImpl
)
checkMixedChannelRiskWithPreloaded
(
currentAccountID
int64
,
currentAccountPlatform
string
,
groupIDs
[]
int64
,
accountsByGroup
map
[
int64
][]
Account
,
groupNameByID
map
[
int64
]
string
)
error
{
currentPlatform
:=
getAccountPlatform
(
currentAccountPlatform
)
if
currentPlatform
==
""
{
return
nil
}
for
_
,
groupID
:=
range
groupIDs
{
accounts
:=
accountsByGroup
[
groupID
]
for
_
,
account
:=
range
accounts
{
if
currentAccountID
>
0
&&
account
.
ID
==
currentAccountID
{
continue
}
otherPlatform
:=
getAccountPlatform
(
account
.
Platform
)
if
otherPlatform
==
""
{
continue
}
if
currentPlatform
!=
otherPlatform
{
groupName
:=
fmt
.
Sprintf
(
"Group %d"
,
groupID
)
if
name
:=
strings
.
TrimSpace
(
groupNameByID
[
groupID
]);
name
!=
""
{
groupName
=
name
}
return
&
MixedChannelError
{
GroupID
:
groupID
,
GroupName
:
groupName
,
CurrentPlatform
:
currentPlatform
,
OtherPlatform
:
otherPlatform
,
}
}
}
}
return
nil
}
func
updateMixedChannelPreloadedAccounts
(
accountsByGroup
map
[
int64
][]
Account
,
groupIDs
[]
int64
,
accountID
int64
,
platform
string
)
{
if
len
(
groupIDs
)
==
0
||
accountID
<=
0
||
platform
==
""
{
return
}
for
_
,
groupID
:=
range
groupIDs
{
if
groupID
<=
0
{
continue
}
accounts
:=
accountsByGroup
[
groupID
]
found
:=
false
for
i
:=
range
accounts
{
if
accounts
[
i
]
.
ID
!=
accountID
{
continue
}
accounts
[
i
]
.
Platform
=
platform
found
=
true
break
}
if
!
found
{
accounts
=
append
(
accounts
,
Account
{
ID
:
accountID
,
Platform
:
platform
,
})
}
accountsByGroup
[
groupID
]
=
accounts
}
}
// 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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment