修改完成待测试

This commit is contained in:
2026-09-13 17:45:47 +08:00
parent 9ad572907b
commit bbc024f7f2
80 changed files with 3844 additions and 1672 deletions
+53
View File
@@ -1,5 +1,6 @@
import { normalizeOptionalSafeInteger } from './request-normalizers.js'
import { createRequestError } from './request-client.js'
import { normalizeOptionalNumericId } from './response-normalizers.js'
import { LINEAGE_PERSON_OPTIONS } from './lineage-person-options.js'
import { normalizeBusinessOptionProjection } from './business-dictionary-contract.js'
@@ -10,6 +11,16 @@ const optionLabels = (options) => Object.freeze(
const lineagePersonError = (message) =>
createRequestError(message, 'LINEAGE_PERSON_RESPONSE_INVALID')
const lineageRankError = (message) =>
createRequestError(message, 'LINEAGE_RANK_RESPONSE_INVALID')
const normalizeLineageRankText = (value, label) => {
if (typeof value !== 'string' || !value.trim()) {
throw lineageRankError(`世系排行选项缺少${label}`)
}
return value.trim()
}
export const normalizeLineagePersonIdentity = (value, label) => {
if (typeof value === 'string' && /^[1-9]\d*$/.test(value)) return value
if (typeof value === 'number' && Number.isSafeInteger(value) && value > 0) return String(value)
@@ -146,6 +157,12 @@ export const normalizeLineagePersonDetail = (value, expectedGenealogyId, expecte
throw lineagePersonError('成员详情敏感病史权限无效')
}
const relationName = normalizeLineagePersonText(value.relationName, '关系显示名称')
const rankId = normalizeOptionalNumericId(
value.rankId,
'成员排行标识',
'LINEAGE_PERSON_RESPONSE_INVALID'
)
const rankName = normalizeLineagePersonText(value.rankName, '排行名称')
for (const field of ['canDisable', 'canCreateDocument', 'canManageDocuments']) {
if (value[field] !== undefined && typeof value[field] !== 'boolean') {
throw lineagePersonError(`成员详情权限字段 ${field} 无效`)
@@ -221,6 +238,8 @@ export const normalizeLineagePersonDetail = (value, expectedGenealogyId, expecte
remark,
canManageSensitiveMedicalHistory,
relationName,
rankId,
rankName,
sortOrder,
status: personStatus === '1' ? 'deceased' : 'normal',
canDisable: value.canDisable === true,
@@ -231,6 +250,40 @@ export const normalizeLineagePersonDetail = (value, expectedGenealogyId, expecte
}
}
export const normalizeLineageRankOptions = (value) => {
if (!Array.isArray(value)) throw lineageRankError('世系排行选项响应不是列表')
const rankIds = new Set()
return value.map((option) => {
if (!option || typeof option !== 'object' || Array.isArray(option)) {
throw lineageRankError('世系排行选项包含无效记录')
}
const rankId = normalizeOptionalNumericId(
option.rankId,
'世系排行标识',
'LINEAGE_RANK_RESPONSE_INVALID'
)
if (!rankId || rankIds.has(rankId)) {
throw lineageRankError(rankId ? '世系排行选项包含重复标识' : '世系排行选项缺少标识')
}
rankIds.add(rankId)
const rankCode = normalizeLineageRankText(option.rankCode, '排行编码')
const rankName = normalizeLineageRankText(option.rankName, '排行名称')
const rankType = normalizeLineageRankText(option.rankType, '排行类型')
const genderScope = normalizeLineageRankText(option.genderScope, '排行适用性别')
if (!['ANCESTOR', 'GENERATION'].includes(rankType)) {
throw lineageRankError('世系排行选项类型无效')
}
if (!['0', '1', '2'].includes(genderScope)) {
throw lineageRankError('世系排行选项适用性别无效')
}
const rankOrder = normalizeOptionalSafeInteger(option.rankOrder, '排行顺序')
if (rankOrder !== undefined && rankOrder < 0) {
throw lineageRankError('世系排行选项顺序无效')
}
return { rankId, rankCode, rankName, rankType, genderScope, rankOrder }
})
}
export const normalizeLineageSensitiveProfile = (value, expectedPersonId) => {
if (!value || typeof value !== 'object' || Array.isArray(value)) {
throw lineagePersonError('成员敏感健康资料响应不是对象')