fix(n+1): 批量查询替代循环单查

- IsAdminBootstrapRequired: userRepo.GetByID 循环 → GetByIDs 批量
- AssignRoles: roleRepo.GetByID 循环 → GetByIDs 批量
- 在 userRepositoryInterface 补充 GetByIDs 方法签名
This commit is contained in:
2026-05-08 08:05:26 +08:00
parent 9b1cea246e
commit 2a18a6fb47
39 changed files with 3169 additions and 393 deletions

View File

@@ -1,4 +1,4 @@
import { mkdtemp, readdir, rm, access, mkdir } from 'node:fs/promises'
import { mkdtemp, readdir, rm, access } from 'node:fs/promises'
import { constants as fsConstants } from 'node:fs'
import { spawn } from 'node:child_process'
import { tmpdir } from 'node:os'
@@ -76,7 +76,7 @@ async function main() {
} else {
browserPath = await resolveBrowserPath()
port = await getFreePort()
profileDir = await createBrowserProfileDir(browserPath, port)
profileDir = await createBrowserProfileDir()
browser = startBrowser(browserPath, port, profileDir)
cdpBaseUrl = `http://127.0.0.1:${port}`
}
@@ -150,7 +150,15 @@ function resolveExternalCdpBaseUrl() {
}
function startBrowser(browserPath, port, profileDir) {
const args = [`--remote-debugging-port=${port}`, `--user-data-dir=${profileDir}`, '--no-sandbox']
const args = [
`--remote-debugging-port=${port}`,
`--user-data-dir=${profileDir}`,
'--noerrdialogs',
'--no-sandbox',
'--disable-breakpad',
'--disable-crash-reporter',
'--disable-crashpad-for-testing',
]
if (isHeadlessShell(browserPath)) {
args.push('--single-process')
@@ -181,14 +189,8 @@ function startBrowser(browserPath, port, profileDir) {
return browser
}
async function createBrowserProfileDir(browserPath, port) {
if (!isHeadlessShell(browserPath)) {
return await mkdtemp(path.join(tmpdir(), 'pw-profile-cdp-'))
}
const profileRoot = path.join(process.cwd(), '.cache', 'cdp-profiles')
await mkdir(profileRoot, { recursive: true })
return path.join(profileRoot, `pw-profile-cdp-smoke-node-${port}`)
async function createBrowserProfileDir() {
return await mkdtemp(path.join(tmpdir(), 'pw-profile-cdp-'))
}
async function resolveBrowserPath() {