Add hierarchical region data to candidate and center records
This commit is contained in:
@@ -374,7 +374,10 @@ export function createAdminRoutes(context) {
|
||||
const proposedRooms = db.centerChangeRooms.filter(item => item.requestId === change.id);
|
||||
const rooms = proposedRooms.map(room => ({ ...room, id: room.roomId || uid('room'), centerId }));
|
||||
const center = {
|
||||
id: centerId, schoolId: change.schoolId, code: change.code, name: change.name, address: change.address,
|
||||
id: centerId, schoolId: change.schoolId, code: change.code, name: change.name,
|
||||
provinceCode: change.provinceCode, provinceName: change.provinceName, cityCode: change.cityCode,
|
||||
cityName: change.cityName, districtCode: change.districtCode, districtName: change.districtName,
|
||||
address: change.address,
|
||||
contact: change.contact, managerName: change.managerName, managerPhone: change.managerPhone,
|
||||
emergencyPhone: change.emergencyPhone, gateOpenTime: change.gateOpenTime, transport: change.transport,
|
||||
status: change.centerStatus, notes: change.notes,
|
||||
|
||||
@@ -45,7 +45,8 @@ export function createCandidateRoutes(context) {
|
||||
buildWorkbook,
|
||||
hasExcelResource,
|
||||
parseWorkbook,
|
||||
adminLevelNames
|
||||
adminLevelNames,
|
||||
resolveRegion
|
||||
} = context;
|
||||
|
||||
async function handleCandidate(request, response, pathname) {
|
||||
@@ -75,6 +76,9 @@ export function createCandidateRoutes(context) {
|
||||
const body = await readJson(request);
|
||||
const fields = ['name', 'gender', 'idNumber', 'phone', 'email', 'address', 'emergencyContact', 'emergencyPhone', 'nativePlace', 'birthDate', 'ethnicity', 'postalCode', 'guardianName', 'guardianPhone'];
|
||||
for (const field of fields) profile[field] = cleanText(body[field], field === 'address' ? 160 : 80);
|
||||
const region = resolveRegion(body);
|
||||
if (!region) return sendError(response, 400, '请选择有效的省、市和区县');
|
||||
Object.assign(profile, region);
|
||||
const school = db.schools.find(item => item.id === cleanText(body.schoolId, 64) && item.active);
|
||||
const schoolClass = db.classes.find(item => item.id === cleanText(body.classId, 64) && item.schoolId === school?.id && item.active);
|
||||
if (!school || !schoolClass) return sendError(response, 400, '请选择有效的学校和班级');
|
||||
@@ -82,7 +86,7 @@ export function createCandidateRoutes(context) {
|
||||
profile.classId = schoolClass.id;
|
||||
profile.school = school.name;
|
||||
profile.grade = schoolClass.name;
|
||||
if (!profile.name || !['男', '女'].includes(profile.gender) || !profile.idNumber || profile.idNumber.startsWith('PENDING-') || !profile.nativePlace || !profile.address || !profile.phone || !profile.email || !profile.school || !profile.classId) return sendError(response, 400, '请完整填写姓名、性别、证件号码、籍贯、家庭住址、手机号、邮箱、学校和班级');
|
||||
if (!profile.name || !['男', '女'].includes(profile.gender) || !profile.idNumber || profile.idNumber.startsWith('PENDING-') || !profile.nativePlace || !profile.address || !profile.phone || !profile.email || !profile.school || !profile.classId) return sendError(response, 400, '请完整填写姓名、性别、证件号码、籍贯、省市区县、家庭住址、手机号、邮箱、学校和班级');
|
||||
if (db.candidateProfiles.some(item => item.id !== profile.id && item.idNumber === profile.idNumber)) return sendError(response, 409, '证件号码已被其他考生使用');
|
||||
profile.status = 'pending';
|
||||
profile.profileCompleted = true;
|
||||
|
||||
Reference in New Issue
Block a user