feat: 完成前端业务闭环与后端联调
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
normalizeOptionalText,
|
||||
normalizeResourcePathId
|
||||
} from './request-normalizers.js'
|
||||
import { normalizeBusinessOptionProjection } from './business-dictionary-contract.js'
|
||||
|
||||
const normalizePersonDocumentText = (value, field) =>
|
||||
normalizeOptionalResponseText(value, field, '重要证件响应', 'PERSON_DOCUMENT_RESPONSE_INVALID')
|
||||
@@ -33,9 +34,6 @@ export const PERSON_DOCUMENT_RESOURCE_USAGE_LABELS = Object.freeze({
|
||||
[PERSON_DOCUMENT_RESOURCE_USAGE.ATTACHMENT]: '附件'
|
||||
})
|
||||
|
||||
const personDocumentTypes = new Set(
|
||||
PERSON_DOCUMENT_TYPE_OPTIONS.map(({ value }) => value)
|
||||
)
|
||||
const personDocumentResourceUsages = new Set(
|
||||
Object.values(PERSON_DOCUMENT_RESOURCE_USAGE)
|
||||
)
|
||||
@@ -64,10 +62,13 @@ export const normalizePersonDocument = (value, expectedGenealogyId) => {
|
||||
if (genealogyId !== expectedGenealogyId) {
|
||||
throw createRequestError('重要证件归属与请求不匹配', 'PERSON_DOCUMENT_RESPONSE_INVALID')
|
||||
}
|
||||
const documentType = normalizePersonDocumentText(value.documentType, 'documentType')
|
||||
if (!personDocumentTypes.has(documentType)) {
|
||||
throw createRequestError('重要证件类型无效', 'PERSON_DOCUMENT_RESPONSE_INVALID')
|
||||
}
|
||||
const documentType = normalizeBusinessOptionProjection(
|
||||
value.documentType,
|
||||
value.documentTypeLabel,
|
||||
value.documentTypeOptionState,
|
||||
'重要证件类型',
|
||||
'PERSON_DOCUMENT_RESPONSE_INVALID'
|
||||
)
|
||||
const documentTitle = normalizePersonDocumentText(value.documentTitle, 'documentTitle')
|
||||
if (!documentTitle) throw createRequestError('重要证件缺少标题', 'PERSON_DOCUMENT_RESPONSE_INVALID')
|
||||
for (const field of ['contentProtected', 'contentUnlocked', 'canEdit', 'canDelete']) {
|
||||
@@ -83,7 +84,9 @@ export const normalizePersonDocument = (value, expectedGenealogyId) => {
|
||||
genealogyId,
|
||||
lineagePersonId: normalizeResourcePathId(value.lineagePersonId, '世系人物标识'),
|
||||
lineagePersonName: normalizePersonDocumentText(value.lineagePersonName, 'lineagePersonName'),
|
||||
documentType,
|
||||
documentType: documentType.value,
|
||||
documentTypeLabel: documentType.label,
|
||||
documentTypeOptionState: documentType.state,
|
||||
documentTitle,
|
||||
maskedIdentifier: normalizePersonDocumentText(value.maskedIdentifier, 'maskedIdentifier'),
|
||||
description: normalizePersonDocumentText(value.description, 'description'),
|
||||
@@ -110,7 +113,7 @@ export const normalizePersonDocuments = (value, expectedGenealogyId) => {
|
||||
export const normalizePersonDocumentPayload = (payload) => {
|
||||
assertPlainPayload(payload, new Set(['lineagePersonId', 'documentType', 'documentTitle', 'maskedIdentifier', 'description', 'sortOrder', 'status']), '重要证件请求')
|
||||
const documentType = normalizeOptionalText(payload.documentType, 'documentType')
|
||||
if (!personDocumentTypes.has(documentType)) throw new TypeError('请选择有效的证件类型')
|
||||
if (!documentType) throw new TypeError('请选择有效的证件类型')
|
||||
const documentTitle = normalizeOptionalText(payload.documentTitle, 'documentTitle')
|
||||
if (!documentTitle) throw new TypeError('请填写证件标题')
|
||||
if (documentTitle.length > 100) throw new TypeError('证件标题不能超过100个字符')
|
||||
|
||||
Reference in New Issue
Block a user