feat: migrate app routes and business modules

This commit is contained in:
2026-08-12 18:22:59 +08:00
parent 555aa00043
commit cc706378c2
247 changed files with 28623 additions and 14988 deletions
+76
View File
@@ -0,0 +1,76 @@
import { hasRemoteConfig } from '@/utils/runtime-config.js'
import {
normalizeGenerationPoemBatchPayload,
normalizeGenerationPoemPreview,
normalizeGenerationPoemRows
} from './generation-poem-contract.js'
import { normalizeGenealogyPathId } from './genealogy-contract.js'
import { createRequestError, requestStrict } from './request-client.js'
const requireRemoteGenerationPoem = (message, code) => {
if (hasRemoteConfig()) return
throw createRequestError(message, code)
}
export const generationPoemApi = {
async getGenerationPoems(genealogyId, requestOptions = {}) {
requireRemoteGenerationPoem(
'字辈列表需要真实读取服务,当前本地预览不会伪造字辈数据',
'REMOTE_READ_REQUIRED'
)
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
const generationPoems = await requestStrict({
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/generation-poems`,
method: 'GET'
}, {
requestController: requestOptions.requestController ?? null
})
return normalizeGenerationPoemRows(generationPoems, normalizedGenealogyId)
},
async getGenerationPoemManagement(genealogyId, requestOptions = {}) {
requireRemoteGenerationPoem(
'字辈维护列表需要真实读取服务,当前本地预览不会伪造管理权限',
'REMOTE_READ_REQUIRED'
)
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
const generationPoems = await requestStrict({
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/generation-poems/management`,
method: 'GET'
}, {
requestController: requestOptions.requestController ?? null
})
return normalizeGenerationPoemRows(generationPoems, normalizedGenealogyId)
},
async previewGenerationPoemBatch(genealogyId, payload, requestOptions = {}) {
requireRemoteGenerationPoem(
'字辈批量预览需要真实服务,当前本地预览不会伪造差异结果',
'REMOTE_READ_REQUIRED'
)
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
const preview = await requestStrict({
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/generation-poems/batch/preview`,
method: 'POST',
data: normalizeGenerationPoemBatchPayload(payload)
}, {
requestController: requestOptions.requestController ?? null
})
return normalizeGenerationPoemPreview(preview, normalizedGenealogyId)
},
async saveGenerationPoemBatch(genealogyId, payload, requestOptions = {}) {
requireRemoteGenerationPoem(
'字辈批量保存需要真实服务,当前本地预览不会伪造保存成功',
'REMOTE_WRITE_REQUIRED'
)
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
return requestStrict({
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/generation-poems/batch/save`,
method: 'POST',
data: normalizeGenerationPoemBatchPayload(payload)
}, {
requestController: requestOptions.requestController ?? null
})
}
}