@@ -2288,41 +2288,6 @@ func (s *adminServiceImpl) checkMixedChannelRisk(ctx context.Context, currentAcc
22882288 return nil
22892289}
22902290
2291- func (s * adminServiceImpl ) preloadMixedChannelRiskData (ctx context.Context , groupIDs []int64 ) (map [int64 ][]Account , map [int64 ]string , error ) {
2292- accountsByGroup := make (map [int64 ][]Account )
2293- groupNameByID := make (map [int64 ]string )
2294- if len (groupIDs ) == 0 {
2295- return accountsByGroup , groupNameByID , nil
2296- }
2297-
2298- seen := make (map [int64 ]struct {}, len (groupIDs ))
2299- for _ , groupID := range groupIDs {
2300- if groupID <= 0 {
2301- continue
2302- }
2303- if _ , ok := seen [groupID ]; ok {
2304- continue
2305- }
2306- seen [groupID ] = struct {}{}
2307-
2308- accounts , err := s .accountRepo .ListByGroup (ctx , groupID )
2309- if err != nil {
2310- return nil , nil , fmt .Errorf ("get accounts in group %d: %w" , groupID , err )
2311- }
2312- accountsByGroup [groupID ] = accounts
2313-
2314- group , err := s .groupRepo .GetByID (ctx , groupID )
2315- if err != nil {
2316- continue
2317- }
2318- if group != nil {
2319- groupNameByID [groupID ] = group .Name
2320- }
2321- }
2322-
2323- return accountsByGroup , groupNameByID , nil
2324- }
2325-
23262291func (s * adminServiceImpl ) validateGroupIDsExist (ctx context.Context , groupIDs []int64 ) error {
23272292 if len (groupIDs ) == 0 {
23282293 return nil
@@ -2352,71 +2317,6 @@ func (s *adminServiceImpl) validateGroupIDsExist(ctx context.Context, groupIDs [
23522317 return nil
23532318}
23542319
2355- func (s * adminServiceImpl ) checkMixedChannelRiskWithPreloaded (currentAccountID int64 , currentAccountPlatform string , groupIDs []int64 , accountsByGroup map [int64 ][]Account , groupNameByID map [int64 ]string ) error {
2356- currentPlatform := getAccountPlatform (currentAccountPlatform )
2357- if currentPlatform == "" {
2358- return nil
2359- }
2360-
2361- for _ , groupID := range groupIDs {
2362- accounts := accountsByGroup [groupID ]
2363- for _ , account := range accounts {
2364- if currentAccountID > 0 && account .ID == currentAccountID {
2365- continue
2366- }
2367-
2368- otherPlatform := getAccountPlatform (account .Platform )
2369- if otherPlatform == "" {
2370- continue
2371- }
2372-
2373- if currentPlatform != otherPlatform {
2374- groupName := fmt .Sprintf ("Group %d" , groupID )
2375- if name := strings .TrimSpace (groupNameByID [groupID ]); name != "" {
2376- groupName = name
2377- }
2378-
2379- return & MixedChannelError {
2380- GroupID : groupID ,
2381- GroupName : groupName ,
2382- CurrentPlatform : currentPlatform ,
2383- OtherPlatform : otherPlatform ,
2384- }
2385- }
2386- }
2387- }
2388-
2389- return nil
2390- }
2391-
2392- func updateMixedChannelPreloadedAccounts (accountsByGroup map [int64 ][]Account , groupIDs []int64 , accountID int64 , platform string ) {
2393- if len (groupIDs ) == 0 || accountID <= 0 || platform == "" {
2394- return
2395- }
2396- for _ , groupID := range groupIDs {
2397- if groupID <= 0 {
2398- continue
2399- }
2400- accounts := accountsByGroup [groupID ]
2401- found := false
2402- for i := range accounts {
2403- if accounts [i ].ID != accountID {
2404- continue
2405- }
2406- accounts [i ].Platform = platform
2407- found = true
2408- break
2409- }
2410- if ! found {
2411- accounts = append (accounts , Account {
2412- ID : accountID ,
2413- Platform : platform ,
2414- })
2415- }
2416- accountsByGroup [groupID ] = accounts
2417- }
2418- }
2419-
24202320// CheckMixedChannelRisk checks whether target groups contain mixed channels for the current account platform.
24212321func (s * adminServiceImpl ) CheckMixedChannelRisk (ctx context.Context , currentAccountID int64 , currentAccountPlatform string , groupIDs []int64 ) error {
24222322 return s .checkMixedChannelRisk (ctx , currentAccountID , currentAccountPlatform , groupIDs )
0 commit comments