feat: 完成前端业务闭环与后端联调
This commit is contained in:
@@ -23,6 +23,7 @@ export const normalizeLineageWritePayload = (payload) => {
|
||||
'appUserId',
|
||||
'personNo',
|
||||
'name',
|
||||
'courtesyName',
|
||||
'aliasName',
|
||||
'sex',
|
||||
'generationName',
|
||||
@@ -32,13 +33,23 @@ export const normalizeLineageWritePayload = (payload) => {
|
||||
'birthDate',
|
||||
'birthLunar',
|
||||
'birthPlace',
|
||||
'zodiacCode',
|
||||
'currentAddress',
|
||||
'mobile',
|
||||
'email',
|
||||
'educationCode',
|
||||
'occupation',
|
||||
'deathDate',
|
||||
'deathLunar',
|
||||
'deathAge',
|
||||
'deathPlace',
|
||||
'deathExpressionCode',
|
||||
'burialDate',
|
||||
'burialPlace',
|
||||
'biography',
|
||||
'remark',
|
||||
'relationName',
|
||||
'relationVariantCode',
|
||||
'generation',
|
||||
'personStatus',
|
||||
'sortOrder'
|
||||
@@ -79,15 +90,24 @@ export const normalizeLineageWritePayload = (payload) => {
|
||||
['personNo', '人物编号', null],
|
||||
['sex', '性别', null],
|
||||
['generationName', '字辈', 12],
|
||||
['aliasName', '别名或曾用名', null],
|
||||
['courtesyName', '表字', 40],
|
||||
['aliasName', '别号或曾用名', 40],
|
||||
['birthLunar', '出生农历', null],
|
||||
['birthPlace', '出生地', null],
|
||||
['birthPlace', '出生地', 120],
|
||||
['zodiacCode', '生肖编码', 60],
|
||||
['currentAddress', '现居地', 120],
|
||||
['mobile', '联系电话', 30],
|
||||
['email', '电子邮箱', 254],
|
||||
['educationCode', '学历分类编码', 60],
|
||||
['occupation', '职业', 80],
|
||||
['deathLunar', '逝世农历', null],
|
||||
['deathPlace', '逝世地', null],
|
||||
['burialPlace', '安葬地', null],
|
||||
['deathPlace', '逝世地', 120],
|
||||
['deathExpressionCode', '逝世表述编码', 60],
|
||||
['burialPlace', '安葬地', 120],
|
||||
['biography', '人物简介', 500],
|
||||
['remark', '备注', null],
|
||||
['relationName', '关系显示名称', null],
|
||||
['relationVariantCode', '关系显示修饰编码', 60],
|
||||
['personStatus', '人物状态', null]
|
||||
]) {
|
||||
if (payload[field] === undefined) continue
|
||||
@@ -98,9 +118,13 @@ export const normalizeLineageWritePayload = (payload) => {
|
||||
}
|
||||
if (normalizedText) normalizedPayload[field] = normalizedText
|
||||
}
|
||||
if (normalizedPayload.email && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(normalizedPayload.email)) {
|
||||
throw new TypeError('人物电子邮箱格式无效')
|
||||
}
|
||||
for (const [field, label] of [
|
||||
['birthDate', '出生日期'],
|
||||
['deathDate', '离世日期']
|
||||
['deathDate', '离世日期'],
|
||||
['burialDate', '安葬日期']
|
||||
]) {
|
||||
if (payload[field] === undefined) continue
|
||||
const normalizedDate = normalizeLineagePersonDate(payload[field], label)
|
||||
@@ -109,6 +133,16 @@ export const normalizeLineageWritePayload = (payload) => {
|
||||
if (normalizedPayload.birthDate && normalizedPayload.deathDate && normalizedPayload.deathDate < normalizedPayload.birthDate) {
|
||||
throw new TypeError('人物离世日期不能早于出生日期')
|
||||
}
|
||||
if (normalizedPayload.deathDate && normalizedPayload.burialDate && normalizedPayload.burialDate < normalizedPayload.deathDate) {
|
||||
throw new TypeError('人物安葬日期不能早于离世日期')
|
||||
}
|
||||
if (payload.deathAge !== undefined && payload.deathAge !== null && payload.deathAge !== '') {
|
||||
const deathAge = typeof payload.deathAge === 'number' ? payload.deathAge : Number(payload.deathAge)
|
||||
if (!Number.isSafeInteger(deathAge) || deathAge < 0 || deathAge > 200) {
|
||||
throw new TypeError('人物享年必须是 0 至 200 的整数')
|
||||
}
|
||||
normalizedPayload.deathAge = deathAge
|
||||
}
|
||||
if (payload.sortOrder !== undefined && payload.sortOrder !== null && payload.sortOrder !== '') {
|
||||
const sortOrder = typeof payload.sortOrder === 'number' ? payload.sortOrder : Number(payload.sortOrder)
|
||||
if (!Number.isSafeInteger(sortOrder)) throw new TypeError('人物排序值必须是安全整数')
|
||||
|
||||
Reference in New Issue
Block a user