feat: 完成前端业务闭环与后端联调
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { hasRemoteConfig } from '@/utils/runtime-config.js'
|
||||
import {
|
||||
normalizeBusinessFileAccess
|
||||
} from './business-file-contract.js'
|
||||
@@ -16,35 +15,15 @@ import {
|
||||
normalizeContentAccessGrant,
|
||||
normalizeContentPasswordPayload
|
||||
} from './protected-content-contract.js'
|
||||
import { createRequestError, requestStrict } from './request-client.js'
|
||||
import { requestStrict } from './request-client.js'
|
||||
|
||||
const requireRemotePersonDocument = (operation) => {
|
||||
if (hasRemoteConfig()) return
|
||||
throw createRequestError(
|
||||
`重要证件${operation}需要真实服务,当前本地预览不会伪造结果`,
|
||||
operation === '读取' ? 'REMOTE_READ_REQUIRED' : 'REMOTE_WRITE_REQUIRED'
|
||||
)
|
||||
}
|
||||
|
||||
const writePersonDocument = (url, method, data, label, requestOptions) => {
|
||||
if (!hasRemoteConfig()) {
|
||||
throw createRequestError(
|
||||
`${label}写入需要真实服务,当前本地预览不会伪造结果`,
|
||||
'REMOTE_WRITE_REQUIRED'
|
||||
)
|
||||
}
|
||||
const writePersonDocument = (url, method, data, requestOptions) => {
|
||||
return requestStrict({ url, method, data }, {
|
||||
requestController: requestOptions.requestController ?? null
|
||||
})
|
||||
}
|
||||
|
||||
const deletePersonDocumentEndpoint = async (url, label, requestOptions) => {
|
||||
if (!hasRemoteConfig()) {
|
||||
throw createRequestError(
|
||||
`${label}写入需要真实服务,当前本地预览不会伪造结果`,
|
||||
'REMOTE_WRITE_REQUIRED'
|
||||
)
|
||||
}
|
||||
const deletePersonDocumentEndpoint = async (url, requestOptions) => {
|
||||
await requestStrict({ url, method: 'DELETE' }, {
|
||||
requireData: false,
|
||||
requestController: requestOptions.requestController ?? null
|
||||
@@ -65,7 +44,6 @@ export const personDocumentApi = {
|
||||
if (query.lineagePersonId !== undefined && query.lineagePersonId !== null && query.lineagePersonId !== '') {
|
||||
queryParams.lineagePersonId = normalizeResourcePathId(query.lineagePersonId, '世系人物标识')
|
||||
}
|
||||
requireRemotePersonDocument('读取')
|
||||
const personDocuments = await requestStrict({
|
||||
url: `/genealogy/app/genealogies/${normalizedGenealogyId}/person-documents`,
|
||||
method: 'GET',
|
||||
@@ -94,7 +72,6 @@ export const personDocumentApi = {
|
||||
`/genealogy/app/genealogies/${normalizedGenealogyId}/person-documents`,
|
||||
'POST',
|
||||
normalizePersonDocumentPayload(payload),
|
||||
'重要证件',
|
||||
requestOptions
|
||||
)
|
||||
return normalizePersonDocument(personDocument, normalizedGenealogyId)
|
||||
@@ -106,7 +83,6 @@ export const personDocumentApi = {
|
||||
`/genealogy/app/genealogies/${normalizedIds.genealogyId}/person-documents/${normalizedIds.documentId}`,
|
||||
'PUT',
|
||||
normalizePersonDocumentPayload(payload),
|
||||
'重要证件',
|
||||
requestOptions
|
||||
)
|
||||
return normalizePersonDocument(personDocument, normalizedIds.genealogyId)
|
||||
@@ -116,7 +92,6 @@ export const personDocumentApi = {
|
||||
const normalizedIds = normalizeDocumentIds(genealogyId, documentId)
|
||||
return deletePersonDocumentEndpoint(
|
||||
`/genealogy/app/genealogies/${normalizedIds.genealogyId}/person-documents/${normalizedIds.documentId}`,
|
||||
'重要证件',
|
||||
requestOptions
|
||||
)
|
||||
},
|
||||
@@ -127,7 +102,6 @@ export const personDocumentApi = {
|
||||
`/genealogy/app/genealogies/${normalizedIds.genealogyId}/person-documents/${normalizedIds.documentId}/resources`,
|
||||
'POST',
|
||||
normalizePersonDocumentResourcePayload(payload),
|
||||
'证件文件',
|
||||
requestOptions
|
||||
)
|
||||
return normalizePersonDocumentResource(documentResource)
|
||||
@@ -140,7 +114,6 @@ export const personDocumentApi = {
|
||||
`/genealogy/app/genealogies/${normalizedIds.genealogyId}/person-documents/${normalizedIds.documentId}/resources/${normalizedResourceId}`,
|
||||
'PUT',
|
||||
normalizePersonDocumentResourcePayload(payload),
|
||||
'证件文件',
|
||||
requestOptions
|
||||
)
|
||||
return normalizePersonDocumentResource(documentResource)
|
||||
@@ -151,7 +124,6 @@ export const personDocumentApi = {
|
||||
const normalizedResourceId = normalizeResourcePathId(resourceId, '证件文件标识')
|
||||
return deletePersonDocumentEndpoint(
|
||||
`/genealogy/app/genealogies/${normalizedIds.genealogyId}/person-documents/${normalizedIds.documentId}/resources/${normalizedResourceId}`,
|
||||
'证件文件',
|
||||
requestOptions
|
||||
)
|
||||
},
|
||||
@@ -176,13 +148,14 @@ export const personDocumentApi = {
|
||||
|
||||
async setPersonDocumentPassword(genealogyId, documentId, password, requestOptions = {}) {
|
||||
const normalizedIds = normalizeDocumentIds(genealogyId, documentId)
|
||||
await writePersonDocument(
|
||||
`/genealogy/app/genealogies/${normalizedIds.genealogyId}/person-documents/${normalizedIds.documentId}/content-protection`,
|
||||
'PUT',
|
||||
normalizeContentPasswordPayload(password),
|
||||
'证件内容密码',
|
||||
requestOptions
|
||||
)
|
||||
await requestStrict({
|
||||
url: `/genealogy/app/genealogies/${normalizedIds.genealogyId}/person-documents/${normalizedIds.documentId}/content-protection`,
|
||||
method: 'PUT',
|
||||
data: normalizeContentPasswordPayload(password)
|
||||
}, {
|
||||
requireData: false,
|
||||
requestController: requestOptions.requestController ?? null
|
||||
})
|
||||
return null
|
||||
},
|
||||
|
||||
@@ -192,7 +165,6 @@ export const personDocumentApi = {
|
||||
`/genealogy/app/genealogies/${normalizedIds.genealogyId}/person-documents/${normalizedIds.documentId}/content-unlock`,
|
||||
'POST',
|
||||
normalizeContentPasswordPayload(password),
|
||||
'证件内容解锁',
|
||||
requestOptions
|
||||
)
|
||||
return normalizeContentAccessGrant(accessGrant)
|
||||
@@ -202,7 +174,6 @@ export const personDocumentApi = {
|
||||
const normalizedIds = normalizeDocumentIds(genealogyId, documentId)
|
||||
return deletePersonDocumentEndpoint(
|
||||
`/genealogy/app/genealogies/${normalizedIds.genealogyId}/person-documents/${normalizedIds.documentId}/content-protection`,
|
||||
'证件内容密码',
|
||||
requestOptions
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user