feat: 完成前端业务闭环与后端联调
This commit is contained in:
@@ -1,23 +1,13 @@
|
||||
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)
|
||||
}
|
||||
import { requestStrict } from './request-client.js'
|
||||
|
||||
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`,
|
||||
@@ -29,10 +19,6 @@ export const generationPoemApi = {
|
||||
},
|
||||
|
||||
async getGenerationPoemManagement(genealogyId, requestOptions = {}) {
|
||||
requireRemoteGenerationPoem(
|
||||
'字辈维护列表需要真实读取服务,当前本地预览不会伪造管理权限',
|
||||
'REMOTE_READ_REQUIRED'
|
||||
)
|
||||
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
|
||||
const generationPoems = await requestStrict({
|
||||
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/generation-poems/management`,
|
||||
@@ -44,10 +30,6 @@ export const generationPoemApi = {
|
||||
},
|
||||
|
||||
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`,
|
||||
@@ -60,17 +42,15 @@ export const generationPoemApi = {
|
||||
},
|
||||
|
||||
async saveGenerationPoemBatch(genealogyId, payload, requestOptions = {}) {
|
||||
requireRemoteGenerationPoem(
|
||||
'字辈批量保存需要真实服务,当前本地预览不会伪造保存成功',
|
||||
'REMOTE_WRITE_REQUIRED'
|
||||
)
|
||||
const normalizedGenealogyId = normalizeGenealogyPathId(genealogyId)
|
||||
return requestStrict({
|
||||
await requestStrict({
|
||||
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/generation-poems/batch/save`,
|
||||
method: 'POST',
|
||||
data: normalizeGenerationPoemBatchPayload(payload)
|
||||
}, {
|
||||
requireData: false,
|
||||
requestController: requestOptions.requestController ?? null
|
||||
})
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user