fix_profile_conflicts.ps1 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Fix @Profile annotations for packages that are excluded by excludeFilters in FsCompanyApplication
  2. # These controllers should NOT have @Profile({"admin","company"}) because they conflict with
  3. # controllers in fs-company's own source code.
  4. # Change them back to @Profile("admin") so they only load in fs-admin context.
  5. $baseDir = "d:\ylrz\ylrz_saas_his_scrm\fs-admin-saas\src\main\java\com\fs"
  6. # Packages that are excluded by excludeFilters and have conflicting controllers
  7. $conflictPackages = @(
  8. "admin\controller",
  9. "web\controller",
  10. "api\controller",
  11. "crm\controller",
  12. "qw\controller",
  13. "live\controller",
  14. "course\controller",
  15. "user\controller",
  16. "fastGpt",
  17. "fastgptApi",
  18. "company\controller"
  19. )
  20. $totalFixed = 0
  21. foreach ($pkg in $conflictPackages) {
  22. $pkgDir = Join-Path $baseDir $pkg
  23. if (-not (Test-Path $pkgDir)) {
  24. Write-Host "SKIP: $pkgDir not found"
  25. continue
  26. }
  27. $files = Get-ChildItem -Path $pkgDir -Filter "*.java" -Recurse
  28. foreach ($file in $files) {
  29. $content = [System.IO.File]::ReadAllText($file.FullName)
  30. if ($content -match '@Profile\(\{"admin",\s*"company"\}\)') {
  31. $newContent = $content -replace '@Profile\(\{"admin",\s*"company"\}\)', '@Profile("admin")'
  32. $utf8NoBom = New-Object System.Text.UTF8Encoding($false)
  33. [System.IO.File]::WriteAllText($file.FullName, $newContent, $utf8NoBom)
  34. $totalFixed++
  35. Write-Host "FIXED: $($file.FullName)"
  36. }
  37. }
  38. }
  39. Write-Host "`nTotal files fixed: $totalFixed"