diff --git a/internal/service/highwin/admin.go b/internal/service/highwin/admin.go index 8ffaac4..8c25253 100644 --- a/internal/service/highwin/admin.go +++ b/internal/service/highwin/admin.go @@ -122,11 +122,6 @@ func (w *BroadcastSimulationWorker) Start(ctx context.Context, req ContinuousSim if w == nil || w.db == nil || w.redis == nil || w.broadcaster == nil { return nil, common.NewAppError(http.StatusInternalServerError, "simulation_worker_not_configured", "simulation worker is not configured") } - normalizedRegionCodes, err := w.normalizeConfiguredRegionCodes(ctx, req.SysOrigin, req.RegionCodes) - if err != nil { - return nil, err - } - req.RegionCodes = normalizedRegionCodes w.mu.Lock() if w.cancel != nil { @@ -337,63 +332,6 @@ func (w *BroadcastSimulationWorker) sendContinuous(ctx context.Context, req Broa return err } -func (w *BroadcastSimulationWorker) normalizeConfiguredRegionCodes(ctx context.Context, sysOrigin string, values []string) ([]string, error) { - var rows []struct { - ID int64 - RegionCode string - RegionName string - } - if err := w.db.WithContext(ctx). - Table("voice_room_region_im_group"). - Select("id, region_code, region_name"). - Where("sys_origin = ? AND status = ? AND group_id <> ?", sysOrigin, "ACTIVE", ""). - Find(&rows).Error; err != nil { - return nil, err - } - lookup := map[string]string{} - for _, row := range rows { - code := strings.TrimSpace(row.RegionCode) - if code == "" { - continue - } - for _, key := range []string{ - code, - row.RegionName, - strconv.FormatInt(row.ID, 10), - } { - key = strings.ToUpper(strings.TrimSpace(key)) - if key != "" { - lookup[key] = code - } - } - } - seen := map[string]struct{}{} - result := make([]string, 0, len(values)) - for _, value := range values { - raw := strings.TrimSpace(value) - code := lookup[strings.ToUpper(raw)] - if code == "" { - code = raw - } - if _, ok := lookup[strings.ToUpper(code)]; !ok { - continue - } - key := strings.ToUpper(strings.TrimSpace(code)) - if key == "" { - continue - } - if _, exists := seen[key]; exists { - continue - } - seen[key] = struct{}{} - result = append(result, code) - } - if len(result) == 0 { - return nil, common.NewAppError(http.StatusBadRequest, "simulation_region_im_group_missing", "selected regions have no active region im group") - } - return result, nil -} - func (w *BroadcastSimulationWorker) randomOfflineUser(ctx context.Context, sysOrigin string, rng *rand.Rand) (int64, error) { onlineIDs := w.onlineUserIDs(ctx, sysOrigin) query := w.db.WithContext(ctx).