| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162 |
- #!/usr/bin/env node
- import { randomBytes } from 'node:crypto';
- import { readFile } from 'node:fs/promises';
- const APP_ID = process.env.XIAOSHU_PARSE_APP_ID || '7pIbDBJmKx_main';
- const MASTER_KEY = process.env.XIAOSHU_MASTER_KEY || '';
- const PARSE_URL = (process.env.XIAOSHU_PARSE_URL || 'https://server.xiaoshu.pro/parse').replace(/\/$/, '');
- const FUNCTION_URL = (process.env.XIAOSHU_FUNCTION_URL || 'https://server.xiaoshu.pro/api/functions').replace(/\/$/, '');
- if (!MASTER_KEY) throw new Error('缺少 XIAOSHU_MASTER_KEY');
- async function jsonRequest(url, init = {}, master = false) {
- const response = await fetch(url, {
- ...init,
- headers: {
- 'X-Parse-Application-Id': APP_ID,
- ...(master ? { 'X-Parse-Master-Key': MASTER_KEY } : {}),
- 'Content-Type': 'application/json',
- ...(init.headers || {}),
- },
- });
- const payload = await response.json().catch(() => ({}));
- if (!response.ok) {
- const detail = payload.message || payload.error || payload;
- throw new Error(`${response.status}: ${typeof detail === 'string' ? detail : JSON.stringify(detail)}`);
- }
- return payload;
- }
- async function callFunction(path, token, params) {
- const payload = await jsonRequest(`${FUNCTION_URL}/${path}`, {
- method: 'POST',
- body: JSON.stringify({ token, params }),
- });
- if (!payload.success) throw new Error(payload.message || `${path} 返回失败`);
- return payload.data;
- }
- async function callFunctionError(path, token, params, expectedStatus) {
- const response = await fetch(`${FUNCTION_URL}/${path}`, {
- method: 'POST',
- headers: { 'X-Parse-Application-Id': APP_ID, 'Content-Type': 'application/json' },
- body: JSON.stringify({ token, params }),
- });
- const payload = await response.json().catch(() => ({}));
- if (response.status !== expectedStatus || payload.success !== false) throw new Error(`${path} 期望 ${expectedStatus} 失败,实际 ${response.status}: ${payload.message || payload.error || ''}`);
- return payload;
- }
- async function callLegacyFunction(token, params, expectedStatus = 200) {
- const response = await fetch(`${FUNCTION_URL}/xiaoshu/app/gateway`, {
- method: 'POST',
- headers: { 'X-Parse-Application-Id': APP_ID, 'Content-Type': 'application/json' },
- body: JSON.stringify({ ...(token ? { token } : {}), params }),
- });
- const payload = await response.json().catch(() => ({}));
- if (response.status !== expectedStatus) throw new Error(`app gateway ${params.action} 期望 ${expectedStatus},实际 ${response.status}: ${payload.retmsg || payload.error || ''}`);
- return payload;
- }
- async function sourceActions() {
- const source = await readFile(new URL('../projects/xiaoshu-mobile/src/app/core/source-parity.generated.ts', import.meta.url), 'utf8');
- const match = source.match(/export const SOURCE_API_ACTIONS = (\[[\s\S]*?\]) as const;/);
- if (!match) throw new Error('无法读取 SOURCE_API_ACTIONS');
- return JSON.parse(match[1]);
- }
- let userId = '';
- let adminCreatedUserId = '';
- let temporaryGroupObjectId = '';
- const temporaryNodeObjectIds = [];
- const temporarySpecialObjectIds = [];
- const temporaryGuestCategoryObjectIds = [];
- const temporaryExamClassObjectIds = [];
- const temporaryExamPointObjectIds = [];
- const temporaryKnowledgeObjectIds = [];
- let temporaryExamTeacherId = '';
- const temporaryDictionaryCategoryIds = [];
- const temporaryDictionaryItemIds = [];
- const temporaryGradeCategoryIds = [];
- const temporaryGradeOptionIds = [];
- let temporaryModelObjectId = '';
- const temporaryModelFieldObjectIds = [];
- let registeredUserId = '';
- let memberId = '';
- let memberLegacyId = 0;
- let teamChildId = '';
- let coachId = '';
- let coachLegacyId = 0;
- let temporaryAppointmentId = '';
- let temporaryAppointmentObjectId = '';
- let temporaryGuestbookId = '';
- let temporaryGuestbookReplyId = '';
- let temporaryGuestBarId = '';
- let contentHitObjectId = '';
- let contentHitOriginal = 0;
- let adZoneRestore = null;
- let adInfoRestore = null;
- let fontShapeRestore = null;
- let temporaryFontShapeId = '';
- let temporaryFontShapeTypeId = '';
- let designResourceRestore = null;
- let temporaryDesignResourceId = '';
- let temporaryDesignSceneId = '';
- let temporaryDesignSceneTemplateId = '';
- let temporaryDesignSceneCloneId = '';
- let temporaryDesignTemplateId = '';
- let temporaryDesignTemplateSceneId = '';
- let temporaryRoleId = '';
- let temporaryRoleAuthId = '';
- let surveyRestore = null;
- let surveyQuestionRestore = null;
- let temporarySurveyId = '';
- const temporarySurveyQuestionIds = [];
- let temporarySurveyAnswerId = '';
- let serviceSeatRestore = null;
- let serviceCodeRestore = null;
- let temporaryServiceSeatId = '';
- let temporaryServiceCodeId = '';
- let storeApplicationRestore = null;
- let storeStyleRestore = null;
- let temporaryStoreApplicationId = '';
- let temporaryStoreStyleId = '';
- let contentTagsRestore = null;
- let userLevelRestore = null;
- let temporaryUserLevelId = '';
- let baikeRestore = null;
- let temporaryCrmClientTypeId = '';
- let temporaryShopFareTemplateId = '';
- let temporaryMisTypeId = '';
- let temporaryPageStyleId = '';
- let temporaryPlatformCompanyId = '';
- let temporaryPlatformMemberId = '';
- const temporaryLessonIds = [];
- const temporaryBalanceLogs = [];
- try {
- const sample = await jsonRequest(`${PARSE_URL}/classes/Company?limit=1&keys=objectId`, {}, true);
- const companyId = sample.results?.[0]?.objectId;
- if (!companyId) throw new Error('没有可用于帐套隔离测试的 Company');
- const company = { __type: 'Pointer', className: 'Company', objectId: companyId };
- const username = `codex_admin_smoke_${Date.now()}`;
- const password = randomBytes(24).toString('base64url');
- const created = await jsonRequest(`${PARSE_URL}/users`, {
- method: 'POST',
- body: JSON.stringify({ username, password, isAdmin: true, roles: ['admin', 'super-admin'], adminRoleKey: 'super-admin', company }),
- }, true);
- userId = created.objectId;
- const login = await jsonRequest(`${PARSE_URL}/login`, {
- method: 'POST',
- body: JSON.stringify({ username, password }),
- });
- if (!login.sessionToken) throw new Error('临时管理员登录未返回 sessionToken');
- const registeredUsername = `codex_register_smoke_${Date.now()}`;
- const registered = await callLegacyFunction('', { action: 'user_register', name: registeredUsername, passwd: 'Ab1234' });
- registeredUserId = String(registered.result?.objectId || '');
- const registeredLegacyId = Number(registered.result?.userId);
- if (!registeredUserId || !registeredLegacyId || !registered.result?.sessionToken || Number(registered.result?.groupId) !== 1 || Number(registered.addon?.parentUserId) !== 0) throw new Error(`新用户注册基础字段异常:${JSON.stringify(registered)}`);
- const registeredInfo = await callLegacyFunction(registered.result.sessionToken, { action: 'user_get', uid: registeredLegacyId });
- if (Number(registeredInfo.result?.userId) !== registeredLegacyId || Number(registeredInfo.result?.groupId) !== 1 || Number(registeredInfo.addon?.Purse) !== 0 || Number(registeredInfo.addon?.UserPoint) !== 0) throw new Error('新用户注册后自查异常');
- const registeredByName = await callLegacyFunction('', { action: 'user_info_name', uname: registeredUsername });
- if (registeredByName.result?.objectId !== registeredUserId) throw new Error('新用户用户名查重异常');
- await jsonRequest(`${PARSE_URL}/users/${registeredUserId}`, { method: 'DELETE' }, true);
- registeredUserId = '';
- const memberUsername = `codex_member_smoke_${Date.now()}`;
- const memberPassword = randomBytes(24).toString('base64url');
- memberLegacyId = 900000000 + Math.floor(Date.now() / 1000) % 90000000;
- const member = await jsonRequest(`${PARSE_URL}/users`, {
- method: 'POST',
- body: JSON.stringify({ username: memberUsername, password: memberPassword, legacyUserId: memberLegacyId, legacyGroupId: 1, legacyUserData: { UserID: memberLegacyId, UserName: memberUsername, HoneyName: '冒烟学员', GroupID: 1, ParentUserID: 0, VIP: 2, Purse: 2, SilverCoin: 2, UserExp: 2, UserPoint: 2 }, company }),
- }, true);
- memberId = member.objectId;
- const childLegacyId = memberLegacyId + 2;
- const child = await jsonRequest(`${PARSE_URL}/users`, {
- method: 'POST',
- body: JSON.stringify({ username: `codex_team_child_${Date.now()}`, password: randomBytes(24).toString('base64url'), legacyUserId: childLegacyId, legacyGroupId: 3, legacyUserData: { UserID: childLegacyId, UserName: `team_child_${childLegacyId}`, HoneyName: '冒烟团队成员', GroupID: 3, ParentUserID: memberLegacyId, VIP: 3, UserExp: 5, UserPwd: 'must-not-leak' }, company }),
- }, true);
- teamChildId = child.objectId;
- const coachUsername = `codex_coach_smoke_${Date.now()}`;
- const coachPassword = randomBytes(24).toString('base64url');
- coachLegacyId = memberLegacyId + 1;
- const coach = await jsonRequest(`${PARSE_URL}/users`, {
- method: 'POST',
- body: JSON.stringify({ username: coachUsername, password: coachPassword, legacyUserId: coachLegacyId, legacyGroupId: 3, company }),
- }, true);
- coachId = coach.objectId;
- for (const lessonType of [1, 2, 3]) {
- const lesson = await jsonRequest(`${PARSE_URL}/classes/LessonRecord`, {
- method: 'POST',
- body: JSON.stringify({ company, sourceKey: `cloud:smoke-lesson:${coachLegacyId}:${lessonType}`, jsmz: String(coachLegacyId), kclx: String(lessonType) }),
- }, true);
- temporaryLessonIds.push(lesson.objectId);
- }
- const memberLogin = await jsonRequest(`${PARSE_URL}/login`, {
- method: 'POST',
- body: JSON.stringify({ username: memberUsername, password: memberPassword }),
- });
- const coachLogin = await jsonRequest(`${PARSE_URL}/login`, {
- method: 'POST',
- body: JSON.stringify({ username: coachUsername, password: coachPassword }),
- });
- const feedbackModel = { UserID: memberLegacyId, Title: '冒烟学员 反馈的意见', TContent: '2026-08-19 请假一天', Cateid: 22 };
- const feedback = await callLegacyFunction(memberLogin.sessionToken, { action: 'guestbook_add', model: JSON.stringify(feedbackModel) });
- temporaryGuestbookId = String(feedback.result?.objectId || '');
- if (!temporaryGuestbookId || Number(feedback.result?.UserID) !== memberLegacyId || feedback.result?.Title !== feedbackModel.Title || feedback.result?.TContent !== feedbackModel.TContent || Number(feedback.result?.Cateid) !== 22) throw new Error(`旧版 model 留言写入异常:${JSON.stringify(feedback)}`);
- await callLegacyFunction(memberLogin.sessionToken, { action: 'guestbook_add', model: JSON.stringify({ ...feedbackModel, UserID: coachLegacyId }) }, 403);
- const profileModel = { honeyName: '冒烟资料更新', trueName: '测试学员', userFace: '/UploadFiles/smoke-avatar.png', sex: '女', birthday: '2000-01-02', mobile: '13800138000', Email: `${memberUsername}@example.test`, seturl: '/member/smoke', Position: '词汇小英雄' };
- const updatedProfile = await callLegacyFunction(memberLogin.sessionToken, { action: 'user_update', uid: memberLegacyId, mu: JSON.stringify(profileModel), inviCode: '' });
- if (updatedProfile.result?.honeyName !== profileModel.honeyName || updatedProfile.result?.userFace !== profileModel.userFace || updatedProfile.result?.email !== profileModel.Email || updatedProfile.result?.seturl !== profileModel.seturl) throw new Error(`旧版 mu 用户资料更新异常:${JSON.stringify(updatedProfile)}`);
- await callLegacyFunction(memberLogin.sessionToken, { action: 'user_update', uid: coachLegacyId, mu: JSON.stringify({ honeyName: '越权' }) }, 403);
- await callLegacyFunction(memberLogin.sessionToken, { action: 'user_update_pwd', uid: memberLegacyId, vcode: '123456', newPass: 'Ab1234', reNewPass: 'Ab1234' }, 501);
- await callLegacyFunction(memberLogin.sessionToken, { action: 'user_update_pwdall', uid: memberLegacyId, login: 'Ab1234', pay: '123456' }, 501);
- const createdAppointment = await callLegacyFunction(login.sessionToken, { action: 'content_add', content: JSON.stringify({ ModelID: 54, nodeId: 29, inputer: coachUsername, status: 99, title: memberUsername }), addon: JSON.stringify({ szyh: memberLegacyId, kcid: 16, dslx: 1, dszt: 0, pl: coachLegacyId, fxpl: coachLegacyId, sdsd: '19:00' }) });
- temporaryAppointmentId = String(createdAppointment.result);
- const appointmentSourceKey = `cloud:content_add:${memberLegacyId}:${temporaryAppointmentId}`;
- const appointmentWhere = encodeURIComponent(JSON.stringify({ sourceKey: appointmentSourceKey }));
- const appointmentRows = await jsonRequest(`${PARSE_URL}/classes/CourseAppointment?where=${appointmentWhere}&limit=1`, {}, true);
- temporaryAppointmentObjectId = appointmentRows.results?.[0]?.objectId || '';
- if (!temporaryAppointmentObjectId) throw new Error('临时预约副表创建失败');
- const appointmentCommonRows = await jsonRequest(`${PARSE_URL}/classes/CommonModel?where=${appointmentWhere}&limit=1`, {}, true);
- const temporaryAppointmentCommonObjectId = String(appointmentCommonRows.results?.[0]?.objectId || '');
- if (!temporaryAppointmentCommonObjectId) throw new Error('临时预约主内容创建失败');
- const meta = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'meta' });
- if (meta.identity?.objectId !== userId || !meta.cloudFunctions) throw new Error('管理员 meta 校验失败');
- const dashboard = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'techDashboard' });
- if (!Array.isArray(dashboard.metrics) || dashboard.metrics.length !== 8) throw new Error('dashboard 指标校验失败');
- const catalog = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'catalog' });
- if (!Array.isArray(catalog.resources) || catalog.resources.length < 90 || catalog.resources.some((item) => ['_Session', 'Function'].includes(item.className))) throw new Error('后台规范化类目录校验失败');
- const managedUsername = `codex_admin_created_${Date.now()}`;
- const managedPassword = randomBytes(24).toString('base64url');
- const managed = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'createUser', username: managedUsername, password: managedPassword, displayName: '后台开户冒烟', mobile: '13800138001', isAdmin: true, roles: ['admin'] });
- adminCreatedUserId = String(managed.objectId || '');
- if (!adminCreatedUserId || !Number(managed.userId) || Number(managed.groupId) !== 1 || managed.isAdmin === true || managed.roles?.includes?.('admin') || managed.sessionToken) throw new Error(`管理员开户响应异常:${JSON.stringify(managed)}`);
- const managedStored = await jsonRequest(`${PARSE_URL}/users/${adminCreatedUserId}`, {}, true);
- if (managedStored.username !== managedUsername || managedStored.isAdmin === true || managedStored.roles?.includes?.('admin') || Number(managedStored.legacyUserId) !== Number(managed.userId) || Number(managedStored.legacyGroupId) !== 1 || Number(managedStored.legacyUserData?.UserID) !== Number(managed.userId) || Number(managedStored.legacyUserData?.Purse) !== 0) throw new Error('管理员开户持久化约束校验失败');
- const managedLogin = await jsonRequest(`${PARSE_URL}/login`, { method: 'POST', body: JSON.stringify({ username: managedUsername, password: managedPassword }) });
- if (!managedLogin.sessionToken) throw new Error('后台开户用户登录失败');
- const locked = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'userBatch', className: '_User', action: 'lock', objectIds: [adminCreatedUserId], reason: '云函数冒烟' });
- if (locked.updated !== 1 || locked.results?.[0]?.isDisabled !== true || Number(locked.results?.[0]?.legacyUserData?.State) !== 0 || Number(locked.revokedSessions) < 1) throw new Error(`用户停用与会话撤销异常:${JSON.stringify(locked)}`);
- await callLegacyFunction('', { action: 'user_login_passwd', name: managedUsername, passwd: managedPassword }, 403);
- const unlocked = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'userBatch', className: '_User', action: 'unlock', objectIds: [adminCreatedUserId], reason: '恢复冒烟用户' });
- if (unlocked.updated !== 1 || unlocked.results?.[0]?.isDisabled !== false || Number(unlocked.results?.[0]?.legacyUserData?.State) !== 1) throw new Error(`用户解锁异常:${JSON.stringify(unlocked)}`);
- const temporaryGroup = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveGroup', className: 'Group', fields: { groupName: '云函数冒烟临时组', description: '验证帐套内原子组编号', parentGroupId: 0, regSelect: false } });
- temporaryGroupObjectId = String(temporaryGroup.objectId || '');
- const temporaryGroupNumber = Number(temporaryGroup.groupId);
- if (!temporaryGroupObjectId || !temporaryGroupNumber) throw new Error('临时用户组创建失败');
- const moved = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'userBatch', className: '_User', action: 'move', objectIds: [adminCreatedUserId], groupId: temporaryGroupNumber });
- if (moved.updated !== 1 || Number(moved.results?.[0]?.legacyGroupId) !== temporaryGroupNumber || Number(moved.results?.[0]?.legacyUserData?.GroupID) !== temporaryGroupNumber) throw new Error(`用户组同步异常:${JSON.stringify(moved)}`);
- const groupDeleteBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'Group', objectId: temporaryGroupObjectId }, 409);
- if (!String(groupDeleteBlocked.message).includes('仍有用户')) throw new Error('用户组引用删除保护未返回明确原因');
- const managedAppLogin = await callLegacyFunction('', { action: 'user_login_passwd', name: managedUsername, passwd: managedPassword });
- if (!managedAppLogin.result?.sessionToken || Number(managedAppLogin.addon?.State) !== 1) throw new Error('解锁后旧版登录异常');
- await jsonRequest(`${PARSE_URL}/users/${adminCreatedUserId}`, { method: 'DELETE' }, true);
- adminCreatedUserId = '';
- const deletedGroup = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'Group', objectId: temporaryGroupObjectId });
- if (deletedGroup.objectId !== temporaryGroupObjectId) throw new Error('无引用用户组删除失败');
- temporaryGroupObjectId = '';
- const schema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'CourseAppointment' });
- if (schema.className !== 'CourseAppointment' || !Array.isArray(schema.fields)) throw new Error('schema 校验失败');
- const contentSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'CommonModel' });
- const contentFieldMap = Object.fromEntries((contentSchema.fields || []).map((field) => [field.name, field]));
- if (contentSchema.creatable !== false || contentFieldMap.status?.writable !== false || contentFieldMap.modelId?.writable !== false || contentFieldMap.itemId?.writable !== false || contentFieldMap.nodeId?.writable !== false) throw new Error('内容结构字段未从通用创建/编辑中隔离');
- const nodeSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'Node' });
- const nodeFieldMap = Object.fromEntries((nodeSchema.fields || []).map((field) => [field.name, field]));
- if (nodeFieldMap.nodeId?.writable !== false || nodeFieldMap.parentId?.writable !== false || nodeFieldMap.depth?.writable !== false || nodeFieldMap.zstatus?.writable !== false || nodeFieldMap.sourceKey?.writable !== false) throw new Error('栏目结构字段未从通用编辑中隔离');
- const holidaySchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'SysHoliday' });
- const holidayFieldMap = Object.fromEntries((holidaySchema.fields || []).map((field) => [field.name, field]));
- if (holidaySchema.creatable !== false || ['id','cdate','cadminId','cuserId','sourceKey'].some((name) => holidayFieldMap[name]?.writable !== false)) throw new Error('节假日系统字段未从新增或通用编辑中隔离');
- const holidayPage = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'list', className: 'SysHoliday', page: 1, pageSize: 20 });
- if (!Array.isArray(holidayPage.results)) throw new Error('节假日列表返回异常');
- const searchNavigationSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'Search' });
- const searchNavigationFieldMap = Object.fromEntries((searchNavigationSchema.fields || []).map((field) => [field.name, field]));
- if (searchNavigationSchema.creatable !== false || ['id','type','state','time','adminId','orderId','linkType','linkState','sourceKey'].some((name) => searchNavigationFieldMap[name]?.writable !== false)) throw new Error('快捷入口结构字段未从新增或通用编辑中隔离');
- const searchNavigationPage = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'searchNavigations', className: 'Search', type: 1, state: -100, elite: -100, page: 1, pageSize: 20 });
- if (!Array.isArray(searchNavigationPage.results) || !searchNavigationPage.results.length || searchNavigationPage.results.some((entry) => Number(entry.type) !== 1)) throw new Error('后台快捷入口筛选列表返回异常');
- const apiCatalog = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'apiCatalog' });
- if (!Array.isArray(apiCatalog.results) || apiCatalog.results.length < 9 || apiCatalog.results.some((entry) => !String(entry.path || '').startsWith('xiaoshu/') || Object.prototype.hasOwnProperty.call(entry, 'code'))) throw new Error('云函数接口目录缺失或泄露了源码');
- const adZoneSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'AdZone' });
- const adZoneFieldMap = Object.fromEntries((adZoneSchema.fields || []).map((field) => [field.name, field]));
- if (adZoneSchema.creatable !== false || ['id','cdate','cadmin','image','sourceKey'].some((name) => adZoneFieldMap[name]?.writable !== false)) throw new Error('广告位系统字段未从新增或通用编辑中隔离');
- const adInfoSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'AdInfo' });
- const adInfoFieldMap = Object.fromEntries((adInfoSchema.fields || []).map((field) => [field.name, field]));
- if (adInfoSchema.creatable !== false || ['id','cdate','zoneId','ztype','extend1','extend2','extend3','sourceKey'].some((name) => adInfoFieldMap[name]?.writable !== false)) throw new Error('广告内容系统字段未从新增或通用编辑中隔离');
- const adZonePage = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'adZones', className: 'AdZone', page: 1, pageSize: 20, status: -100, type: '' });
- const sampleAdZone = adZonePage.results?.[0]; if (!sampleAdZone?.objectId || !sampleAdZone.id) throw new Error('广告位专用列表没有返回历史广告位');
- const adInfoPage = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'adInfos', className: 'AdInfo', page: 1, pageSize: 20, status: -100, zoneId: String(sampleAdZone.id) });
- const sampleAdInfo = adInfoPage.results?.[0]; if (!sampleAdInfo?.objectId || String(sampleAdInfo.zoneId) !== String(sampleAdZone.id)) throw new Error('广告内容按广告位筛选异常');
- const zoneCreateBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveAdZone', className: 'AdZone', fields: {} }, 501);
- const infoCreateBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveAdInfo', className: 'AdInfo', fields: {} }, 501);
- if (!String(zoneCreateBlocked.message).includes('AdZone.id') || !String(infoCreateBlocked.message).includes('AdInfo.id')) throw new Error('广告新增未返回旧 ID 明确阻塞原因');
- adZoneRestore = { objectId: sampleAdZone.objectId, remind: String(sampleAdZone.remind || ''), zstatus: Number(sampleAdZone.zstatus) };
- const zoneProbeRemind = `${adZoneRestore.remind} [angular-smoke]`.trim();
- const updatedAdZone = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveAdZone', className: 'AdZone', objectId: sampleAdZone.objectId, fields: { ...sampleAdZone, remind: zoneProbeRemind } });
- if (updatedAdZone.remind !== zoneProbeRemind) throw new Error('广告位专用编辑未写入备注');
- const zoneToggleAction = adZoneRestore.zstatus === 99 ? 'pause' : 'active'; const toggledZone = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'adZoneBatch', className: 'AdZone', action: zoneToggleAction, objectIds: [sampleAdZone.objectId] });
- if (Number(toggledZone.results?.[0]?.zstatus) !== (zoneToggleAction === 'active' ? 99 : 0)) throw new Error('广告位启停批量操作异常');
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveAdZone', className: 'AdZone', objectId: sampleAdZone.objectId, fields: { ...sampleAdZone, remind: adZoneRestore.remind, zstatus: adZoneRestore.zstatus } }); adZoneRestore = null;
- adInfoRestore = { objectId: sampleAdInfo.objectId, remind: String(sampleAdInfo.remind || ''), zstatus: Number(sampleAdInfo.zstatus) };
- const infoProbeRemind = `${adInfoRestore.remind} [angular-smoke]`.trim();
- const updatedAdInfo = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveAdInfo', className: 'AdInfo', objectId: sampleAdInfo.objectId, zoneId: String(sampleAdInfo.zoneId), fields: { ...sampleAdInfo, remind: infoProbeRemind } });
- if (updatedAdInfo.remind !== infoProbeRemind) throw new Error('广告内容专用编辑未写入备注');
- const infoToggleAction = adInfoRestore.zstatus === 99 ? 'unaudit' : 'audit'; const toggledInfo = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'adInfoBatch', className: 'AdInfo', action: infoToggleAction, objectIds: [sampleAdInfo.objectId] });
- if (Number(toggledInfo.results?.[0]?.zstatus) !== (infoToggleAction === 'audit' ? 99 : 0)) throw new Error('广告内容审核批量操作异常');
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveAdInfo', className: 'AdInfo', objectId: sampleAdInfo.objectId, zoneId: String(sampleAdInfo.zoneId), fields: { ...sampleAdInfo, remind: adInfoRestore.remind, zstatus: adInfoRestore.zstatus } }); adInfoRestore = null;
- const adPreview = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'adPreview', zoneObjectId: sampleAdZone.objectId }); if (!adPreview.zone?.objectId || !Array.isArray(adPreview.results)) throw new Error('广告位当前生效广告预览异常');
- const fontShapeTypeSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'FontPicShapeType' }); const fontShapeTypeFieldMap = Object.fromEntries((fontShapeTypeSchema.fields || []).map((field) => [field.name, field])); if (fontShapeTypeSchema.creatable !== false || ['id','sourceKey','createTime','updateTime'].some((name) => fontShapeTypeFieldMap[name]?.writable !== false)) throw new Error('图形分类系统字段未隔离');
- const fontShapeSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'FontPicShape' }); const fontShapeFieldMap = Object.fromEntries((fontShapeSchema.fields || []).map((field) => [field.name, field])); if (fontShapeSchema.creatable !== false || ['id','shape','typeId','userId','userName','sourceKey','createTime','updateTime'].some((name) => fontShapeFieldMap[name]?.writable !== false)) throw new Error('图形素材系统字段未隔离');
- const fontShapeTypes = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'fontShapeTypes', className: 'FontPicShapeType', page: 1, pageSize: 1000, search: '' }); if (!fontShapeTypes.results?.length) throw new Error('图形分类列表缺少历史数据');
- const allFontShapes = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'fontShapes', className: 'FontPicShape', page: 1, pageSize: 20, typeId: 0, search: '' }); const sampleFontShape = allFontShapes.results?.[0]; const sampleFontShapeType = fontShapeTypes.results.find((entry) => Number(entry.id) === Number(sampleFontShape?.typeId)); if (!sampleFontShape?.objectId || !sampleFontShapeType?.objectId) throw new Error('图形素材与分类历史关系异常'); const filteredFontShapes = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'fontShapes', className: 'FontPicShape', page: 1, pageSize: 20, typeId: Number(sampleFontShapeType.id), search: '' }); if (!filteredFontShapes.results?.length || filteredFontShapes.results.some((entry) => Number(entry.typeId) !== Number(sampleFontShapeType.id))) throw new Error('图形素材按分类筛选异常');
- const fontShapeCreateBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveFontShape', className: 'FontPicShape', fields: {} }, 501); const fontShapeTypeCreateBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveFontShapeType', className: 'FontPicShapeType', fields: {} }, 501); if (!String(fontShapeCreateBlocked.message).includes('FontPicShape.id') || !String(fontShapeTypeCreateBlocked.message).includes('FontPicShapeType.id')) throw new Error('图形素材新增未返回旧 ID 阻塞原因');
- for (const action of ['Index','FontPicInfo','FontPicInfo_Submit','FontPic_API','Draft','DraftInfo','DraftInfo_Submit','Draft_API']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyFontPicBlocker', action }, 501); if (!String(blocked.message).startsWith('migration_blocked:')) throw new Error(`旧字体图动作 ${action} 未返回明确阻塞原因`); }
- fontShapeRestore = { objectId: sampleFontShape.objectId, shape: String(sampleFontShape.shape || ''), remarks: String(sampleFontShape.remarks || ''), typeId: Number(sampleFontShape.typeId), updateTime: sampleFontShape.updateTime };
- const shapeProbeRemarks = `${fontShapeRestore.remarks} [angular-smoke]`.trim(); const updatedShape = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveFontShape', className: 'FontPicShape', objectId: sampleFontShape.objectId, typeId: fontShapeRestore.typeId, fields: { ...sampleFontShape, remarks: shapeProbeRemarks } }); if (updatedShape.remarks !== shapeProbeRemarks || Number(updatedShape.typeId) !== fontShapeRestore.typeId || String(updatedShape.shape || '') !== fontShapeRestore.shape) throw new Error('图形素材元数据专用编辑异常');
- const fileBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveFontShape', className: 'FontPicShape', objectId: sampleFontShape.objectId, typeId: fontShapeRestore.typeId, fields: { ...sampleFontShape, remarks: shapeProbeRemarks }, file: { name: 'font-shape-smoke.png', mimeType: 'image/png', base64: 'iVBORw0KGgo=' } }, 501); if (!String(fileBlocked.message).includes('文件适配器') || !String(fileBlocked.message).includes('PostgreSQL')) throw new Error('图形文件基础设施阻塞未返回明确原因');
- const shapeRestoreBody = { shape: fontShapeRestore.shape, remarks: fontShapeRestore.remarks, typeId: fontShapeRestore.typeId, ...(fontShapeRestore.updateTime ? { updateTime: fontShapeRestore.updateTime } : {}) }; await jsonRequest(`${PARSE_URL}/classes/FontPicShape/${fontShapeRestore.objectId}`, { method: 'PUT', body: JSON.stringify(shapeRestoreBody) }, true); fontShapeRestore = null;
- const originalTypeRemarks = String(sampleFontShapeType.remarks || ''); const updatedShapeType = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveFontShapeType', className: 'FontPicShapeType', objectId: sampleFontShapeType.objectId, fields: { ...sampleFontShapeType, remarks: `${originalTypeRemarks} [angular-smoke]`.trim() } }); if (!String(updatedShapeType.remarks).endsWith('[angular-smoke]')) throw new Error('图形分类专用编辑失败'); await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveFontShapeType', className: 'FontPicShapeType', objectId: sampleFontShapeType.objectId, fields: { ...sampleFontShapeType, remarks: originalTypeRemarks } });
- const referencedTypeDelete = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'fontShapeTypeBatch', className: 'FontPicShapeType', action: 'delete', objectIds: [sampleFontShapeType.objectId] }, 409); if (!String(referencedTypeDelete.message).includes('素材引用')) throw new Error('图形分类引用删除保护未返回明确原因');
- const tempType = await jsonRequest(`${PARSE_URL}/classes/FontPicShapeType`, { method: 'POST', body: JSON.stringify({ name: '__font_shape_type_batch_smoke__', remarks: 'temporary', sourceKey: `smoke-font-shape-type-${Date.now()}`, company }) }, true); temporaryFontShapeTypeId = tempType.objectId; const deletedTempType = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'fontShapeTypeBatch', className: 'FontPicShapeType', action: 'delete', objectIds: [temporaryFontShapeTypeId] }); if (deletedTempType.updated !== 1) throw new Error('图形分类批量删除失败'); temporaryFontShapeTypeId = '';
- const tempShape = await jsonRequest(`${PARSE_URL}/classes/FontPicShape`, { method: 'POST', body: JSON.stringify({ name: '__font_shape_batch_smoke__', shape: '', typeId: Number(sampleFontShapeType.id), remarks: 'temporary', sourceKey: `smoke-font-shape-${Date.now()}`, company }) }, true); temporaryFontShapeId = tempShape.objectId; const deletedTempShape = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'fontShapeBatch', className: 'FontPicShape', action: 'delete', objectIds: [temporaryFontShapeId] }); if (deletedTempShape.updated !== 1) throw new Error('图形素材批量删除失败'); temporaryFontShapeId = '';
- const designResourceSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'DesignRes' }); const designResourceFieldMap = Object.fromEntries((designResourceSchema.fields || []).map((field) => [field.name, field])); if (designResourceSchema.creatable !== false || ['id','vpath','previewimg','cdate','userid','sourceKey'].some((name) => designResourceFieldMap[name]?.writable !== false)) throw new Error('设计资源结构字段未隔离');
- const designResources = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'designResources', className: 'DesignRes', page: 1, pageSize: 20, type: '', search: '' }); const sampleDesignResource = designResources.results?.[0]; if (!sampleDesignResource?.objectId || !sampleDesignResource.ztype || !sampleDesignResource.vpath) throw new Error('设计资源专用列表缺少历史数据'); const filteredDesignResources = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'designResources', className: 'DesignRes', page: 1, pageSize: 20, type: String(sampleDesignResource.ztype), search: '' }); if (!filteredDesignResources.results?.length || filteredDesignResources.results.some((entry) => String(entry.ztype).toLowerCase() !== String(sampleDesignResource.ztype).toLowerCase())) throw new Error('设计资源按类型筛选异常');
- const designResourceCreateBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveDesignResource', className: 'DesignRes', fields: {} }, 501); if (!String(designResourceCreateBlocked.message).includes('文件') || !String(designResourceCreateBlocked.message).includes('DesignRes.id')) throw new Error('设计资源新增未返回明确阻塞');
- const restoreDesignField = (name) => Object.prototype.hasOwnProperty.call(sampleDesignResource, name) ? (name === 'zstatus' ? Number(sampleDesignResource[name]) : sampleDesignResource[name]) : { __op: 'Delete' }; designResourceRestore = { objectId: sampleDesignResource.objectId, fields: Object.fromEntries(['name','style','use','useage','zstatus','ztype','fun'].map((name) => [name, restoreDesignField(name)])) }; const designProbeName = `${String(sampleDesignResource.name || '')} [angular-smoke]`.trim(); const updatedDesignResource = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveDesignResource', className: 'DesignRes', objectId: sampleDesignResource.objectId, fields: { ...sampleDesignResource, name: designProbeName } }); if (updatedDesignResource.name !== designProbeName || updatedDesignResource.vpath !== sampleDesignResource.vpath || updatedDesignResource.previewimg !== sampleDesignResource.previewimg) throw new Error('设计资源元数据专用编辑异常');
- const designFileBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveDesignResource', className: 'DesignRes', objectId: sampleDesignResource.objectId, fields: { ...sampleDesignResource, name: designProbeName }, file: { name: 'design-resource-smoke.png', mimeType: 'image/png', base64: 'iVBORw0KGgo=' } }, 501); if (!String(designFileBlocked.message).includes('文件适配器') || !String(designFileBlocked.message).includes('PostgreSQL')) throw new Error('设计资源文件阻塞未返回明确原因'); await jsonRequest(`${PARSE_URL}/classes/DesignRes/${designResourceRestore.objectId}`, { method: 'PUT', body: JSON.stringify(designResourceRestore.fields) }, true); designResourceRestore = null;
- const temporaryDesignResource = await jsonRequest(`${PARSE_URL}/classes/DesignRes`, { method: 'POST', body: JSON.stringify({ name: '__design_resource_batch_smoke__', ztype: 'img', useage: 'smoke', vpath: '/smoke/design-resource.png', sourceKey: `smoke-design-resource-${Date.now()}`, company }) }, true); temporaryDesignResourceId = temporaryDesignResource.objectId; const deletedTemporaryDesignResource = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'designResourceBatch', className: 'DesignRes', action: 'delete', objectIds: [temporaryDesignResourceId] }); if (deletedTemporaryDesignResource.updated !== 1) throw new Error('设计资源批量删除失败'); temporaryDesignResourceId = '';
- const designSceneSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'DesignScence' }); const designSceneFieldMap = Object.fromEntries((designSceneSchema.fields || []).map((field) => [field.name, field])); if (designSceneSchema.writable !== true || designSceneSchema.creatable !== false || ['id','guid','comp','page','path','cdate','cuser','tlpId','ztype','scence','siteId','update','company','orderId','labelArr','resource','userName','accessPwd','sourceKey'].some((name) => designSceneFieldMap[name]?.writable !== false)) throw new Error('可视化场景结构字段未隔离'); const designSceneCreateBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveDesignScene', className: 'DesignScence', fields: {} }, 501); if (!String(designSceneCreateBlocked.message).includes('设计器初始化协议')) throw new Error('场景新增未返回明确阻塞');
- const designSceneSourceKey = `smoke-design-scene-${Date.now()}`; const temporaryDesignScene = await jsonRequest(`${PARSE_URL}/classes/DesignScence`, { method: 'POST', body: JSON.stringify({ company, sourceKey: designSceneSourceKey, guid: randomBytes(16).toString('hex'), title: '__design_scene_smoke__', userId: memberLegacyId, userName: memberUsername, score: 1, status: 0, seflag: 'smoke', previewImg: '/smoke/scene-preview.png', thumbImg: '/smoke/scene-thumb.png', remind: 'temporary scene', meta: '{"smoke":true}', page: '{"page":true}', comp: '{"components":[]}', scence: '{}', resource: '[]', path: '/smoke/scene', ztype: 0, tlpId: 0 }) }, true); temporaryDesignSceneId = temporaryDesignScene.objectId;
- const normalDesignScenes = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'designScenes', className: 'DesignScence', status: -100, page: 1, pageSize: 100, search: '__design_scene_smoke__' }); if (normalDesignScenes.total !== 1 || normalDesignScenes.results?.[0]?.objectId !== temporaryDesignSceneId || normalDesignScenes.results.some((entry) => Number(entry.ztype) !== 0 || Number(entry.tlpId) !== 0 || Number(entry.status) === -2)) throw new Error('普通可视化场景范围筛选异常');
- const updatedDesignScene = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveDesignScene', className: 'DesignScence', objectId: temporaryDesignSceneId, fields: { title: '__design_scene_smoke_updated__', userId: memberLegacyId, score: 8, status: 0, seflag: 'scene-key', previewImg: '/smoke/scene-preview-2.png', thumbImg: '/smoke/scene-thumb-2.png', remind: 'updated temporary scene', meta: '{"smoke":"updated"}' } }); if (updatedDesignScene.title !== '__design_scene_smoke_updated__' || Number(updatedDesignScene.userId) !== memberLegacyId || updatedDesignScene.userName !== memberUsername || updatedDesignScene.page !== '{"page":true}' || updatedDesignScene.comp !== '{"components":[]}' || Number(updatedDesignScene.tlpId) !== 0) throw new Error('可视化场景白名单编辑或用户名同步异常');
- const createdDesignTemplate = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'createDesignSceneTemplate', className: 'DesignScence', objectId: temporaryDesignSceneId }); temporaryDesignSceneTemplateId = String(createdDesignTemplate.template?.objectId || ''); temporaryDesignSceneCloneId = String(createdDesignTemplate.scene?.objectId || ''); if (!temporaryDesignSceneTemplateId || !temporaryDesignSceneCloneId || !Number(createdDesignTemplate.template?.id) || !Number(createdDesignTemplate.scene?.id) || Number(createdDesignTemplate.template?.ztype) !== 1 || Number(createdDesignTemplate.scene?.ztype) !== 1 || Number(createdDesignTemplate.scene?.tlpId) !== Number(createdDesignTemplate.template?.id) || createdDesignTemplate.scene?.page !== '{"page":true}' || Number(createdDesignTemplate.scene?.score) !== 0 || createdDesignTemplate.scene?.accessPwd !== '' || createdDesignTemplate.scene?.seflag !== '') throw new Error('场景复制为模板的数据或原子编号异常');
- const recycledDesignScene = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'designSceneBatch', className: 'DesignScence', action: 'recycle', objectIds: [temporaryDesignSceneId] }); if (recycledDesignScene.updated !== 1 || Number(recycledDesignScene.results?.[0]?.status) !== -2) throw new Error('场景移入回收站失败'); const recycledDesignScenes = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'designScenes', className: 'DesignScence', status: -2, page: 1, pageSize: 100, search: '__design_scene_smoke_updated__' }); if (recycledDesignScenes.results?.[0]?.objectId !== temporaryDesignSceneId) throw new Error('场景回收站列表异常'); const restoredDesignScene = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'designSceneBatch', className: 'DesignScence', action: 'restore', objectIds: [temporaryDesignSceneId] }); if (restoredDesignScene.updated !== 1 || Number(restoredDesignScene.results?.[0]?.status) !== 0) throw new Error('场景恢复失败'); const deletedDesignScene = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'designSceneBatch', className: 'DesignScence', action: 'delete', objectIds: [temporaryDesignSceneId] }); if (deletedDesignScene.updated !== 1) throw new Error('场景彻底删除失败'); temporaryDesignSceneId = '';
- await jsonRequest(`${PARSE_URL}/classes/DesignScence/${temporaryDesignSceneCloneId}`, { method: 'DELETE' }, true); temporaryDesignSceneCloneId = ''; await jsonRequest(`${PARSE_URL}/classes/DesignTlp/${temporaryDesignSceneTemplateId}`, { method: 'DELETE' }, true); temporaryDesignSceneTemplateId = '';
- const designTemplateWritableSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'DesignTlp' }); const designTemplateFieldMap = Object.fromEntries((designTemplateWritableSchema.fields || []).map((field) => [field.name, field])); if (designTemplateWritableSchema.writable !== true || designTemplateWritableSchema.creatable !== true || ['id','cdate','isDef','ztype','company','sourceKey'].some((name) => designTemplateFieldMap[name]?.writable !== false) || ['tlpName','classId','price','previewImg','score','zstatus','defBy','remind'].some((name) => designTemplateFieldMap[name]?.writable !== true)) throw new Error('可视化模板字段权限异常'); const existingDesignTemplates = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'designTemplates', className: 'DesignTlp', status: -100, classId: -100, page: 1, pageSize: 100, search: '' }); if (existingDesignTemplates.total < 2 || existingDesignTemplates.results.some((entry) => Number(entry.zstatus) === -2)) throw new Error('历史可视化模板列表异常');
- const designTemplateProbe = `__design_template_smoke_${Date.now()}__`; const createdStandaloneTemplate = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveDesignTemplate', className: 'DesignTlp', fields: { tlpName: designTemplateProbe, classId: 6, price: 12.5, previewImg: '/smoke/template-preview.png', score: 3, zstatus: 0, defBy: 'smoke', remind: 'temporary template' } }); temporaryDesignTemplateId = String(createdStandaloneTemplate.objectId || ''); temporaryDesignTemplateSceneId = String(createdStandaloneTemplate.designScene?.objectId || ''); if (!temporaryDesignTemplateId || !temporaryDesignTemplateSceneId || !Number(createdStandaloneTemplate.id) || !Number(createdStandaloneTemplate.designScene?.id) || Number(createdStandaloneTemplate.designScene?.tlpId) !== Number(createdStandaloneTemplate.id) || Number(createdStandaloneTemplate.designScene?.ztype) !== 1 || !createdStandaloneTemplate.designScene?.guid) throw new Error('模板与空模板场景原子创建异常');
- const filteredDesignTemplates = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'designTemplates', className: 'DesignTlp', status: -100, classId: 6, page: 1, pageSize: 100, search: designTemplateProbe }); if (filteredDesignTemplates.total !== 1 || filteredDesignTemplates.results?.[0]?.objectId !== temporaryDesignTemplateId || Number(filteredDesignTemplates.results?.[0]?.classId) !== 6) throw new Error('模板分类或关键词筛选异常'); const designTemplateDetail = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'designTemplate', className: 'DesignTlp', objectId: temporaryDesignTemplateId }); if (designTemplateDetail.designScene?.objectId !== temporaryDesignTemplateSceneId) throw new Error(`模板与模板场景联合详情异常:${JSON.stringify({ expected: temporaryDesignTemplateSceneId, actual: designTemplateDetail.designScene, templateId: createdStandaloneTemplate.id })}`); const designEditorTarget = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'designTemplateEditorTarget', className: 'DesignTlp', objectId: temporaryDesignTemplateId }); if (designEditorTarget.guid !== createdStandaloneTemplate.designScene.guid || designEditorTarget.available !== false || !String(designEditorTarget.legacyPath).startsWith('/design/default?id=') || !String(designEditorTarget.reason).includes('未迁入')) throw new Error('旧模板设计入口解析或阻塞说明异常');
- const updatedStandaloneTemplate = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveDesignTemplate', className: 'DesignTlp', objectId: temporaryDesignTemplateId, fields: { tlpName: `${designTemplateProbe}_updated`, classId: 6, price: 13, previewImg: '/smoke/template-preview-2.png', score: 4, zstatus: 0, defBy: 'smoke-updated', remind: 'updated temporary template' } }); if (updatedStandaloneTemplate.tlpName !== `${designTemplateProbe}_updated` || Number(updatedStandaloneTemplate.price) !== 13 || updatedStandaloneTemplate.sourceKey !== createdStandaloneTemplate.sourceKey) throw new Error('模板白名单编辑异常'); const recycledStandaloneTemplate = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'designTemplateBatch', className: 'DesignTlp', action: 'recycle', objectIds: [temporaryDesignTemplateId] }); if (recycledStandaloneTemplate.updated !== 1 || Number(recycledStandaloneTemplate.results?.[0]?.zstatus) !== -2) throw new Error('模板移入回收站失败'); const recycledDesignTemplates = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'designTemplates', className: 'DesignTlp', status: -2, classId: 6, page: 1, pageSize: 100, search: `${designTemplateProbe}_updated` }); if (recycledDesignTemplates.results?.[0]?.objectId !== temporaryDesignTemplateId) throw new Error('模板回收站列表异常'); const restoredStandaloneTemplate = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'designTemplateBatch', className: 'DesignTlp', action: 'restore', objectIds: [temporaryDesignTemplateId] }); if (restoredStandaloneTemplate.updated !== 1 || Number(restoredStandaloneTemplate.results?.[0]?.zstatus) !== 0) throw new Error('模板恢复失败'); const deletedStandaloneTemplate = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'designTemplateBatch', className: 'DesignTlp', action: 'delete', objectIds: [temporaryDesignTemplateId] }); if (deletedStandaloneTemplate.updated !== 1 || deletedStandaloneTemplate.deletedScenes !== 1) throw new Error('模板及关联场景彻底删除失败'); const deletedTemplateSceneResponse = await fetch(`${PARSE_URL}/classes/DesignScence/${temporaryDesignTemplateSceneId}`, { headers: { 'X-Parse-Application-Id': APP_ID, 'X-Parse-Master-Key': MASTER_KEY } }); if (deletedTemplateSceneResponse.status !== 404) throw new Error('模板永久删除后关联场景仍存在'); temporaryDesignTemplateId = ''; temporaryDesignTemplateSceneId = '';
- const roleSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'Role' }); const roleFieldMap = Object.fromEntries((roleSchema.fields || []).map((field) => [field.name, field])); if (roleSchema.writable !== true || roleSchema.creatable !== true || ['roleId','ztype','zstatus','nodeId','auth','auth2','auth3','cadminId','cdate','sourceKey'].some((name) => roleFieldMap[name]?.writable !== false)) throw new Error('角色结构字段未隔离'); const roleAuthSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'ARoleAuth' }); if (roleAuthSchema.writable !== false || roleAuthSchema.fields?.some((field) => field.writable)) throw new Error('角色权限类未禁止通用写入');
- const adminRoles = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'roles', className: 'Role', type: 'admin', page: 1, pageSize: 100, search: '' }); const userRoles = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'roles', className: 'Role', type: 'user', page: 1, pageSize: 100, search: '' }); if (adminRoles.total < 9 || adminRoles.results.some((entry) => String(entry.ztype) !== 'admin') || userRoles.total < 3 || userRoles.results.some((entry) => String(entry.ztype) !== 'user')) throw new Error('管理员/用户角色分类列表异常'); const protectedRole = adminRoles.results.find((entry) => Number(entry.roleId) === 1); if (!protectedRole) throw new Error('缺少历史超级管理员角色'); const protectedRoleDelete = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'roleBatch', className: 'Role', action: 'delete', objectIds: [protectedRole.objectId] }, 409); if (!String(protectedRoleDelete.message).includes('内置')) throw new Error('系统内置角色删除保护未返回明确原因');
- const roleProbeName = `__angular_role_smoke_${Date.now()}__`; const createdRole = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveRole', className: 'Role', roleType: 'admin', fields: { roleName: roleProbeName, description: 'temporary role' } }); temporaryRoleId = createdRole.objectId; if (!temporaryRoleId || !Number(createdRole.roleId) || createdRole.ztype !== 'admin') throw new Error('角色原子新增失败'); const duplicateRole = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveRole', className: 'Role', roleType: 'admin', fields: { roleName: roleProbeName, description: 'duplicate' } }, 409); if (!String(duplicateRole.message).includes('重复')) throw new Error('角色名称防重异常');
- const savedRoleAuth = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveRoleAuthorization', className: 'Role', roleObjectId: temporaryRoleId, authorization: { model: 'manage, manage,edit', content: 'manage', shop: '', page: '', exam: '', user: '', system: '', office: '', portable: '', sites: '', other: '', extend: '' } }); temporaryRoleAuthId = savedRoleAuth.objectId; if (!temporaryRoleAuthId || !Number(savedRoleAuth.id) || savedRoleAuth.model !== 'manage,edit' || Number(savedRoleAuth.rid) !== Number(createdRole.roleId)) throw new Error('角色权限新增、去重或原子编号异常'); const roleAuthorization = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'roleAuthorization', className: 'Role', objectId: temporaryRoleId }); if (roleAuthorization.authorization?.objectId !== temporaryRoleAuthId || roleAuthorization.authorization?.model !== 'manage,edit') throw new Error('角色与权限联合详情异常'); const deletedRole = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'roleBatch', className: 'Role', action: 'delete', objectIds: [temporaryRoleId] }); if (deletedRole.updated !== 1 || deletedRole.deletedAuthorizations !== 1) throw new Error('角色与权限级联删除异常'); temporaryRoleId = ''; temporaryRoleAuthId = '';
- const surveySchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'DesignAsk' }); const surveyFieldMap = Object.fromEntries((surveySchema.fields || []).map((field) => [field.name, field])); if (surveySchema.creatable !== false || surveySchema.writable !== true || ['id','cdate','cuser','adminId','sourceKey'].some((name) => surveyFieldMap[name]?.writable !== false)) throw new Error('问卷系统字段未隔离');
- const surveyQuestionSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'DesignQuestion' }); const surveyQuestionFieldMap = Object.fromEntries((surveyQuestionSchema.fields || []).map((field) => [field.name, field])); if (surveyQuestionSchema.creatable !== false || surveyQuestionSchema.writable !== true || ['id','askId','cdate','cuser','orderId','sourceKey'].some((name) => surveyQuestionFieldMap[name]?.writable !== false)) throw new Error('问卷题目系统字段未隔离');
- const surveyAnswerSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'DesignAnswer' }); if (surveyAnswerSchema.writable !== false || surveyAnswerSchema.creatable !== false) throw new Error('问卷答卷未保持只读');
- const surveys = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'surveys', className: 'DesignAsk', page: 1, pageSize: 100, search: '', status: -100 }); const sampleSurvey = surveys.results?.find((entry) => new Date(entry.endDate?.iso || entry.endDate).getTime() > Date.now()); if (surveys.total < 2 || !sampleSurvey?.objectId || !Number(sampleSurvey.id)) throw new Error('旧问卷列表未绕过兼容层错误 count'); const surveyId = Number(sampleSurvey.id);
- const surveyQuestions = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'surveyQuestions', className: 'DesignQuestion', askId: surveyId, page: 1, pageSize: 100, search: '' }); const sampleSurveyQuestion = surveyQuestions.results?.[0]; if (!sampleSurveyQuestion?.objectId || surveyQuestions.results.some((entry) => Number(entry.askId) !== surveyId)) throw new Error('问卷题目归属筛选异常');
- const surveyResults = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'surveyResults', className: 'DesignAnswer', askId: surveyId, page: 1, pageSize: 100 }); if (!surveyResults.results?.length || surveyResults.results.some((entry) => Number(entry.askId) !== surveyId)) throw new Error('问卷答卷归属筛选异常');
- const surveyChart = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'surveyResultChart', askId: surveyId }); if (surveyChart.responseCount !== surveyResults.total || !Array.isArray(surveyChart.questions) || !surveyChart.questions.length || surveyChart.questions.some((question) => !Array.isArray(question.options))) throw new Error('问卷结果统计异常');
- const surveyCreateBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveSurvey', className: 'DesignAsk', fields: {} }, 501); const surveyQuestionCreateBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveSurveyQuestion', className: 'DesignQuestion', fields: {} }, 501); if (!String(surveyCreateBlocked.message).includes('DesignAsk.id') || !String(surveyQuestionCreateBlocked.message).includes('DesignQuestion.id')) throw new Error('问卷新增未返回旧 ID 阻塞原因');
- surveyRestore = { objectId: sampleSurvey.objectId, fields: { title: sampleSurvey.title, category: sampleSurvey.category, remind: sampleSurvey.remind, preViewImg: sampleSurvey.preViewImg, startDate: { __type: 'Date', iso: String(sampleSurvey.startDate?.iso || sampleSurvey.startDate) }, endDate: { __type: 'Date', iso: String(sampleSurvey.endDate?.iso || sampleSurvey.endDate) }, ztype: Number(sampleSurvey.ztype || 0), ipinterval: Number(sampleSurvey.ipinterval || 0), zstatus: Number(sampleSurvey.zstatus || 0), isIplimit: Number(sampleSurvey.isIplimit || 0), isNeedLogin: Number(sampleSurvey.isNeedLogin || 0), isShowResult: Number(sampleSurvey.isShowResult || 0), isEnableVcode: Number(sampleSurvey.isEnableVcode || 0) } }; const surveyProbeRemind = `${String(sampleSurvey.remind || '')} [angular-smoke]`.trim(); const updatedSurvey = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveSurvey', className: 'DesignAsk', objectId: sampleSurvey.objectId, fields: { ...sampleSurvey, remind: surveyProbeRemind, ztype: Number(sampleSurvey.ztype || 0), ipinterval: Number(sampleSurvey.ipinterval || 0), zstatus: Number(sampleSurvey.zstatus || 0), isIplimit: Number(sampleSurvey.isIplimit || 0), isNeedLogin: Number(sampleSurvey.isNeedLogin || 0), isShowResult: Number(sampleSurvey.isShowResult || 0), isEnableVcode: Number(sampleSurvey.isEnableVcode || 0) } }); if (updatedSurvey.remind !== surveyProbeRemind) throw new Error('问卷专用编辑失败'); const surveyToggleAction = Number(sampleSurvey.zstatus) === 99 ? 'stop' : 'start'; const toggledSurvey = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'surveyBatch', className: 'DesignAsk', action: surveyToggleAction, objectIds: [sampleSurvey.objectId] }); if (Number(toggledSurvey.results?.[0]?.zstatus) !== (surveyToggleAction === 'start' ? 99 : 0)) throw new Error('问卷启停失败'); await jsonRequest(`${PARSE_URL}/classes/DesignAsk/${surveyRestore.objectId}`, { method: 'PUT', body: JSON.stringify(surveyRestore.fields) }, true); surveyRestore = null;
- surveyQuestionRestore = { objectId: sampleSurveyQuestion.objectId, fields: { qtitle: sampleSurveyQuestion.qtitle, qcontent: sampleSurveyQuestion.qcontent, qtype: sampleSurveyQuestion.qtype, qoption: sampleSurveyQuestion.qoption, qflag: sampleSurveyQuestion.qflag, required: Number(sampleSurveyQuestion.required || 0) } }; const questionProbeContent = `${String(sampleSurveyQuestion.qcontent || '')} [angular-smoke]`.trim(); const updatedSurveyQuestion = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveSurveyQuestion', className: 'DesignQuestion', objectId: sampleSurveyQuestion.objectId, fields: { ...sampleSurveyQuestion, qcontent: questionProbeContent } }); if (updatedSurveyQuestion.qcontent !== questionProbeContent || Number(updatedSurveyQuestion.askId) !== surveyId) throw new Error('问卷题目专用编辑失败'); await jsonRequest(`${PARSE_URL}/classes/DesignQuestion/${surveyQuestionRestore.objectId}`, { method: 'PUT', body: JSON.stringify(surveyQuestionRestore.fields) }, true); surveyQuestionRestore = null;
- const temporarySurvey = await jsonRequest(`${PARSE_URL}/classes/DesignAsk`, { method: 'POST', body: JSON.stringify({ title: '__survey_batch_smoke__', startDate: { __type: 'Date', iso: new Date().toISOString() }, endDate: { __type: 'Date', iso: new Date(Date.now() + 86400000).toISOString() }, sourceKey: `smoke-survey-${Date.now()}`, company }) }, true); temporarySurveyId = temporarySurvey.objectId; const deletedTemporarySurvey = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'surveyBatch', className: 'DesignAsk', action: 'delete', objectIds: [temporarySurveyId] }); if (deletedTemporarySurvey.updated !== 1) throw new Error('问卷批量删除失败'); temporarySurveyId = '';
- for (let index = 0; index < 2; index++) { const createdQuestion = await jsonRequest(`${PARSE_URL}/classes/DesignQuestion`, { method: 'POST', body: JSON.stringify({ askId: surveyId, qtitle: `__survey_sort_smoke_${index}__`, qtype: 'radio', qoption: JSON.stringify([{ text: 'A', value: 'A' }]), qflag: '{}', required: 0, orderId: 0, sourceKey: `smoke-survey-question-${Date.now()}-${index}`, company }) }, true); temporarySurveyQuestionIds.push(createdQuestion.objectId); } const sortedQuestions = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'surveyBatch', className: 'DesignQuestion', action: 'sort', objectIds: [...temporarySurveyQuestionIds], orders: temporarySurveyQuestionIds.map((objectId, index) => ({ objectId, orderId: 700 + index })) }); if (sortedQuestions.results?.map((entry) => Number(entry.orderId)).sort().join(',') !== '700,701') throw new Error('问卷题目批量排序失败'); const deletedTemporaryQuestions = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'surveyBatch', className: 'DesignQuestion', action: 'delete', objectIds: [...temporarySurveyQuestionIds] }); if (deletedTemporaryQuestions.updated !== 2) throw new Error('问卷题目批量删除失败'); temporarySurveyQuestionIds.length = 0;
- const temporaryAnswer = await jsonRequest(`${PARSE_URL}/classes/DesignAnswer`, { method: 'POST', body: JSON.stringify({ askId: surveyId, answer: '[]', sourceKey: `smoke-survey-answer-${Date.now()}`, company }) }, true); temporarySurveyAnswerId = temporaryAnswer.objectId; const deletedTemporaryAnswer = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'surveyBatch', className: 'DesignAnswer', action: 'delete', objectIds: [temporarySurveyAnswerId] }); if (deletedTemporaryAnswer.updated !== 1) throw new Error('问卷答卷批量删除失败'); temporarySurveyAnswerId = '';
- const serviceSeatSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'ServiceSeat' }); const serviceSeatFieldMap = Object.fromEntries((serviceSeatSchema.fields || []).map((field) => [field.name, field])); if (serviceSeatSchema.creatable !== true || ['sId','sAdminId','sRemrk','sDateTime','sourceKey'].some((name) => serviceSeatFieldMap[name]?.writable !== false)) throw new Error('客服席位系统字段未隔离');
- const serviceCodeSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'Temp' }); const serviceCodeFieldMap = Object.fromEntries((serviceCodeSchema.fields || []).map((field) => [field.name, field])); if (serviceCodeSchema.creatable !== false || ['id','useType','str3','str5','str6','describe','cdate','userId','sourceKey'].some((name) => serviceCodeFieldMap[name]?.writable !== false)) throw new Error('客服欢迎语系统字段未隔离');
- const serviceSeats = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'serviceSeats', className: 'ServiceSeat', page: 1, pageSize: 20, search: '' }); const sampleServiceSeat = serviceSeats.results?.[0]; if (!sampleServiceSeat?.objectId || !Number(sampleServiceSeat.sId) || !sampleServiceSeat.sRemrk) throw new Error('客服席位历史数据读取异常');
- const serviceCodes = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'serviceCodes', className: 'Temp', page: 1, pageSize: 20, search: '' }); const sampleServiceCode = serviceCodes.results?.[0]; if (!sampleServiceCode?.objectId || Number(sampleServiceCode.useType) !== 12) throw new Error('客服欢迎语历史数据读取异常');
- serviceSeatRestore = { objectId: sampleServiceSeat.objectId, fields: { sName: sampleServiceSeat.sName, sFaceImg: sampleServiceSeat.sFaceImg, sRemrk: sampleServiceSeat.sRemrk, sAdminId: Number(sampleServiceSeat.sAdminId || 0), sDefault: Number(sampleServiceSeat.sDefault || 0), sIndex: Number(sampleServiceSeat.sIndex || 0), sDateTime: sampleServiceSeat.sDateTime } }; const seatProbeName = `${String(sampleServiceSeat.sName || '')} [angular-smoke]`.trim(); const updatedServiceSeat = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveServiceSeat', className: 'ServiceSeat', objectId: sampleServiceSeat.objectId, username: sampleServiceSeat.sRemrk, fields: { ...sampleServiceSeat, sName: seatProbeName, sDefault: Number(sampleServiceSeat.sDefault || 0), sIndex: Number(sampleServiceSeat.sIndex || 0) } }); if (updatedServiceSeat.sName !== seatProbeName || Number(updatedServiceSeat.sAdminId) !== Number(sampleServiceSeat.sAdminId)) throw new Error('客服席位专用编辑失败'); await jsonRequest(`${PARSE_URL}/classes/ServiceSeat/${serviceSeatRestore.objectId}`, { method: 'PUT', body: JSON.stringify(serviceSeatRestore.fields) }, true); serviceSeatRestore = null;
- const weakAccountBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveServiceSeat', className: 'ServiceSeat', username: `missing_service_${Date.now()}`, fields: { sName: '临时客服', sDefault: 0, sIndex: 0 } }, 501); if (!String(weakAccountBlocked.message).includes('固定密码 123456')) throw new Error('客服弱密码开户未返回明确安全阻塞');
- const createdServiceSeat = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveServiceSeat', className: 'ServiceSeat', username: sampleServiceSeat.sRemrk, fields: { sName: '__service_seat_create_smoke__', sFaceImg: '', sDefault: 0, sIndex: 999 } }); temporaryServiceSeatId = String(createdServiceSeat.objectId || ''); if (!temporaryServiceSeatId || !Number(createdServiceSeat.sId) || createdServiceSeat.sourceKey !== `[["S_ID",${Number(createdServiceSeat.sId)}]]`) throw new Error('客服席位原子编号创建异常'); const deletedServiceSeat = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'serviceBatch', className: 'ServiceSeat', action: 'delete', objectIds: [temporaryServiceSeatId] }); if (deletedServiceSeat.updated !== 1) throw new Error('客服席位批量删除失败'); temporaryServiceSeatId = '';
- serviceCodeRestore = { objectId: sampleServiceCode.objectId, fields: { str1: sampleServiceCode.str1, str2: sampleServiceCode.str2, str4: sampleServiceCode.str4 } }; const codeProbeName = `${String(sampleServiceCode.str1 || '')} [angular-smoke]`.trim(); const updatedServiceCode = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveServiceCode', className: 'Temp', objectId: sampleServiceCode.objectId, fields: { ...sampleServiceCode, str1: codeProbeName } }); if (updatedServiceCode.str1 !== codeProbeName || Number(updatedServiceCode.useType) !== 12) throw new Error('客服欢迎语专用编辑失败'); await jsonRequest(`${PARSE_URL}/classes/Temp/${serviceCodeRestore.objectId}`, { method: 'PUT', body: JSON.stringify(serviceCodeRestore.fields) }, true); serviceCodeRestore = null;
- const serviceCodeCreateBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveServiceCode', className: 'Temp', fields: {} }, 501); if (!String(serviceCodeCreateBlocked.message).includes('Temp.id')) throw new Error('客服欢迎语新增未返回旧 ID 阻塞原因'); const directServiceCode = await jsonRequest(`${PARSE_URL}/classes/Temp`, { method: 'POST', body: JSON.stringify({ useType: 12, str1: '__service_code_delete_smoke__', str2: 'temporary', str3: `smoke-${Date.now()}`, str4: 'def', sourceKey: `smoke-service-code-${Date.now()}`, company }) }, true); temporaryServiceCodeId = directServiceCode.objectId; const readDirectServiceCode = await jsonRequest(`${PARSE_URL}/classes/Temp/${temporaryServiceCodeId}`, {}, true); if (readDirectServiceCode.id != null) throw new Error('客服欢迎语省略 id 的创建探测意外生成了旧编号'); const deletedServiceCode = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'serviceBatch', className: 'Temp', action: 'delete', objectIds: [temporaryServiceCodeId] }); if (deletedServiceCode.updated !== 1) throw new Error('客服欢迎语批量删除失败'); temporaryServiceCodeId = '';
- for (const action of ['MsgEx','MsgInfo','MsgList','chat_del']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyServiceChatBlocker', action }, 501); if (!String(blocked.message).startsWith('migration_blocked:')) throw new Error(`旧客服消息动作 ${action} 未返回明确阻塞原因`); }
- const storeApplicationSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'StoreApplication' }); const storeApplicationFieldMap = Object.fromEntries((storeApplicationSchema.fields || []).map((field) => [field.name, field])); if (storeApplicationSchema.creatable !== false || ['id','userId','userName','addTime','storeState','storeCommendState','storeModelId','sourceKey'].some((name) => storeApplicationFieldMap[name]?.writable !== false)) throw new Error('店铺系统字段未隔离');
- const storeStyleSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'StoreStyle' }); const storeStyleFieldMap = Object.fromEntries((storeStyleSchema.fields || []).map((field) => [field.name, field])); if (storeStyleSchema.creatable !== false || ['id','cdate','zstatus','sourceKey'].some((name) => storeStyleFieldMap[name]?.writable !== false)) throw new Error('店铺样式系统字段未隔离');
- const storeApplications = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'storeApplications', className: 'StoreApplication', page: 1, pageSize: 100, search: '', status: -100 }); const sampleStoreApplication = storeApplications.results?.find((entry) => entry.userName === 'admin') || storeApplications.results?.[0]; if (storeApplications.total < 1 || !sampleStoreApplication?.objectId || !Number(sampleStoreApplication.id) || !sampleStoreApplication.userName) throw new Error('店铺历史数据读取异常');
- const storeStyles = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'storeStyles', className: 'StoreStyle', page: 1, pageSize: 100, search: '' }); const sampleStoreStyle = storeStyles.results?.[0]; if (storeStyles.total < 1 || !sampleStoreStyle?.objectId || !Number(sampleStoreStyle.id)) throw new Error('店铺样式历史数据读取异常');
- const storeCreateBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveStoreApplication', className: 'StoreApplication', fields: {} }, 501); const storeStyleCreateBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveStoreStyle', className: 'StoreStyle', fields: {} }, 501); if (!String(storeCreateBlocked.message).includes('StoreApplication.id') || !String(storeStyleCreateBlocked.message).includes('StoreStyle.id')) throw new Error('店铺新增未返回旧 ID 阻塞原因');
- storeApplicationRestore = { objectId: sampleStoreApplication.objectId, fields: { storeName: sampleStoreApplication.storeName, lxr: sampleStoreApplication.lxr, tel: sampleStoreApplication.tel, addr: sampleStoreApplication.addr, area: sampleStoreApplication.area, logo: sampleStoreApplication.logo, pics: sampleStoreApplication.pics, weibo: sampleStoreApplication.weibo, map: sampleStoreApplication.map, content: sampleStoreApplication.content, synopsis: sampleStoreApplication.synopsis, shopType: sampleStoreApplication.shopType, videoUrl: sampleStoreApplication.videoUrl, userId: Number(sampleStoreApplication.userId || 0), userName: sampleStoreApplication.userName, storeStyleId: Number(sampleStoreApplication.storeStyleId || 0), storeState: Number(sampleStoreApplication.storeState || 0), storeCommendState: Number(sampleStoreApplication.storeCommendState || 0) } }; const storeProbeSynopsis = `${String(sampleStoreApplication.synopsis || '')} [angular-smoke]`.trim(); const updatedStoreApplication = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveStoreApplication', className: 'StoreApplication', objectId: sampleStoreApplication.objectId, username: sampleStoreApplication.userName, styleId: Number(sampleStoreApplication.storeStyleId || 0), fields: { ...sampleStoreApplication, synopsis: storeProbeSynopsis } }); if (updatedStoreApplication.synopsis !== storeProbeSynopsis || Number(updatedStoreApplication.userId) !== Number(sampleStoreApplication.userId)) throw new Error('店铺专用编辑失败'); const storeAuditAction = Number(sampleStoreApplication.storeState) === 99 ? 'unaudit' : 'audit'; const auditedStore = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'storeBatch', className: 'StoreApplication', action: storeAuditAction, objectIds: [sampleStoreApplication.objectId] }); if (Number(auditedStore.results?.[0]?.storeState) !== (storeAuditAction === 'audit' ? 99 : -1)) throw new Error('店铺审核状态更新失败'); const recommendedStore = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'storeBatch', className: 'StoreApplication', action: 'elite', objectIds: [sampleStoreApplication.objectId] }); if (Number(recommendedStore.results?.[0]?.storeCommendState) !== 1 || Number(recommendedStore.results?.[0]?.storeState) !== 99) throw new Error('店铺推荐失败'); await jsonRequest(`${PARSE_URL}/classes/StoreApplication/${storeApplicationRestore.objectId}`, { method: 'PUT', body: JSON.stringify(storeApplicationRestore.fields) }, true); storeApplicationRestore = null;
- const storeDeleteBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'storeBatch', className: 'StoreApplication', action: 'delete', objectIds: [sampleStoreApplication.objectId] }, 501); if (!String(storeDeleteBlocked.message).includes('ZL_Commodities')) throw new Error('店铺真实删除未返回商品主表阻塞原因');
- storeStyleRestore = { objectId: sampleStoreStyle.objectId, fields: { styleName: sampleStoreStyle.styleName, remind: sampleStoreStyle.remind, thumbnail: sampleStoreStyle.thumbnail, templateIndex: sampleStoreStyle.templateIndex, templateContent: sampleStoreStyle.templateContent, templateList: sampleStoreStyle.templateList } }; const styleProbeRemind = `${String(sampleStoreStyle.remind || '')} [angular-smoke]`.trim(); const updatedStoreStyle = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveStoreStyle', className: 'StoreStyle', objectId: sampleStoreStyle.objectId, fields: { ...sampleStoreStyle, remind: styleProbeRemind } }); if (updatedStoreStyle.remind !== styleProbeRemind) throw new Error('店铺样式专用编辑失败'); await jsonRequest(`${PARSE_URL}/classes/StoreStyle/${storeStyleRestore.objectId}`, { method: 'PUT', body: JSON.stringify(storeStyleRestore.fields) }, true); storeStyleRestore = null;
- const temporaryStoreApplication = await jsonRequest(`${PARSE_URL}/classes/StoreApplication`, { method: 'POST', body: JSON.stringify({ storeName: '__store_style_ref_smoke__', userId: Number(sampleStoreApplication.userId), userName: sampleStoreApplication.userName, storeStyleId: Number(sampleStoreStyle.id), storeState: 0, sourceKey: `smoke-store-application-${Date.now()}`, company }) }, true); temporaryStoreApplicationId = temporaryStoreApplication.objectId; const referencedStoreStyle = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'storeBatch', className: 'StoreStyle', action: 'delete', objectIds: [sampleStoreStyle.objectId] }, 409); if (!String(referencedStoreStyle.message).includes('店铺引用')) throw new Error('店铺样式引用删除保护未返回明确原因'); await jsonRequest(`${PARSE_URL}/classes/StoreApplication/${temporaryStoreApplicationId}`, { method: 'DELETE' }, true); temporaryStoreApplicationId = '';
- const temporaryStoreStyle = await jsonRequest(`${PARSE_URL}/classes/StoreStyle`, { method: 'POST', body: JSON.stringify({ styleName: '__store_style_delete_smoke__', templateIndex: 'index.html', templateContent: 'content.html', templateList: 'list.html', sourceKey: `smoke-store-style-${Date.now()}`, company }) }, true); temporaryStoreStyleId = temporaryStoreStyle.objectId; const readTemporaryStoreStyle = await jsonRequest(`${PARSE_URL}/classes/StoreStyle/${temporaryStoreStyleId}`, {}, true); if (readTemporaryStoreStyle.id != null) throw new Error('店铺样式省略 id 的创建探测意外生成了旧编号'); const deletedStoreStyle = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'storeBatch', className: 'StoreStyle', action: 'delete', objectIds: [temporaryStoreStyleId] }); if (deletedStoreStyle.updated !== 1) throw new Error('店铺样式批量删除失败'); temporaryStoreStyleId = '';
- const productPageBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyStoreProductBlocker' }, 501); if (!String(productPageBlocked.message).includes('ZL_Commodities')) throw new Error('店铺商品页未返回商品主表阻塞原因');
- const contentTagSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'ContentTagKey' }); if (contentTagSchema.className !== 'ContentTagKey' || contentTagSchema.writable !== true || contentTagSchema.creatable !== false || contentTagSchema.fields?.some((field) => field.writable)) throw new Error('内容标签虚拟 Schema 异常');
- const contentTagPage = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'contentTagKeys', className: 'ContentTagKey', page: 1, pageSize: 20, search: '' }); const originalContentTags = Array.isArray(contentTagPage.results?.[0]?.tags) ? contentTagPage.results[0].tags.map(String) : []; contentTagsRestore = originalContentTags; const tagProbe = `angular-smoke-${Date.now()}`; const probeContentTags = originalContentTags.length >= 1000 ? [...originalContentTags.slice(0, 999), tagProbe] : [...originalContentTags, tagProbe]; const savedContentTags = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveContentTagKeys', className: 'ContentTagKey', objectId: 'global-content-tags', tags: probeContentTags }); if (savedContentTags.count !== probeContentTags.length || savedContentTags.tags?.at(-1) !== tagProbe) throw new Error('内容标签 Parse Config 保存异常'); const readContentTags = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'getContentTagKeys', className: 'ContentTagKey', objectId: 'global-content-tags' }); if (readContentTags.tags?.at(-1) !== tagProbe) throw new Error('内容标签 Parse Config 写后读失败'); await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveContentTagKeys', className: 'ContentTagKey', objectId: 'global-content-tags', tags: originalContentTags }); contentTagsRestore = null;
- for (const action of ['Comment','Commont_API','ConAudit_API','ConAudit_SJ_API','ConAudit','ConAuditDetail','VerBak','VerBak_Del']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyContentAddonBlocker', action }, 501); if (!String(blocked.message).startsWith('migration_blocked:')) throw new Error(`内容附加动作 ${action} 未返回明确数据阻塞`); }
- for (const action of ['Vendor','Vendor_API','VendorAdd','VendorAdd_Submit']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyShopVendorBlocker', action }, 501); if (!String(blocked.message).startsWith('migration_blocked:')) throw new Error(`旧供应商动作 ${action} 未返回明确数据阻塞`); }
- const userLevelSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'UserLevel' }); const userLevelFieldMap = Object.fromEntries((userLevelSchema.fields || []).map((field) => [field.name, field])); if (userLevelSchema.creatable !== false || ['id','cdate','ztype','addon1','addon2','addon3','addon4','addon5','orderId','storeId','zstatus','sourceKey','discountRate'].some((name) => userLevelFieldMap[name]?.writable !== false) || ['alias','pointRate','image','remark'].some((name) => userLevelFieldMap[name]?.writable !== true)) throw new Error('积分等级 Schema 字段隔离异常');
- const userLevels = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'userLevels', className: 'UserLevel', page: 1, pageSize: 100, search: '' }); const sampleUserLevel = userLevels.results?.[0]; if (userLevels.total < 1 || !sampleUserLevel?.objectId || !Number(sampleUserLevel.id) || !sampleUserLevel.alias) throw new Error('积分等级历史数据读取异常');
- const userLevelCreateBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveUserLevel', className: 'UserLevel', fields: {} }, 501); if (!String(userLevelCreateBlocked.message).includes('UserLevel.id')) throw new Error('积分等级新增未返回旧 ID 阻塞原因'); userLevelRestore = { objectId: sampleUserLevel.objectId, fields: { alias: sampleUserLevel.alias, pointRate: Number(sampleUserLevel.pointRate || 0), image: sampleUserLevel.image, remark: sampleUserLevel.remark } }; const levelProbeRemark = `${String(sampleUserLevel.remark || '')} [angular-smoke]`.trim(); const savedUserLevel = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveUserLevel', className: 'UserLevel', objectId: sampleUserLevel.objectId, fields: { ...sampleUserLevel, pointRate: Number(sampleUserLevel.pointRate || 0), remark: levelProbeRemark } }); if (savedUserLevel.remark !== levelProbeRemark || Number(savedUserLevel.id) !== Number(sampleUserLevel.id)) throw new Error('积分等级专用编辑失败'); await jsonRequest(`${PARSE_URL}/classes/UserLevel/${userLevelRestore.objectId}`, { method: 'PUT', body: JSON.stringify(userLevelRestore.fields) }, true); userLevelRestore = null;
- const directUserLevel = await jsonRequest(`${PARSE_URL}/classes/UserLevel`, { method: 'POST', body: JSON.stringify({ alias: '__user_level_delete_smoke__', pointRate: 999999, image: '', remark: 'temporary', sourceKey: `smoke-user-level-${Date.now()}`, company }) }, true); temporaryUserLevelId = directUserLevel.objectId; const readDirectUserLevel = await jsonRequest(`${PARSE_URL}/classes/UserLevel/${temporaryUserLevelId}`, {}, true); if (readDirectUserLevel.id != null) throw new Error('积分等级省略 id 的创建探测意外生成了旧编号'); const deletedUserLevel = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'userLevelBatch', className: 'UserLevel', action: 'delete', objectIds: [temporaryUserLevelId] }); if (deletedUserLevel.updated !== 1) throw new Error('积分等级批量删除失败'); temporaryUserLevelId = '';
- const userMoneySchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'UserMoneyLog' }); if (userMoneySchema.writable !== false || userMoneySchema.creatable !== false || userMoneySchema.fields?.some((field) => field.writable)) throw new Error('资金积分流水虚拟 Schema 应全部只读'); const moneyPage = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'userMoneyLogs', className: 'UserMoneyLog', type: 1, page: 1, pageSize: 20, search: '', startDate: '', endDate: '' }); const sampleMoneyLog = moneyPage.results?.[0]; if (moneyPage.total < 1 || !String(sampleMoneyLog?.objectId || '').startsWith('UserExpDomP:') || sampleMoneyLog.moneyTypeLabel !== '余额') throw new Error('余额流水规范化聚合异常'); const moneyDetail = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'getUserMoneyLog', className: 'UserMoneyLog', objectId: sampleMoneyLog.objectId }); if (moneyDetail.objectId !== sampleMoneyLog.objectId || moneyDetail.recordObjectId !== sampleMoneyLog.recordObjectId) throw new Error('资金流水详情读取异常'); const moneyDate = String(sampleMoneyLog.hisTime?.iso || sampleMoneyLog.hisTime || '').slice(0,10); const filteredMoney = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'userMoneyLogs', className: 'UserMoneyLog', type: 1, page: 1, pageSize: 20, search: String(sampleMoneyLog.userId || ''), startDate: moneyDate, endDate: moneyDate }); if (filteredMoney.total < 1) throw new Error('资金流水用户/日期筛选失败'); for (const type of [2,3,4,5,6]) { const ledger = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'userMoneyLogs', className: 'UserMoneyLog', type, page: 1, pageSize: 1, search: '', startDate: '', endDate: '' }); if (ledger.className !== 'UserMoneyLog') throw new Error(`资金流水类型 ${type} 未正确路由`); }
- const balanceAdded = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'adjustUserBalance', userId: memberLegacyId, type: 4, amount: 1.25, direction: 'add', detail: '冒烟调整后回滚' }); temporaryBalanceLogs.push({ className: balanceAdded.ledgerClass, objectId: balanceAdded.recordObjectId }); if (Number(balanceAdded.score) !== 1.25 || Number(balanceAdded.balanceAfter) !== Number(balanceAdded.scoreBefore) + 1.25) throw new Error('管理员增加用户积分事务异常'); const balanceDeducted = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'adjustUserBalance', userId: memberLegacyId, type: 4, amount: 1.25, direction: 'deduct', detail: '冒烟调整回滚' }); temporaryBalanceLogs.push({ className: balanceDeducted.ledgerClass, objectId: balanceDeducted.recordObjectId }); if (Number(balanceDeducted.score) !== -1.25 || Number(balanceDeducted.balanceAfter) !== Number(balanceAdded.scoreBefore)) throw new Error('管理员扣减用户积分或余额恢复异常');
- for (const action of ['ThirdInfo','ThirdInfo_Submit','SigninList','RealNameAuth','RealNameAuthAdd','RealNameAuth_API']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyUserAddonBlocker', action }, 501); if (!String(blocked.message).startsWith('migration_blocked:')) throw new Error(`旧用户附加动作 ${action} 未返回明确阻塞原因`); }
- for (const action of ['Output','GetMd','UserOrder','DelUserPost_Btn_Click','UPClient','UserBlontoAdmin','UserBlontoAdmin_Submit','UserLogin','AdminAdd','AdminAdd_Submit','Admin_API','SendMailList','SubscriptListManage','Jobsconfig','ZoneConfig','WSApi','Department','Department_Submit','WSApi_Submit']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyUserRemainderBlocker', action }, 501); if (!String(blocked.message).startsWith('migration_blocked:')) throw new Error(`旧用户剩余动作 ${action} 未返回明确阻塞原因`); }
- for (const action of ['Default','AskInfo','AskAdd','AskAdd_Submit','Ask_API','AnswerList','AnswerAdd','AnswerAdd_Submit','Answer_API','Config','Config_Submit']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyAskBlocker', action }, 501); if (!String(blocked.message).startsWith('migration_blocked:')) throw new Error(`旧问答动作 ${action} 未返回明确阻塞原因`); }
- for (const action of ['Default','BiaoDetail','Biao_API','UserFiles','UserFiles_API']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyBiaoCalcBlocker', action }, 501); if (!String(blocked.message).startsWith('migration_blocked:')) throw new Error(`旧裱件计算动作 ${action} 未返回明确阻塞原因`); }
- const officeChartBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyOfficeChartBlocker', action: 'Index' }, 501); if (!String(officeChartBlocked.message).includes('Index.cshtml')) throw new Error('旧 Office 图表页未返回缺失视图阻塞原因');
- for (const action of ['Default','UserChatHistory','UserFriend','Group','GroupAdd','GroupAdd_Submit','GroupUser','MessageHistory','Config','Config_Submit','Chat_API']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyChatBlocker', action }, 501); if (!String(blocked.message).startsWith('migration_blocked:')) throw new Error(`旧聊天动作 ${action} 未返回明确阻塞原因`); }
- for (const action of ['ClassList','ClassAdd','ClassAdd_Submit','Class_API']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyDesignClassBlocker', action }, 501); if (!String(blocked.message).startsWith('migration_blocked:')) throw new Error(`旧模板分类动作 ${action} 未返回明确阻塞原因`); }
- for (const action of ['SPwdCheck','Import','Import_DownTlp','Import_Submit','ImportForContent','ImportForContent_DownTlp','ImportForContent_Submit']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyComBlocker', action }, 501); if (!String(blocked.message).startsWith('migration_blocked:')) throw new Error(`旧通用后台动作 ${action} 未返回明确阻塞原因`); }
- for (const action of ['UserBaseField','ContentField','SelUploadFiles']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyCommonBlocker', action }, 501); if (!String(blocked.message).startsWith('migration_blocked:')) throw new Error(`旧公共动作 ${action} 未返回明确阻塞原因`); }
- for (const action of ['Index','SiteInfo','SiteInfo_Submit','SiteOption','SiteOption_Submit','MailConfig','MailConfig_Submit','UserConfig','UserConfig_Submit','SetOrderStatus','SetOrderStatus_Submit','SMSCfg','SMSConfig_Submit','ThumbConfig','ThumbConfig_Submit','AppConfig','AppConfig_Submit','APPConfig_ReInstall']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacySiteConfigBlocker', action }, 501); if (!String(blocked.message).startsWith('migration_blocked:')) throw new Error(`旧站点配置动作 ${action} 未返回明确阻塞原因`); }
- const baikeSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'Baike' }); if (baikeSchema.writable !== false || baikeSchema.fields?.some((field) => field.writable)) throw new Error('百科主词条 Schema 应保持只读'); const baikePage = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'baikeEntries', className: 'Baike', page: 1, pageSize: 20, search: '', status: -100, elite: -100 }); const sampleBaike = baikePage.results?.[0]; if (baikePage.total < 1 || !sampleBaike?.objectId || !Number(sampleBaike.id)) throw new Error('百科历史主词条读取异常'); baikeRestore = { objectId: sampleBaike.objectId, fields: { status: Number(sampleBaike.status || 0), elite: Number(sampleBaike.elite || 0) } }; const baikeAuditAction = Number(sampleBaike.status) === 1 ? 'unaudit' : 'audit'; const auditedBaike = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'baikeBatch', className: 'Baike', action: baikeAuditAction, objectIds: [sampleBaike.objectId] }); if (Number(auditedBaike.results?.[0]?.status) !== (baikeAuditAction === 'audit' ? 1 : 0)) throw new Error('百科审核状态更新失败'); const baikeEliteAction = Number(sampleBaike.elite) === 1 ? 'unelite' : 'elite'; const eliteBaike = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'baikeBatch', className: 'Baike', action: baikeEliteAction, objectIds: [sampleBaike.objectId] }); if (Number(eliteBaike.results?.[0]?.elite) !== (baikeEliteAction === 'elite' ? 1 : 0)) throw new Error('百科推荐状态更新失败'); await jsonRequest(`${PARSE_URL}/classes/Baike/${baikeRestore.objectId}`, { method: 'PUT', body: JSON.stringify(baikeRestore.fields) }, true); baikeRestore = null; for (const action of ['BKVersionList','Version_API','BKList','Config','Config_Submit']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyBaikeBlocker', action }, 501); if (!String(blocked.message).startsWith('migration_blocked:')) throw new Error(`旧百科动作 ${action} 未返回明确阻塞原因`); }
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'save', className: 'Node', fields: { nodeName: '禁止通用新增' } }, 400);
- const nodeSuffix = Date.now().toString(36);
- const rootNode = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveNode', className: 'Node', parentId: 0, fields: { nodeName: `云函数冒烟栏目-${nodeSuffix}`, nodeDir: `smoke-${nodeSuffix}`, nodeType: 1, contentModel: '54' } });
- temporaryNodeObjectIds.push(String(rootNode.objectId || ''));
- const rootNodeId = Number(rootNode.nodeId);
- if (!temporaryNodeObjectIds[0] || !rootNodeId || Number(rootNode.parentId) !== 0 || Number(rootNode.depth) !== 1 || rootNode.sourceKey !== `[["NodeID",${rootNodeId}]]`) throw new Error(`栏目原子创建异常:${JSON.stringify(rootNode)}`);
- const childNode = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveNode', className: 'Node', parentId: rootNodeId, fields: { nodeName: `云函数冒烟子栏目-${nodeSuffix}`, nodeDir: `smoke-child-${nodeSuffix}`, nodeType: 1, contentModel: '54' } });
- temporaryNodeObjectIds.push(String(childNode.objectId || ''));
- const childNodeId = Number(childNode.nodeId);
- if (!temporaryNodeObjectIds[1] || !childNodeId || Number(childNode.parentId) !== rootNodeId || Number(childNode.depth) !== 2) throw new Error(`子栏目层级创建异常:${JSON.stringify(childNode)}`);
- const duplicateNode = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveNode', className: 'Node', parentId: 0, fields: { nodeName: `云函数冒烟栏目-${nodeSuffix}`, nodeDir: `another-${nodeSuffix}` } }, 409);
- if (!String(duplicateNode.message).includes('不能重复')) throw new Error('栏目同级重名保护未返回明确原因');
- const cycleNode = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveNode', className: 'Node', objectId: rootNode.objectId, parentId: childNodeId, fields: { ...rootNode, nodeName: rootNode.nodeName, nodeDir: rootNode.nodeDir } }, 409);
- if (!String(cycleNode.message).includes('自身或其下级')) throw new Error('栏目层级循环保护未返回明确原因');
- const movedNode = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'nodeBatch', className: 'Node', action: 'move', objectIds: [childNode.objectId], parentId: 0 });
- if (movedNode.updated !== 1 || Number(movedNode.results?.[0]?.parentId) !== 0) throw new Error('栏目批量迁移失败');
- const recycledNode = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'nodeBatch', className: 'Node', action: 'recycle', objectIds: [rootNode.objectId] });
- if (Number(recycledNode.results?.[0]?.zstatus) !== -2) throw new Error('栏目回收站状态更新失败');
- const recoveredNode = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'nodeBatch', className: 'Node', action: 'recover', objectIds: [rootNode.objectId] });
- if (Number(recoveredNode.results?.[0]?.zstatus) !== 99) throw new Error('栏目回收站恢复失败');
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'nodeBatch', className: 'Node', action: 'purge', objectIds: [childNode.objectId] });
- temporaryNodeObjectIds.pop();
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'nodeBatch', className: 'Node', action: 'purge', objectIds: [rootNode.objectId] });
- temporaryNodeObjectIds.pop();
- const specialSuffix = Date.now().toString(36);
- const rootSpecial = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveSpecial', className: 'Special', pid: 0, fields: { specName: `云函数冒烟专题-${specialSuffix}`, specDir: `special-${specialSuffix}`, specCate: 0, specDesc: '专题生命周期验证' } });
- temporarySpecialObjectIds.push(String(rootSpecial.objectId || ''));
- const rootSpecId = Number(rootSpecial.specId);
- if (!temporarySpecialObjectIds[0] || !rootSpecId || Number(rootSpecial.pid) !== 0 || rootSpecial.sourceKey !== `[["SpecID",${rootSpecId}]]`) throw new Error(`专题原子创建异常:${JSON.stringify(rootSpecial)}`);
- const childSpecial = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveSpecial', className: 'Special', pid: rootSpecId, fields: { specName: `云函数冒烟子专题-${specialSuffix}`, specDir: `special-child-${specialSuffix}` } });
- temporarySpecialObjectIds.push(String(childSpecial.objectId || ''));
- const childSpecId = Number(childSpecial.specId);
- if (!temporarySpecialObjectIds[1] || !childSpecId || Number(childSpecial.pid) !== rootSpecId) throw new Error(`子专题创建异常:${JSON.stringify(childSpecial)}`);
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveSpecial', className: 'Special', pid: 0, fields: { specName: rootSpecial.specName, specDir: `special-other-${specialSuffix}` } }, 409);
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveSpecial', className: 'Special', objectId: rootSpecial.objectId, pid: childSpecId, fields: { ...rootSpecial, specName: rootSpecial.specName, specDir: rootSpecial.specDir } }, 409);
- const specialDeleteBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'Special', objectId: rootSpecial.objectId }, 409);
- if (!String(specialDeleteBlocked.message).includes('下级专题')) throw new Error('专题子级引用删除保护未返回明确原因');
- const movedSpecial = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'specialBatch', className: 'Special', action: 'move', objectIds: [childSpecial.objectId], pid: 0 });
- if (movedSpecial.updated !== 1 || Number(movedSpecial.results?.[0]?.pid) !== 0) throw new Error('专题批量迁移失败');
- const mergeBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'specialBatch', className: 'Special', action: 'merge', objectIds: [childSpecial.objectId], targetId: rootSpecId }, 501);
- if (!String(mergeBlocked.message).includes('specialId')) throw new Error('专题合并数据阻塞未返回明确原因');
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'Special', objectId: childSpecial.objectId });
- temporarySpecialObjectIds.pop();
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'Special', objectId: rootSpecial.objectId });
- temporarySpecialObjectIds.pop();
- const categorySuffix = Date.now().toString(36);
- const rootCategory = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveGuestCategory', className: 'Guestcate', gtype: 1, parentId: 0, fields: { catename: `冒烟贴吧版块-${categorySuffix}`, desc: '分类生命周期验证', needLog: 1 } });
- temporaryGuestCategoryObjectIds.push(String(rootCategory.objectId || ''));
- const rootCateid = Number(rootCategory.cateid);
- if (!temporaryGuestCategoryObjectIds[0] || !rootCateid || Number(rootCategory.gtype) !== 1 || rootCategory.sourceKey !== `[["Cateid",${rootCateid}]]`) throw new Error(`贴吧分类原子创建异常:${JSON.stringify(rootCategory)}`);
- const childCategory = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveGuestCategory', className: 'Guestcate', gtype: 1, parentId: rootCateid, fields: { catename: `冒烟子版块-${categorySuffix}` } });
- temporaryGuestCategoryObjectIds.push(String(childCategory.objectId || ''));
- const childCateid = Number(childCategory.cateid);
- if (!temporaryGuestCategoryObjectIds[1] || !childCateid || Number(childCategory.parentId) !== rootCateid) throw new Error('贴吧子分类创建失败');
- const guestCategory = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveGuestCategory', className: 'Guestcate', gtype: 0, parentId: 0, fields: { catename: `冒烟留言分类-${categorySuffix}`, status: 1 } });
- temporaryGuestCategoryObjectIds.push(String(guestCategory.objectId || ''));
- const barAuthorizationBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'barAuthorization', cateId: rootCateid }, 501);
- if (!String(barAuthorizationBlocked.message).includes('ZL_Guest_BarAuth')) throw new Error('贴吧逐用户权限数据阻塞未返回明确原因');
- const barMedalBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'barMedal', objectId: 'missing-post' }, 501);
- if (!String(barMedalBlocked.message).includes('ZL_Guest_Medals')) throw new Error('贴吧勋章数据阻塞未返回明确原因');
- const temporaryBar = await jsonRequest(`${PARSE_URL}/classes/GuestBar`, { method: 'POST', body: JSON.stringify({ sourceKey: `cloud:smoke-bar:${categorySuffix}`, company, cateId: rootCateid, pid: 0, title: '后台贴吧工作流冒烟', msgContent: '冒烟正文', status: 0, orderFlag: 0, postFlag: '', cdate: { __type: 'Date', iso: new Date().toISOString() } }) }, true);
- temporaryGuestBarId = String(temporaryBar.objectId || '');
- const barAudited = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'barBatch', className: 'GuestBar', action: 'audit', objectIds: [temporaryGuestBarId] });
- if (Number(barAudited.results?.[0]?.status) !== 99) throw new Error('贴吧帖子审核失败');
- const barElite = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'barBatch', className: 'GuestBar', action: 'elite', objectIds: [temporaryGuestBarId] });
- if (!String(barElite.results?.[0]?.postFlag).includes('Recommend')) throw new Error('贴吧帖子加精失败');
- const barTop = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'barBatch', className: 'GuestBar', action: 'top-global', objectIds: [temporaryGuestBarId] });
- if (Number(barTop.results?.[0]?.orderFlag) !== 2) throw new Error('贴吧帖子全局置顶失败');
- const barMoved = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'barBatch', className: 'GuestBar', action: 'move', objectIds: [temporaryGuestBarId], cateId: childCateid });
- if (Number(barMoved.results?.[0]?.cateId) !== childCateid) throw new Error('贴吧帖子移动版块失败');
- const barRecycled = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'barBatch', className: 'GuestBar', action: 'recycle', objectIds: [temporaryGuestBarId] });
- if (Number(barRecycled.results?.[0]?.status) !== -2) throw new Error('贴吧帖子回收失败');
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'barBatch', className: 'GuestBar', action: 'recover', objectIds: [temporaryGuestBarId] });
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveGuestCategory', className: 'Guestcate', gtype: 1, parentId: 0, fields: { catename: rootCategory.catename } }, 409);
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveGuestCategory', className: 'Guestcate', objectId: rootCategory.objectId, gtype: 0, parentId: childCateid, fields: { ...rootCategory, catename: rootCategory.catename } }, 409);
- const recommendedCategory = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'guestCategoryBatch', className: 'Guestcate', action: 'recommend', objectIds: [rootCategory.objectId] });
- if (recommendedCategory.results?.[0]?.barInfo !== 'Recommend') throw new Error('贴吧分类推荐失败');
- const categoryDeleteBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'Guestcate', objectId: rootCategory.objectId }, 409);
- if (!String(categoryDeleteBlocked.message).includes('引用')) throw new Error('分类子级引用删除保护未返回明确原因');
- await jsonRequest(`${PARSE_URL}/classes/GuestBar/${temporaryGuestBarId}`, { method: 'DELETE' }, true);
- temporaryGuestBarId = '';
- for (const category of [childCategory, rootCategory, guestCategory]) {
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'Guestcate', objectId: category.objectId });
- temporaryGuestCategoryObjectIds.splice(temporaryGuestCategoryObjectIds.indexOf(String(category.objectId)), 1);
- }
- const examClassSuffix = Date.now().toString(36);
- const rootExamClass = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveExamClass', className: 'ExamClass', parentId: 0, classType: 1, orderId: 0, fields: { cClassName: `冒烟试题分类-${examClassSuffix}` } });
- temporaryExamClassObjectIds.push(String(rootExamClass.objectId || ''));
- const rootExamClassId = Number(rootExamClass.cId);
- if (!temporaryExamClassObjectIds[0] || !rootExamClassId || rootExamClass.sourceKey !== `[["C_id",${rootExamClassId}]]`) throw new Error(`试题分类原子创建异常:${JSON.stringify(rootExamClass)}`);
- const childExamClass = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveExamClass', className: 'ExamClass', parentId: rootExamClassId, classType: 2, orderId: 0, fields: { cClassName: `冒烟子试题分类-${examClassSuffix}` } });
- temporaryExamClassObjectIds.push(String(childExamClass.objectId || ''));
- const childExamClassId = Number(childExamClass.cId);
- if (!childExamClassId || Number(childExamClass.cClassid) !== rootExamClassId || Number(childExamClass.cClassType) !== 2) throw new Error('子试题分类创建失败');
- const examChildren = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'examClassChildren', className: 'ExamClass', parentId: rootExamClassId });
- if (!examChildren.results?.some((entry) => entry.objectId === childExamClass.objectId)) throw new Error('试题子分类接口未返回目标记录');
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveExamClass', className: 'ExamClass', parentId: 0, classType: 1, orderId: 0, fields: { cClassName: rootExamClass.cClassName } }, 409);
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveExamClass', className: 'ExamClass', objectId: rootExamClass.objectId, parentId: childExamClassId, classType: 1, orderId: Number(rootExamClass.cOrderBy) || 0, fields: { cClassName: rootExamClass.cClassName } }, 409);
- const examClassDeleteBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'ExamClass', objectId: rootExamClass.objectId }, 409);
- if (!String(examClassDeleteBlocked.message).includes('下级分类')) throw new Error('试题分类子级引用删除保护未返回明确原因');
- const movedExamClass = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveExamClass', className: 'ExamClass', objectId: childExamClass.objectId, parentId: 0, classType: 2, orderId: Number(childExamClass.cOrderBy) || 0, fields: { cClassName: childExamClass.cClassName } });
- if (Number(movedExamClass.cClassid) !== 0) throw new Error('试题分类结构移动失败');
- const knowledgeSuffix = Date.now().toString(36);
- const rootKnowledge = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveKnowledge', className: 'QuestionsKnowledge', classId: rootExamClassId, parentId: 0, orderId: 0, fields: { kName: `冒烟知识点-${knowledgeSuffix}`, status: 1, grade: 0, isSys: 0 } });
- temporaryKnowledgeObjectIds.push(String(rootKnowledge.objectId || ''));
- const rootKnowledgeId = Number(rootKnowledge.kId);
- if (!temporaryKnowledgeObjectIds[0] || !rootKnowledgeId || rootKnowledge.sourceKey !== `[["k_id",${rootKnowledgeId}]]`) throw new Error(`知识点原子创建异常:${JSON.stringify(rootKnowledge)}`);
- const childKnowledge = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveKnowledge', className: 'QuestionsKnowledge', classId: rootExamClassId, parentId: rootKnowledgeId, orderId: 0, fields: { kName: `冒烟子知识点-${knowledgeSuffix}`, status: 1, grade: 0, isSys: 0 } });
- temporaryKnowledgeObjectIds.push(String(childKnowledge.objectId || ''));
- const childKnowledgeId = Number(childKnowledge.kId);
- if (!childKnowledgeId || Number(childKnowledge.pid) !== rootKnowledgeId || Number(childKnowledge.kClassId) !== rootExamClassId) throw new Error('子知识点创建失败');
- const knowledgeChildren = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'knowledgeChildren', className: 'QuestionsKnowledge', classId: rootExamClassId, parentId: rootKnowledgeId });
- if (!knowledgeChildren.results?.some((entry) => entry.objectId === childKnowledge.objectId)) throw new Error('知识点子级接口未返回目标记录');
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveKnowledge', className: 'QuestionsKnowledge', classId: rootExamClassId, parentId: 0, orderId: 0, fields: { kName: rootKnowledge.kName, status: 1, grade: 0, isSys: 0 } }, 409);
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveKnowledge', className: 'QuestionsKnowledge', objectId: rootKnowledge.objectId, classId: rootExamClassId, parentId: childKnowledgeId, orderId: Number(rootKnowledge.kOrderBy) || 0, fields: { kName: rootKnowledge.kName, status: 1, grade: 0, isSys: 0 } }, 409);
- const knowledgeDeleteBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'QuestionsKnowledge', objectId: rootKnowledge.objectId }, 409);
- if (!String(knowledgeDeleteBlocked.message).includes('下级知识点')) throw new Error('知识点子级引用删除保护未返回明确原因');
- const movedKnowledge = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveKnowledge', className: 'QuestionsKnowledge', objectId: childKnowledge.objectId, classId: rootExamClassId, parentId: 0, orderId: Number(childKnowledge.kOrderBy) || 0, fields: { kName: childKnowledge.kName, status: 1, grade: 0, isSys: 0 } });
- if (Number(movedKnowledge.pid) !== 0) throw new Error('知识点结构移动失败');
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'QuestionsKnowledge', objectId: childKnowledge.objectId });
- temporaryKnowledgeObjectIds.pop();
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'QuestionsKnowledge', objectId: rootKnowledge.objectId });
- temporaryKnowledgeObjectIds.pop();
- const examTeacher = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveExamTeacher', className: 'ExTeacher', classId: rootExamClassId, fields: { tname: `冒烟考试教师-${examClassSuffix}`, post: '测试岗位', teach: '测试科目', fileUpload: '', remark: '教师生命周期验证' } });
- temporaryExamTeacherId = String(examTeacher.objectId || '');
- const examTeacherLegacyId = Number(examTeacher.id);
- if (!temporaryExamTeacherId || !examTeacherLegacyId || Number(examTeacher.tclsss) !== rootExamClassId || examTeacher.sourceKey !== `[["ID",${examTeacherLegacyId}]]`) throw new Error(`考试教师原子创建异常:${JSON.stringify(examTeacher)}`);
- const updatedExamTeacher = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveExamTeacher', className: 'ExTeacher', objectId: temporaryExamTeacherId, classId: childExamClassId, fields: { tname: examTeacher.tname, post: '更新岗位', teach: '更新科目', fileUpload: '', remark: '已更新' } });
- if (Number(updatedExamTeacher.tclsss) !== childExamClassId || updatedExamTeacher.post !== '更新岗位') throw new Error('考试教师更新失败');
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'ExTeacher', objectId: temporaryExamTeacherId });
- temporaryExamTeacherId = '';
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'ExamClass', objectId: childExamClass.objectId });
- temporaryExamClassObjectIds.pop();
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'ExamClass', objectId: rootExamClass.objectId });
- temporaryExamClassObjectIds.pop();
- const dictionarySuffix = Date.now().toString(36);
- const existingDictionaryItems = await jsonRequest(`${PARSE_URL}/classes/Datadic?limit=1000`, {}, true);
- const highestExistingCategoryRef = Math.max(0, ...(existingDictionaryItems.results || []).map((entry) => Number(entry.diccate) || 0));
- const dictionaryCategory = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveDictionaryCategory', className: 'Datadiccategory', fields: { categoryname: `冒烟字典分类-${dictionarySuffix}`, isused: true } });
- temporaryDictionaryCategoryIds.push(String(dictionaryCategory.objectId || ''));
- const dictionaryCategoryId = Number(dictionaryCategory.diccateid);
- if (!temporaryDictionaryCategoryIds[0] || dictionaryCategoryId <= highestExistingCategoryRef || dictionaryCategory.sourceKey !== `[["Diccateid",${dictionaryCategoryId}]]`) throw new Error(`字典分类原子编号或既有引用避让异常:${JSON.stringify(dictionaryCategory)}`);
- const selectableCategories = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'dictionaryCategories', enabledOnly: true });
- if (!selectableCategories.results?.some((entry) => entry.objectId === dictionaryCategory.objectId)) throw new Error('字典分类选择接口未返回新建分类');
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveDictionaryCategory', className: 'Datadiccategory', fields: { categoryname: dictionaryCategory.categoryname, isused: true } }, 409);
- const dictionaryItem = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveDictionaryItem', className: 'Datadic', categoryId: dictionaryCategoryId, fields: { dicname: `冒烟字典项-${dictionarySuffix}`, isused: true } });
- temporaryDictionaryItemIds.push(String(dictionaryItem.objectId || ''));
- const dictionaryItemId = Number(dictionaryItem.dicid);
- if (!temporaryDictionaryItemIds[0] || !dictionaryItemId || Number(dictionaryItem.diccate) !== dictionaryCategoryId || dictionaryItem.sourceKey !== `[["Dicid",${dictionaryItemId}]]`) throw new Error(`字典项原子创建异常:${JSON.stringify(dictionaryItem)}`);
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveDictionaryItem', className: 'Datadic', categoryId: dictionaryCategoryId, fields: { dicname: dictionaryItem.dicname, isused: true } }, 409);
- const dictionaryCategoryDeleteBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'dictionaryBatch', className: 'Datadiccategory', action: 'delete', objectIds: [dictionaryCategory.objectId] }, 409);
- if (!String(dictionaryCategoryDeleteBlocked.message).includes('仍有字典项')) throw new Error('字典分类引用删除保护未返回明确原因');
- const dictionaryDisabled = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'dictionaryBatch', className: 'Datadic', action: 'disable', objectIds: [dictionaryItem.objectId] });
- if (dictionaryDisabled.results?.[0]?.isused !== false) throw new Error('字典项批量停用失败');
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'dictionaryBatch', className: 'Datadic', action: 'enable', objectIds: [dictionaryItem.objectId] });
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'dictionaryBatch', className: 'Datadic', action: 'delete', objectIds: [dictionaryItem.objectId] });
- temporaryDictionaryItemIds.pop();
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'dictionaryBatch', className: 'Datadiccategory', action: 'delete', objectIds: [dictionaryCategory.objectId] });
- temporaryDictionaryCategoryIds.pop();
- const gradeSuffix = Date.now().toString(36);
- const gradeCategory = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveGradeCategory', className: 'GradeCate', fields: { cateName: `冒烟多级字典-${gradeSuffix}`, remark: '多级字典生命周期验证', gradeField: '省份|城市' } });
- temporaryGradeCategoryIds.push(String(gradeCategory.objectId || ''));
- const gradeCategoryId = Number(gradeCategory.cateId);
- if (!temporaryGradeCategoryIds[0] || !gradeCategoryId || gradeCategory.sourceKey !== `[["CateID",${gradeCategoryId}]]` || gradeCategory.gradeField !== '省份|城市') throw new Error(`多级字典分类原子创建异常:${JSON.stringify(gradeCategory)}`);
- const gradeCategoryList = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'gradeCategories' });
- if (!gradeCategoryList.results?.some((entry) => entry.objectId === gradeCategory.objectId)) throw new Error('多级字典分类选择接口未返回新建分类');
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveGradeCategory', className: 'GradeCate', fields: { cateName: gradeCategory.cateName, gradeField: '一级|二级' } }, 409);
- const rootGrade = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveGradeOption', className: 'Grade', categoryId: gradeCategoryId, parentId: 0, fields: { gradeName: `冒烟省份-${gradeSuffix}` } });
- temporaryGradeOptionIds.push(String(rootGrade.objectId || ''));
- const rootGradeId = Number(rootGrade.gradeId);
- if (!temporaryGradeOptionIds[0] || !rootGradeId || Number(rootGrade.grade) !== 1 || Number(rootGrade.parentId) !== 0 || rootGrade.sourceKey !== `[["GradeID",${rootGradeId}]]`) throw new Error(`一级字典选项创建异常:${JSON.stringify(rootGrade)}`);
- const childGrade = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveGradeOption', className: 'Grade', categoryId: gradeCategoryId, parentId: rootGradeId, fields: { gradeName: `冒烟城市-${gradeSuffix}` } });
- temporaryGradeOptionIds.push(String(childGrade.objectId || ''));
- const childGradeId = Number(childGrade.gradeId);
- if (!childGradeId || Number(childGrade.parentId) !== rootGradeId || Number(childGrade.grade) !== 2 || Number(childGrade.cate) !== gradeCategoryId) throw new Error('二级字典选项创建失败');
- const gradePage = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'gradeOptions', categoryId: gradeCategoryId, parentId: rootGradeId, page: 1, pageSize: 20 });
- if (!gradePage.results?.some((entry) => entry.objectId === childGrade.objectId)) throw new Error('多级字典分层列表未返回子选项');
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveGradeOption', className: 'Grade', categoryId: gradeCategoryId, parentId: rootGradeId, fields: { gradeName: childGrade.gradeName } }, 409);
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveGradeOption', className: 'Grade', categoryId: gradeCategoryId, parentId: childGradeId, fields: { gradeName: '越界三级选项' } }, 409);
- const updatedChildGrade = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveGradeOption', className: 'Grade', objectId: childGrade.objectId, categoryId: 999999, parentId: 0, fields: { gradeName: `${childGrade.gradeName}-更新`, cate: 999999, parentId: 0, grade: 1 } });
- if (Number(updatedChildGrade.cate) !== gradeCategoryId || Number(updatedChildGrade.parentId) !== rootGradeId || Number(updatedChildGrade.grade) !== 2) throw new Error('多级字典选项编辑篡改了结构字段');
- const gradeCategoryDeleteBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'gradeBatch', className: 'GradeCate', action: 'delete', objectIds: [gradeCategory.objectId] }, 409);
- if (!String(gradeCategoryDeleteBlocked.message).includes('仍有选项')) throw new Error('多级字典分类引用删除保护未返回明确原因');
- const rootGradeDeleteBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'gradeBatch', className: 'Grade', action: 'delete', objectIds: [rootGrade.objectId] }, 409);
- if (!String(rootGradeDeleteBlocked.message).includes('下级选项')) throw new Error('多级字典子级删除保护未返回明确原因');
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'gradeBatch', className: 'Grade', action: 'delete', objectIds: [childGrade.objectId] }); temporaryGradeOptionIds.pop();
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'gradeBatch', className: 'Grade', action: 'delete', objectIds: [rootGrade.objectId] }); temporaryGradeOptionIds.pop();
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'gradeBatch', className: 'GradeCate', action: 'delete', objectIds: [gradeCategory.objectId] }); temporaryGradeCategoryIds.pop();
- const currencyCreateBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveCurrency', className: 'Currency', fields: { title: '禁止无旧 ID 货币', currencyName: 'TST', currencySymbol: 'T$', currentExchange: 1.25, remark: '应被阻塞' } }, 501);
- if (!String(currencyCreateBlocked.message).includes('保留 id')) throw new Error('货币新增未返回明确旧 ID 阻塞原因');
- const holidayCreateBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveHoliday', className: 'SysHoliday', fields: { name: '禁止无旧 ID 节假日' } }, 501);
- if (!String(holidayCreateBlocked.message).includes('保留 id')) throw new Error('节假日新增未返回明确旧 ID 阻塞原因');
- const searchNavigationCreateBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveSearchNavigation', className: 'Search', fields: { name: '禁止无旧 ID 快捷入口' } }, 501);
- if (!String(searchNavigationCreateBlocked.message).includes('保留 id')) throw new Error('快捷入口新增未返回明确旧 ID 阻塞原因');
- const searchNavigationStartBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'searchNavigationBatch', className: 'Search', action: 'starturl', objectIds: ['not-used'] }, 501);
- if (!String(searchNavigationStartBlocked.message).includes('SiteConfig')) throw new Error('快捷入口全局起始页未返回明确阻塞原因');
- for (const action of ['APIInfo_Submit','APIInfo_SwaggerClose','APIInfo_SwaggerOpen','LicenceFile_API','close_system','Hotkey','HotkeyAdd','HotkeyAdd_Submit','Hotkey_API','Prize','Prize_Submit']) {
- const configBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyConfigBlocker', action }, 501);
- if (!String(configBlocked.message).startsWith('migration_blocked:')) throw new Error(`旧配置动作 ${action} 未返回明确阻塞原因`);
- }
- if (dictionaryCategory.company?.__type !== 'Pointer' || JSON.stringify(dictionaryCategory).match(/accessToken|mch_key|"ak"|"sk"/i)) throw new Error('后台响应展开了帐套敏感配置');
- const examPointSuffix = Date.now().toString(36);
- const rootExamPoint = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveExamPoint', className: 'ExamPoint', parentId: 0, orderId: 0, fields: { testPoint: `冒烟考点-${examPointSuffix}` } });
- temporaryExamPointObjectIds.push(String(rootExamPoint.objectId || ''));
- const rootExamPointId = Number(rootExamPoint.id);
- if (!temporaryExamPointObjectIds[0] || !rootExamPointId || rootExamPoint.sourceKey !== `[["ID",${rootExamPointId}]]`) throw new Error(`考点原子创建异常:${JSON.stringify(rootExamPoint)}`);
- const childExamPoint = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveExamPoint', className: 'ExamPoint', parentId: rootExamPointId, orderId: 0, fields: { testPoint: `冒烟子考点-${examPointSuffix}` } });
- temporaryExamPointObjectIds.push(String(childExamPoint.objectId || ''));
- const childExamPointId = Number(childExamPoint.id);
- if (!childExamPointId || Number(childExamPoint.tid) !== rootExamPointId) throw new Error('子考点创建失败');
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveExamPoint', className: 'ExamPoint', parentId: 0, orderId: 0, fields: { testPoint: rootExamPoint.testPoint } }, 409);
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveExamPoint', className: 'ExamPoint', objectId: rootExamPoint.objectId, parentId: childExamPointId, orderId: Number(rootExamPoint.orderBy) || 0, fields: { testPoint: rootExamPoint.testPoint } }, 409);
- const examPointDeleteBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'ExamPoint', objectId: rootExamPoint.objectId }, 409);
- if (!String(examPointDeleteBlocked.message).includes('下级考点')) throw new Error('考点子级引用删除保护未返回明确原因');
- const movedExamPoint = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveExamPoint', className: 'ExamPoint', objectId: childExamPoint.objectId, parentId: 0, orderId: Number(childExamPoint.orderBy) || 0, fields: { testPoint: childExamPoint.testPoint } });
- if (Number(movedExamPoint.tid) !== 0) throw new Error('考点结构移动失败');
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'ExamPoint', objectId: childExamPoint.objectId });
- temporaryExamPointObjectIds.pop();
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'ExamPoint', objectId: rootExamPoint.objectId });
- temporaryExamPointObjectIds.pop();
- const metadataSuffix = Date.now().toString(36);
- const temporaryModelId = 800000000 + Math.floor(Date.now() / 1000) % 100000000;
- const tempModel = await jsonRequest(`${PARSE_URL}/classes/Model`, { method: 'POST', body: JSON.stringify({ sourceKey: `cloud:smoke-model:${metadataSuffix}`, company, modelId: temporaryModelId, modelName: `冒烟模型-${metadataSuffix}`, tableName: `ZL_C_Smoke_${metadataSuffix}`, modelType: 1, itemName: '记录', itemUnit: '条', multiFlag: true }) }, true);
- temporaryModelObjectId = String(tempModel.objectId || '');
- const updatedModel = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveModelMetadata', className: 'Model', objectId: temporaryModelObjectId, fields: { modelName: `冒烟模型更新-${metadataSuffix}`, description: '仅元数据更新', tableName: 'malicious_table', modelId: 1 } });
- if (Number(updatedModel.modelId) !== temporaryModelId || updatedModel.tableName !== `ZL_C_Smoke_${metadataSuffix}` || updatedModel.description !== '仅元数据更新') throw new Error(`模型结构字段隔离异常:${JSON.stringify(updatedModel)}`);
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveModelMetadata', className: 'Model', fields: { modelName: '禁止新增模型' } }, 501);
- for (let index = 0; index < 2; index++) {
- const field = await jsonRequest(`${PARSE_URL}/classes/ModelField`, { method: 'POST', body: JSON.stringify({ sourceKey: `cloud:smoke-model-field:${metadataSuffix}:${index}`, company, fieldId: temporaryModelId + index + 1, modelId: temporaryModelId, fieldName: `smokeField${index}`, fieldAlias: `冒烟字段${index}`, fieldType: 'TextType', orderId: index, isShow: true }) }, true);
- temporaryModelFieldObjectIds.push(String(field.objectId || ''));
- }
- const updatedField = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveModelFieldMetadata', className: 'ModelField', objectId: temporaryModelFieldObjectIds[0], fields: { fieldAlias: '更新后的字段别名', fieldTips: '仅展示元数据', fieldName: 'maliciousField', fieldType: 'SqlType', modelId: 1 } });
- if (updatedField.fieldAlias !== '更新后的字段别名' || updatedField.fieldName !== 'smokeField0' || updatedField.fieldType !== 'TextType' || Number(updatedField.modelId) !== temporaryModelId) throw new Error(`模型字段结构隔离异常:${JSON.stringify(updatedField)}`);
- const reorderedFields = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'modelFieldOrder', className: 'ModelField', items: [{ objectId: temporaryModelFieldObjectIds[0], orderId: 2 }, { objectId: temporaryModelFieldObjectIds[1], orderId: 1 }] });
- if (reorderedFields.updated !== 2 || Number(reorderedFields.modelId) !== temporaryModelId) throw new Error('模型字段排序失败');
- await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'delete', className: 'ModelField', objectId: temporaryModelFieldObjectIds[0] }, 501);
- const updatedGuestbook = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveGuestbook', className: 'Guestbook', objectId: temporaryGuestbookId, fields: { title: feedbackModel.Title, tcontent: '管理员规范化编辑', gid: 999, status: -2, cateid: 999 } });
- if (updatedGuestbook.tcontent !== '管理员规范化编辑' || Number(updatedGuestbook.gid) === 999 || Number(updatedGuestbook.cateid) === 999 || Number(updatedGuestbook.status) === -2) throw new Error(`留言结构字段隔离异常:${JSON.stringify(updatedGuestbook)}`);
- const guestUnaudited = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'guestbookBatch', className: 'Guestbook', action: 'unaudit', objectIds: [temporaryGuestbookId] });
- if (Number(guestUnaudited.results?.[0]?.status) !== 0) throw new Error('留言取消审核失败');
- const guestRecycled = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'guestbookBatch', className: 'Guestbook', action: 'recycle', objectIds: [temporaryGuestbookId] });
- if (Number(guestRecycled.results?.[0]?.status) !== -2) throw new Error('留言回收失败');
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'guestbookBatch', className: 'Guestbook', action: 'recover', objectIds: [temporaryGuestbookId] });
- const guestReply = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'guestbookReply', className: 'Guestbook', parentObjectId: temporaryGuestbookId, title: '管理员冒烟回复', content: '云函数回复正文' });
- temporaryGuestbookReplyId = String(guestReply.objectId || '');
- if (!temporaryGuestbookReplyId || Number(guestReply.parentid) !== Number(updatedGuestbook.gid) || Number(guestReply.status) !== 99 || !Number(guestReply.gid)) throw new Error(`管理员留言回复异常:${JSON.stringify(guestReply)}`);
- const guestDeleteBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'guestbookBatch', className: 'Guestbook', action: 'purge', objectIds: [temporaryGuestbookId] }, 409);
- if (!String(guestDeleteBlocked.message).includes('仍有回复')) throw new Error('留言回复引用删除保护未返回明确原因');
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'guestbookBatch', className: 'Guestbook', action: 'purge', objectIds: [temporaryGuestbookReplyId] });
- temporaryGuestbookReplyId = '';
- const contentPending = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'contentBatch', className: 'CommonModel', action: 'status', objectIds: [temporaryAppointmentCommonObjectId], status: 0 });
- if (contentPending.updated !== 1 || Number(contentPending.results?.[0]?.status) !== 0) throw new Error('内容待审核状态更新失败');
- const contentRecycled = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'contentBatch', className: 'CommonModel', action: 'recycle', objectIds: [temporaryAppointmentCommonObjectId] });
- if (Number(contentRecycled.results?.[0]?.status) !== -2) throw new Error('内容回收站状态更新失败');
- const contentRecovered = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'contentBatch', className: 'CommonModel', action: 'recover', objectIds: [temporaryAppointmentCommonObjectId] });
- if (Number(contentRecovered.results?.[0]?.status) !== 0) throw new Error('内容回收站恢复失败');
- const contentMoved = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'contentBatch', className: 'CommonModel', action: 'move', objectIds: [temporaryAppointmentCommonObjectId], nodeId: 29 });
- if (Number(contentMoved.results?.[0]?.nodeId) !== 29) throw new Error('内容节点移动失败');
- const contentRefreshed = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'contentBatch', className: 'CommonModel', action: 'refresh', objectIds: [temporaryAppointmentCommonObjectId] });
- if (contentRefreshed.updated !== 1 || !contentRefreshed.results?.[0]?.createTime || !contentRefreshed.results?.[0]?.upDateTime) throw new Error('内容时间刷新失败');
- const contentTitle = String(contentRefreshed.results[0].title || '');
- const duplicateTitles = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyContentUtility', action: 'duplicate-title', title: contentTitle });
- if (!contentTitle || duplicateTitles.total < 1 || !duplicateTitles.results.some((item) => item.objectId === temporaryAppointmentCommonObjectId)) throw new Error('内容重复标题检查失败');
- const contentExport = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyContentUtility', action: 'export', objectIds: [temporaryAppointmentCommonObjectId] });
- if (contentExport.total !== 1 || contentExport.rows?.[0]?.title !== contentTitle) throw new Error('内容导出数据失败');
- const emptyMd = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyContentUtility', action: 'get-md-file' });
- if (emptyMd.content !== '') throw new Error('GetMDFile 空响应兼容失败');
- for (const action of ['Content_AddToNew','AddToSpec','AddToSpec_Submit','ContentManage_Html','ContentRelease','ContentRelease_Submit','CreateHtmlContent','Create_Submit','CreateHtml','ConCatch','CatchConfig','CatchConfig_Submit','MarkDown','MarkDown_Del']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyContentBlocker', action }, 501);
- if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧内容动作 ${action} 未返回明确迁移阻塞`);
- }
- for (const action of ['Design/VisitList','Design/VisitInfoList','Design/VisitInfoDetail','Design/Counter_API','Extend/StatisticalCode','Extend/StatisticalCode_Submit','Extend/Index','Extend/Site','Extend/Month','Extend/Year','Extend/Local','Extend/Browser','Extend/Os','Extend/Channel']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyCounterBlocker', action }, 501);
- if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧访问统计动作 ${action} 未返回明确迁移阻塞`);
- }
- const crmTypeSuffix = Date.now().toString(36); const createdCrmType = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveCrmClientType', className: 'CRMSAttr', fields: { value: `冒烟客户类型-${crmTypeSuffix}`, remark: '临时 CRM 客户类型' } }); temporaryCrmClientTypeId = String(createdCrmType.objectId || ''); if (!temporaryCrmClientTypeId || !Number(createdCrmType.id) || createdCrmType.ztype !== 'ctype' || createdCrmType.sourceKey !== `[["ID",${Number(createdCrmType.id)}]]`) throw new Error(`CRM 客户类型原子编号创建异常:${JSON.stringify(createdCrmType)}`);
- const crmTypeList = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'crmClientTypes', className: 'CRMSAttr', page: 1, pageSize: 20, search: crmTypeSuffix }); if (crmTypeList.total !== 1 || crmTypeList.results?.[0]?.objectId !== temporaryCrmClientTypeId) throw new Error('CRM 客户类型专用列表失败');
- const updatedCrmType = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveCrmClientType', className: 'CRMSAttr', objectId: temporaryCrmClientTypeId, fields: { value: `更新客户类型-${crmTypeSuffix}`, remark: '已更新' } }); if (updatedCrmType.value !== `更新客户类型-${crmTypeSuffix}` || Number(updatedCrmType.id) !== Number(createdCrmType.id)) throw new Error('CRM 客户类型专用编辑失败');
- const deletedCrmType = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'crmClientTypeBatch', className: 'CRMSAttr', action: 'delete', objectIds: [temporaryCrmClientTypeId] }); if (deletedCrmType.updated !== 1) throw new Error('CRM 客户类型专用删除失败'); temporaryCrmClientTypeId = '';
- for (const action of ['Index','ClientList','ClientView','ClientAdd','BiServer_Del','Client_Add','ClientImport','Import_DownTlp','Import_Client','AddServiceRecord','AddServiceRecord_Submit','ServiceRecord_List','Contact','ContactAdd','Contact_Add','ContactImport','ContactImport_Down','ContactImport_Upload','BecomeCustomerList','BecomeCustomerDetail','BecomeCustomerDetailUpdate','BecomeCustomer_API']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyCrmBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧 CRM 动作 ${action} 未返回明确迁移阻塞`);
- }
- for (const action of ['EChartList','ChartCite','ShowM','AddChart','AddChart_Submit','Default']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyEChartsBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧 ECharts 动作 ${action} 未返回明确迁移阻塞`);
- }
- for (const action of ['AddEngLishQuestion','Setting','VersionList','AddVersion','SchoolManage','AddSchool','ClassRoomManage','AddClassRoom','StudentList','CourseManage','AddCourse','ToScore','Papers_Add','Question_Add','Version_GetList','Version_Add','School_Add','ClassRoom_Add','Course_Add','Setting_Update','PublishDesign']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyExamBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧考试动作 ${action} 未返回明确迁移阻塞`);
- }
- for (const action of ['Index','HelpInfo']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyHelperBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧帮助动作 ${action} 未返回明确迁移阻塞`);
- }
- for (const action of ['UList','VipAdd','VipAddJump','VipUpdate','VipUpdate_Submit','VipRenewal','VipRenewal_Submit','VipOverdue','VipOverdue_Submit','OList']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyHmsBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧 Hms 动作 ${action} 未返回明确迁移阻塞`);
- }
- for (const action of ['Scence','Lockin','Lockin_Submit','ASCXLoad','API','AccountForm','AccountForm_API','AccountForm_Submit']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyIndexBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧后台入口动作 ${action} 未返回明确迁移阻塞`);
- }
- for (const action of ['Index','MD','Index_submit','Dels','Preview']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyMarkdownBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧 Markdown 动作 ${action} 未返回明确迁移阻塞`);
- }
- for (const action of ['Message','MessageSend','Message_Add','MessageRead','Message_API']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyMessageBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧站内信动作 ${action} 未返回明确迁移阻塞`);
- }
- for (const action of ['Index','MobileBrower']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyMobileBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧 Mobile 动作 ${action} 未返回明确迁移阻塞`);
- }
- for (const action of ['ZhiDing','UnionNode_Merge']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyNodeRemainderBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧栏目剩余动作 ${action} 未返回明确迁移阻塞`);
- }
- const misTypeSuffix = Date.now().toString(36); const createdMisType = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveMisType', className: 'MisType', fields: { typeName: `冒烟流程类型-${misTypeSuffix}`, typeDescribe: '临时 OA 流程类型' } }); temporaryMisTypeId = String(createdMisType.objectId || ''); if (!temporaryMisTypeId || !Number(createdMisType.id) || createdMisType.sourceKey !== `[["ID",${Number(createdMisType.id)}]]`) throw new Error(`OA 流程类型原子编号创建异常:${JSON.stringify(createdMisType)}`);
- const misTypeList = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'misTypes', className: 'MisType', page: 1, pageSize: 20, search: misTypeSuffix }); if (misTypeList.total !== 1 || misTypeList.results?.[0]?.objectId !== temporaryMisTypeId) throw new Error('OA 流程类型专用列表失败');
- const updatedMisType = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveMisType', className: 'MisType', objectId: temporaryMisTypeId, fields: { typeName: `更新流程类型-${misTypeSuffix}`, typeDescribe: '已更新' } }); if (updatedMisType.typeName !== `更新流程类型-${misTypeSuffix}` || Number(updatedMisType.id) !== Number(createdMisType.id)) throw new Error('OA 流程类型专用编辑失败');
- const deletedMisType = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'misTypeBatch', className: 'MisType', action: 'delete', objectIds: [temporaryMisTypeId] }); if (deletedMisType.updated !== 1) throw new Error('OA 流程类型专用删除失败'); temporaryMisTypeId = '';
- const pageStyleSuffix = Date.now().toString(36); const createdPageStyle = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'savePageStyle', className: 'PageStyle', fields: { pageNodeName: `冒烟黄页样式-${pageStyleSuffix}`, stylePath: `/Template/Page/${pageStyleSuffix}`, templateIndex: 'index.html', templateIndexPic: '/images/page-smoke.png', orderid: 1, isDefault: 1, istrue: 1 } }); temporaryPageStyleId = String(createdPageStyle.objectId || ''); if (!temporaryPageStyleId || !Number(createdPageStyle.pageNodeid) || createdPageStyle.sourceKey !== `[["PageNodeid",${Number(createdPageStyle.pageNodeid)}]]`) throw new Error(`黄页样式原子编号创建异常:${JSON.stringify(createdPageStyle)}`);
- const pageStyleList = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'pageStyles', className: 'PageStyle', page: 1, pageSize: 20, search: pageStyleSuffix }); if (pageStyleList.total !== 1 || pageStyleList.results?.[0]?.objectId !== temporaryPageStyleId) throw new Error('黄页样式专用列表失败');
- const updatedPageStyle = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'savePageStyle', className: 'PageStyle', objectId: temporaryPageStyleId, fields: { pageNodeName: `更新黄页样式-${pageStyleSuffix}`, stylePath: `/Template/Page/${pageStyleSuffix}`, templateIndex: 'index-updated.html', templateIndexPic: '/images/page-smoke.png', orderid: 2, isDefault: 1, istrue: 1 } }); if (updatedPageStyle.pageNodeName !== `更新黄页样式-${pageStyleSuffix}` || Number(updatedPageStyle.pageNodeid) !== Number(createdPageStyle.pageNodeid)) throw new Error('黄页样式专用编辑失败');
- const deletedPageStyle = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'pageStyleBatch', className: 'PageStyle', action: 'delete', objectIds: [temporaryPageStyleId] }); if (deletedPageStyle.updated !== 1) throw new Error('黄页样式专用删除失败'); temporaryPageStyleId = '';
- for (const action of ['ApplyAudit','ApplyInfo','PageContent','EditContent','Content_Edit','PageConfig','PageTemplate','PageTemplateAdd','SetPageOrder','PageConfig_Update','PageTemplate_Add','SetPageOrder_Batch','SetPageOrder_UpMove','SetPageOrder_DownMove','Apply_Update']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyPageBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧黄页动作 ${action} 未返回明确迁移阻塞`);
- }
- const platformSuffix = Date.now().toString(36); const platformUsername = `plat_member_${platformSuffix}`; const platformUser = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'createUser', username: platformUsername, password: randomBytes(24).toString('base64url'), displayName: '协同办公冒烟成员' }); temporaryPlatformMemberId = String(platformUser.objectId || ''); if (!temporaryPlatformMemberId || !Number(platformUser.userId)) throw new Error('协同办公临时成员创建失败');
- const createdPlatformCompany = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'savePlatformCompany', className: 'PlatComp', creatorUsername: platformUsername, fields: { compName: `冒烟协同企业-${platformSuffix}`, compLogo: '', createTime: new Date().toISOString(), registerTime: new Date(Date.now() - 86400000).toISOString(), telephone: '010-12345678', mobile: '13800138000', compHref: '/platform-smoke', compDesc: '临时协同办公企业', mails: 'smoke@example.com', compShort: '冒烟企业', photo: '', faren: '冒烟法人', compType: 1, peoples: '1', registerMoney: 100, keywords: '冒烟', industry: '教育', registerAddr: '测试地址', proAddr: '测试地址' } }); temporaryPlatformCompanyId = String(createdPlatformCompany.objectId || ''); if (!temporaryPlatformCompanyId || !Number(createdPlatformCompany.id) || createdPlatformCompany.sourceKey !== `[["ID",${Number(createdPlatformCompany.id)}]]`) throw new Error(`协同办公企业原子编号创建异常:${JSON.stringify(createdPlatformCompany)}`);
- const platformCompanyList = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'platformCompanies', className: 'PlatComp', page: 1, pageSize: 20, search: platformSuffix }); if (platformCompanyList.total !== 1 || platformCompanyList.results?.[0]?.objectId !== temporaryPlatformCompanyId) throw new Error('协同办公企业专用列表失败');
- const updatedPlatformCompany = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'savePlatformCompany', className: 'PlatComp', objectId: temporaryPlatformCompanyId, creatorUsername: platformUsername, fields: { ...createdPlatformCompany, compName: `更新协同企业-${platformSuffix}`, compHref: '/platform-smoke-updated', createTime: createdPlatformCompany.createTime, registerTime: createdPlatformCompany.registerTime } }); if (updatedPlatformCompany.compName !== `更新协同企业-${platformSuffix}` || Number(updatedPlatformCompany.id) !== Number(createdPlatformCompany.id)) throw new Error('协同办公企业专用编辑失败');
- const addedPlatformMember = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'platformCompanyMemberBatch', companyObjectId: temporaryPlatformCompanyId, action: 'add', usernames: [platformUsername] }); if (addedPlatformMember.updated !== 1) throw new Error('协同办公企业成员加入失败'); const platformMembers = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'platformCompanyMembers', companyObjectId: temporaryPlatformCompanyId, page: 1, pageSize: 100, search: platformSuffix }); if (platformMembers.total !== 1 || platformMembers.results?.[0]?.objectId !== temporaryPlatformMemberId) throw new Error('协同办公企业成员列表失败'); await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'platformCompanyBatch', className: 'PlatComp', action: 'delete', objectIds: [temporaryPlatformCompanyId] }, 409);
- const removedPlatformMember = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'platformCompanyMemberBatch', companyObjectId: temporaryPlatformCompanyId, action: 'remove', objectIds: [temporaryPlatformMemberId] }); if (removedPlatformMember.updated !== 1) throw new Error('协同办公企业成员移出失败'); const deletedPlatformCompany = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'platformCompanyBatch', className: 'PlatComp', action: 'delete', objectIds: [temporaryPlatformCompanyId] }); if (deletedPlatformCompany.updated !== 1) throw new Error('协同办公企业删除失败'); temporaryPlatformCompanyId = ''; await jsonRequest(`${PARSE_URL}/users/${temporaryPlatformMemberId}`, { method: 'DELETE' }, true); temporaryPlatformMemberId = '';
- for (const action of ['Default','AuditApply','AuditApply_Agree','AuditApply_Reject','CreateComp','PlatInfoDeail','PlatInfoDetail_Submit','PlatInfoManage','TopicList','WordTlp','Crud','CrudAdd','CrudAdd_Submit','GroupAdmin_API','API_msg_topic']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyPlatBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧协同办公动作 ${action} 未返回明确迁移阻塞`);
- }
- const printerBlocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyPrinterBlocker', action: 'Index' }, 501); if (!String(printerBlocked.message).includes('ZL_Shop_PrintDevice') || !String(printerBlocked.message).includes('my.feyin.net')) throw new Error('旧打印入口未返回数据与设备协议阻塞原因');
- for (const action of ['Default','FlowInfo','FlowInfo_Submit','Flow_API','SelFlowModel','FlowItem','FlowItemInfo','FlowItemInfo_Submit','FlowItem_API','AddMisModel','AddMisModel_Submit','AddSign','AddSign_Submit','AddSign_Delete','ApplyManage','ApplyManage_Delete','MisModelManage','MisModelManage_Delete','OAConfig','SelModelFieds','SignManage']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyOABlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧 OA 动作 ${action} 未返回明确迁移阻塞`);
- }
- for (const action of ['InteractiveList','Interactive_API']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyDesignInteractiveBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧互动提交动作 ${action} 未返回明确迁移阻塞`);
- }
- for (const action of ['Default','AddQuestionRecord','AddQuestionRecord_Submit','BiServer','BiServer_Del','BiServerInfo','DelIServer','UpdateIServer','BselectiServer','ISReplyAdd','ISReplyAdd_Submit']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyIServerBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧 iServer 动作 ${action} 未返回明确迁移阻塞`);
- }
- for (const action of ['LicenceFiles','LicenceFiles_API','LicenceFilesAdd','LicenceFilesAdd_Submit','LicenceSignApplyList','LicenceSignApplyDetail','LicenceSignApply_API','LicenceSignList','LicenceSignDetail','LicenceSign_API','LicenceList','LicenceAdd','LicenceAdd_Submit','Licence_API','LicenceUserSign']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyLicenceBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧许可签约动作 ${action} 未返回明确迁移阻塞`);
- }
- const promotionSchema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className: 'UserPromotion' }); if (promotionSchema.writable !== false || promotionSchema.creatable !== false || !promotionSchema.fields?.some((field) => field.name === 'promotionCount' && field.writable === false)) throw new Error('用户推广关系 Schema 应保持只读'); const promotionPage = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'userPromotions', className: 'UserPromotion', page: 1, pageSize: 20, search: '', parentUserId: 0, onlyWithChildren: false, startDate: '', endDate: '' }); if (!Number.isInteger(promotionPage.total) || !Array.isArray(promotionPage.results)) throw new Error('用户推广关系列表响应异常'); const promotionSample = promotionPage.results?.[0]; if (promotionSample) { const promotionDetail = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'getUserPromotion', className: 'UserPromotion', objectId: promotionSample.objectId }); if (promotionDetail.objectId !== promotionSample.objectId || !Number.isInteger(Number(promotionDetail.promotionCount))) throw new Error('用户推广关系详情异常'); } const promotionParents = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'userPromotions', className: 'UserPromotion', page: 1, pageSize: 20, search: '', parentUserId: 0, onlyWithChildren: true, startDate: '', endDate: '' }); if (promotionParents.results?.some((entry) => Number(entry.promotionCount) < 1)) throw new Error('仅推广人筛选返回了无成员用户');
- for (const action of ['Index','WD','WD_API','WDAudit','WDAudit_Accept','WDAudit_Reject','UserBank','UserBankAdd','UserBankAdd_Submit','UserBank_API']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyUserPromoBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧推广提现动作 ${action} 未返回明确迁移阻塞`); }
- for (const className of ['Pub','PubTw','PubWTHD','PubZXDC']) { const schema = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'schema', className }); if (schema.writable !== false || schema.fields?.some((field) => field.writable)) throw new Error(`${className} 空互动类必须保持只读`); }
- for (const action of ['PubManage','Pub_API','Pubinfo','PubAdd','PubAdd_Submit','Pubsinfo','PubsinfoAdd','PubsinfoAdd_Submit','PubInfo_API','PubInfo2_API','PubsinfoReply','PubsinfoReply_Submit']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyPubBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧互动模块动作 ${action} 未返回明确迁移阻塞`); }
- for (const action of ['Index','APIList','API_del','AddAPI','AddAPI_Submit','PushMsg','PushMsg_Submit','PushTlp','AddPushTlp','AddPushTlp_Submit','PushTlp_API','MsgList']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyPushBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧推送动作 ${action} 未返回明确迁移阻塞`); }
- for (const action of ['Default','Default_Submit','Mobile','Mobile_Submit','Offline','Offline_Submit']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyPWABlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧 PWA 动作 ${action} 未返回明确迁移阻塞`); }
- for (const action of ['TaskList','ViewLog','TaskAdd','TaskEdit','TaskUpdate','ExecuteNow','TaskDelete','TaskDeleteRange','TaskPause','TaskResume']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyQuartzTaskBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧 Quartz 任务动作 ${action} 未返回明确迁移阻塞`); }
- for (const action of ['Default','API','SiteSwitch','SiteIP','SiteIPAdd','SiteIPAdd_Submit','ContentProtect','SiteAssess','SiteProtect','SiteProtect_Submit','ContentCheck','ContentCheckConfig','ContentCheckConfig_Submit','ContentFilter','SiteCheck']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacySafeBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧站点安全动作 ${action} 未返回明确迁移阻塞`); }
- for (const action of ['Default','StructList','order','order_submit','Struct_API','StructByTree','Struct_ListByTree','StructAdd','StructAdd_Submit','StructMember','Structure_update','Structure_Merge','Structure_Move','Structure_List']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyStructureBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧组织架构动作 ${action} 未返回明确迁移阻塞`); }
- for (const action of ['Index','TlpView','VUE_API','Config','Config_Submit']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyVueBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧 Vue 模板动作 ${action} 未返回明确迁移阻塞`); }
- for (const action of ['Default']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyWorkloadBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧工作量统计动作 ${action} 未返回明确迁移阻塞`); }
- for (const action of ['Default','Add','Add_Submit','List','API','Best']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyVBookBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧 H5 电子书动作 ${action} 未返回明确迁移阻塞`); }
- for (const action of ['Default','SiteAdd','SiteAdd_Submit','SiteArticle','SiteShop','SiteMessage','Site_API','SiteBoard','SiteBoardAdd','SiteBoardAdd_Submit','Board_API','SiteBoardType','SiteBoardTypeAdd','SiteBoardTypeAdd_Submit','BoardType_API','SiteChangeLog','SiteChangeLog_API','TemplateBuyLog','TemplateBuyLog_API']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyVdesignBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧 Vdesign 动作 ${action} 未返回明确迁移阻塞`); }
- for (const action of ['SPage','SPageAdd','SPageAdd_Submit','SPage_API','SPageEdit','SPageEdit_Submit','SPage_AddComponent','SPage_AddLayout','SPageDesign','SPageDesign_API','SPageDesign_Nav','SPageDesign_Label','SPageDesign_Content','SPageDesign_Carousel','SPagePreview']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacySPageBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧 SPage 动作 ${action} 未返回明确迁移阻塞`); }
- for (const action of ['Default','CopybookAdd','CopybookAdd_Submit','Copybook_API','Manuscripts','ManuscriptsAdd','ManuscriptsAdd_Submit','Manuscripts_API','UserFiles','UserFiles_API']) { const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyWritePearlBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧书法珍珠动作 ${action} 未返回明确迁移阻塞`); }
- for (const action of ['TxtLog','TxtLogContent','TxtLog_Down','TaskList','TaskAdd','TaskAdd_API','TaskAdd_Submit','Task_API','TaskCenter']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyLogBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧日志任务动作 ${action} 未返回明确迁移阻塞`);
- }
- const systemLogs = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'systemLogs', className: 'SysLog', page: 1, pageSize: 2, search: '', type1: '', type2: '', startDate: '', endDate: '' }); if (!Array.isArray(systemLogs.results) || systemLogs.pageSize !== 2 || Number(systemLogs.total) < systemLogs.results.length) throw new Error('系统日志只读列表异常');
- const fareSuffix = Date.now().toString(36); const fareRules = [{ name: '冒烟快递', mode: '1', enabled: true, price: '10', plus: '1', free_sel: '0', free_num: '', free_money: '' }]; const createdFare = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveShopFareTemplate', className: 'ShopFareTlp', fields: { tlpName: `冒烟运费-${fareSuffix}`, priceMode: 1, express: JSON.stringify(fareRules), remind: '临时运费模板', remind2: '' } }); temporaryShopFareTemplateId = String(createdFare.objectId || ''); if (!temporaryShopFareTemplateId || !Number(createdFare.id) || createdFare.sourceKey !== `[["ID",${Number(createdFare.id)}]]`) throw new Error(`商城运费模板原子编号创建异常:${JSON.stringify(createdFare)}`);
- const fareList = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'shopFareTemplates', className: 'ShopFareTlp', page: 1, pageSize: 20, search: fareSuffix }); if (fareList.total !== 1 || fareList.results?.[0]?.objectId !== temporaryShopFareTemplateId) throw new Error('商城运费模板专用列表失败');
- const updatedFare = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'saveShopFareTemplate', className: 'ShopFareTlp', objectId: temporaryShopFareTemplateId, fields: { tlpName: `更新运费-${fareSuffix}`, priceMode: 1, express: JSON.stringify(fareRules), remind: '已更新', remind2: '' } }); if (updatedFare.tlpName !== `更新运费-${fareSuffix}` || Number(updatedFare.id) !== Number(createdFare.id)) throw new Error('商城运费模板专用编辑失败');
- const deletedFare = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'shopFareTemplateBatch', className: 'ShopFareTlp', action: 'delete', objectIds: [temporaryShopFareTemplateId] }); if (deletedFare.updated !== 1) throw new Error('商城运费模板专用删除失败'); temporaryShopFareTemplateId = '';
- for (const action of ['OrderSend','OrderSend_Submit','Factory','FactoryAdd','FactoryAdd_Submit','Factory_API','Factory_select','Trademark','TrademarkAdd','Trademark_Submit','Trademark_API','Trademark_select']) {
- const blocked = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'legacyShopExpBlocker', action }, 501); if (!String(blocked.message).includes('migration_blocked')) throw new Error(`旧商城配送动作 ${action} 未返回明确迁移阻塞`);
- }
- await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'contentBatch', className: 'CommonModel', action: 'status', objectIds: [temporaryAppointmentCommonObjectId], status: 99 });
- const page = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'list', className: 'CourseAppointment', page: 1, pageSize: 2 });
- if (!Array.isArray(page.results) || page.pageSize !== 2) throw new Error('资源分页校验失败');
- const normalized = await callFunction('xiaoshu/cms/content-normalizer', login.sessionToken, { content: '<p>中文 <strong>内容</strong></p><script>alert(1)</script>' });
- if (normalized.content !== '中文 内容') throw new Error(`内容清理结果异常:${normalized.content}`);
- const exams = await callFunction('xiaoshu/cms/exams/classes', login.sessionToken, { page: 1, pageSize: 2 });
- if (!Array.isArray(exams.results)) throw new Error('考试班级投影校验失败');
- const guest = await callFunction('xiaoshu/cms/guest/bar', login.sessionToken, { page: 1, pageSize: 2 });
- if (!Array.isArray(guest.results)) throw new Error('互动社区投影校验失败');
- const migration = await callLegacyFunction('', { action: 'migration_status' });
- const sourceActionList = await sourceActions();
- const implementedActions = migration.result?.implemented || [];
- const blockedActions = Object.keys(migration.result?.blocked || {});
- const covered = new Set([...implementedActions, ...blockedActions]);
- const missing = sourceActionList.filter((action) => !covered.has(action));
- if (missing.length) throw new Error(`app gateway 迁移矩阵缺少:${missing.join(', ')}`);
- const sourceBlocked = blockedActions.filter((action) => sourceActionList.includes(action));
- const compatibilityActions = blockedActions.filter((action) => !sourceActionList.includes(action)).sort();
- const sourceImplemented = implementedActions.filter((action) => sourceActionList.includes(action));
- const compatibilityImplemented = implementedActions.filter((action) => !sourceActionList.includes(action)).sort();
- if (sourceImplemented.length !== 75 || sourceBlocked.length !== 16) throw new Error(`app gateway 源 action 计数异常:${sourceImplemented.length} 已映射 / ${sourceBlocked.length} 阻塞`);
- if (compatibilityImplemented.join(',') !== 'cart_add,content_add_zt,product_add,product_upd,reading/ai,reading/create,reading/get,reading/me,reading/query,reading/update,reading/user/update,upload') throw new Error(`app gateway 已实现兼容 action 计数异常:${compatibilityImplemented.join(',')}`);
- if (compatibilityActions.length) throw new Error(`app gateway 阻塞兼容 action 应为空:${compatibilityActions.join(',')}`);
- const content = await callLegacyFunction('', { action: 'content_list', page: 1, pageSize: 2 });
- if (!Array.isArray(content.result) || content.result.length !== 2 || Number(content.page?.itemCount) < 89000) throw new Error('公开内容分页校验失败');
- const contentExact = await callLegacyFunction('', { action: 'content_list', page: 1, pageSize: 1, objectId: content.result[0].objectId });
- if (contentExact.result?.[0]?.objectId !== content.result[0].objectId || contentExact.page?.itemCount !== 1) throw new Error('内容 objectId 精确查询校验失败');
- const contentDetail = await callLegacyFunction('', { action: 'content_get', id: content.result[0].objectId });
- if (!Array.isArray(contentDetail.result) || contentDetail.result[0]?.objectId !== content.result[0].objectId) throw new Error('内容详情旧数组契约校验失败');
- contentHitObjectId = String(content.result[0].objectId);
- contentHitOriginal = Number(content.result[0].hits ?? content.result[0].Hits ?? 0);
- const contentHit = await callLegacyFunction('', { action: 'content_uphis', id: contentHitObjectId, num: 999 });
- if (Number(contentHit.result?.hits) !== contentHitOriginal + 1) throw new Error(`公开内容浏览量未固定原子加一:${JSON.stringify(contentHit)}`);
- await jsonRequest(`${PARSE_URL}/classes/CommonModel/${contentHitObjectId}`, { method: 'PUT', body: JSON.stringify({ hits: contentHitOriginal }) }, true);
- contentHitObjectId = '';
- await callLegacyFunction('', { action: 'content_uphis', id: temporaryAppointmentId }, 401);
- const appUpdate = await callLegacyFunction('', { action: 'app_update' });
- if (Number(appUpdate.result?.ver) !== 113 || appUpdate.result?.nver !== '1.1.8' || !String(appUpdate.result?.path).startsWith('https://') || appUpdate.result?.size !== null || appUpdate.result?.sizeUnavailable !== true) throw new Error(`应用版本旧契约别名异常:${JSON.stringify(appUpdate)}`);
- const gameNode = await callLegacyFunction('', { action: 'node_get', id: 77 });
- if (gameNode.result?.NodeID === undefined || gameNode.result?.ConsumePoint === undefined || gameNode.result?.ConsumeDeposit === undefined) throw new Error(`栏目详情游戏消费字段别名异常:${JSON.stringify(gameNode.result)}`);
- const words = await callLegacyFunction('', { action: 'content_list', modelId: 52, page: 1, pageSize: 1 });
- if (Number(words.page?.itemCount) < 89000 || !words.result?.[0]?.GeneralID || words.result?.[0]?.sy === undefined) throw new Error('词库 addon 联表校验失败');
- const privateContent = await callLegacyFunction('', { action: 'content_list', modelId: 56, page: 1, pageSize: 1 }, 401);
- if (!String(privateContent.retmsg).includes('登录')) throw new Error('学习记录未阻止匿名访问');
- const learning = await callLegacyFunction(login.sessionToken, { action: 'content_list', modelId: 56, page: 1, pageSize: 1 });
- if (!learning.result?.[0]?.GeneralID || learning.result?.[0]?.xxqs === undefined) throw new Error('学习记录 addon 联表校验失败');
- const recordDetail = await callLegacyFunction(login.sessionToken, { action: 'e_record_detail', id: learning.result[0].GeneralID });
- if (!Array.isArray(recordDetail.result) || !recordDetail.result.length || !recordDetail.result[0]?.detail?.[0]?.Title) throw new Error('学习记录单词详情联查校验失败');
- const appointments = await callLegacyFunction(login.sessionToken, { action: 'content_list', modelId: 54, page: 1, pageSize: 1 });
- const appointment = await callLegacyFunction(login.sessionToken, { action: 'e_order_detail', id: appointments.result?.[0]?.GeneralID });
- if (!appointment.result?.[0]?.GeneralID || appointment.result[0].kcid === undefined) throw new Error('预约详情联查校验失败');
- const memberProfile = await callLegacyFunction(memberLogin.sessionToken, { action: 'user_get', uid: memberLegacyId });
- if (memberProfile.result?.honeyName !== profileModel.honeyName || memberProfile.addon?.vip !== 2 || memberProfile.addon?.silverCoin !== 2 || JSON.stringify(memberProfile).includes('must-not-leak')) throw new Error('用户旧契约字段或敏感字段过滤异常');
- const teamMembers = await callLegacyFunction(memberLogin.sessionToken, { action: 'user_list', puid: memberLegacyId, cpage: 1, psize: 10 });
- if (teamMembers.page?.itemCount !== 1 || Number(teamMembers.result?.[0]?.ParentUserID) !== memberLegacyId || Number(teamMembers.result?.[0]?.VIP) !== 3) throw new Error(`团队成员列表异常:${JSON.stringify(teamMembers)}`);
- const teamSummary = await callLegacyFunction(memberLogin.sessionToken, { action: 'user_dept', uid: memberLegacyId });
- if (teamSummary.result?.childs !== 1 || teamSummary.result?.v3 !== 1) throw new Error(`团队会员统计异常:${JSON.stringify(teamSummary.result)}`);
- const childProfile = await callLegacyFunction(memberLogin.sessionToken, { action: 'user_get', uid: childLegacyId });
- if (childProfile.result?.userId !== childLegacyId || childProfile.result?.puid !== memberLegacyId || JSON.stringify(childProfile).includes('must-not-leak')) throw new Error('团队成员详情或密码字段过滤异常');
- await callLegacyFunction(coachLogin.sessionToken, { action: 'user_get', uid: childLegacyId }, 403);
- const coachStudents = await callLegacyFunction(coachLogin.sessionToken, { action: 'e_user_list', cpage: 1, psize: 10 });
- if (coachStudents.page?.itemCount !== 1 || Number(coachStudents.result?.[0]?.szyh) !== memberLegacyId || coachStudents.result?.[0]?.honeyname !== profileModel.honeyName) throw new Error(`陪练学员分组列表异常:${JSON.stringify(coachStudents)}`);
- const newWords = await callLegacyFunction(login.sessionToken, { action: 'e_words_list', uid: 58, page: 1, pageSize: 2 });
- if (Number(newWords.page?.itemCount) < 1 || !newWords.result?.[0]?.detail?.[0]?.Title) throw new Error('用户生词联查校验失败');
- const courseWords = await callLegacyFunction(login.sessionToken, { action: 'e_ck_list', uid: 58, nids: 40, page: 1, pageSize: 1000 });
- const learnedWord = courseWords.result?.find((word) => Number(word.GeneralID) === 2505);
- if (Number(courseWords.page?.itemCount) < 1 || !courseWords.result?.[0]?.detail?.Title || Number(learnedWord?.w_learned) !== 7) throw new Error('课程词库学习进度联查校验失败');
- const memory = await callLegacyFunction(login.sessionToken, { action: 'e_get_21list', uid: 58, page: 1, pageSize: 2 });
- if (Number(memory.page?.itemCount) < 1 || !memory.result?.[0]?.GeneralID || memory.result[0].learned === undefined) throw new Error('21 天抗遗忘联查校验失败');
- // 旧系统此统计按陪练字段 plid 归属,使用已核对过的真实陪练样本,不能用学员 58。
- const completedReviewStats = await callLegacyFunction(login.sessionToken, { action: 'e_get_21list_tj', uid: 1810 });
- if (!Array.isArray(completedReviewStats.result) || Number(completedReviewStats.result[0]?.num) < 1) throw new Error('已完成复习任务统计异常');
- const ownEmpty = await callLegacyFunction(memberLogin.sessionToken, { action: 'content_list', modelId: 56, myfield2: `UserId=${memberLegacyId}`, page: 1, pageSize: 1 });
- if (!Array.isArray(ownEmpty.result) || ownEmpty.page?.itemCount !== 0) throw new Error('普通用户本人记录权限校验失败');
- const ownCourseWords = await callLegacyFunction(memberLogin.sessionToken, { action: 'e_ck_list', uid: memberLegacyId, nids: 40, page: 1, pageSize: 1 });
- if (!Array.isArray(ownCourseWords.result) || ownCourseWords.result[0]?.w_learned !== 0) throw new Error('普通用户本人课程词库权限校验失败');
- const learnedWrite = await callLegacyFunction(memberLogin.sessionToken, { action: 'e_add_words', uid: memberLegacyId, wordsId: '2505', kcid: 16, save: 1 });
- if (learnedWrite.result?.created !== 1 || learnedWrite.result?.learnedIncremented !== 1) throw new Error('首次学习词进度写入校验失败');
- await callLegacyFunction('', { action: 'node_list', pid: 16, ifunit: 1, userId: memberLegacyId }, 401);
- const unitNodes = await callLegacyFunction(memberLogin.sessionToken, { action: 'node_list', pid: 16, ifunit: 1, userId: memberLegacyId, pageSize: 100 });
- const learnedUnit = unitNodes.result?.find((node) => Number(node.NodeID) === 40);
- if (!learnedUnit || Number(learnedUnit.total) < 1 || Number(learnedUnit.yx_word) !== 1 || Number(learnedUnit.process) !== Math.round(100 / Number(learnedUnit.total))) throw new Error(`单元已学进度异常:${JSON.stringify(learnedUnit)}`);
- const learnedRead = await callLegacyFunction(memberLogin.sessionToken, { action: 'e_ck_list', uid: memberLegacyId, nids: 40, page: 1, pageSize: 1000 });
- if (Number(learnedRead.result?.find((word) => Number(word.GeneralID) === 2505)?.w_learned) !== 1) throw new Error('学习次数写后读校验失败');
- await callLegacyFunction(memberLogin.sessionToken, { action: 'e_add_words', uid: memberLegacyId, wordsId: '2505', kcid: 16, ifnew: 1 });
- const addedNewWord = await callLegacyFunction(memberLogin.sessionToken, { action: 'e_words_list', uid: memberLegacyId, page: 1, pageSize: 10 });
- if (addedNewWord.page?.itemCount !== 1 || Number(addedNewWord.result?.[0]?.detail?.[0]?.GeneralID) !== 2505) throw new Error('加入生词写后读校验失败');
- await callLegacyFunction(memberLogin.sessionToken, { action: 'e_add_words', uid: memberLegacyId, wordsId: '2505', kcid: 16, ifnew: 0 });
- const removedNewWord = await callLegacyFunction(memberLogin.sessionToken, { action: 'e_words_list', uid: memberLegacyId, page: 1, pageSize: 10 });
- if (removedNewWord.page?.itemCount !== 0) throw new Error('移出生词写后读校验失败');
- const scheduledStudy = await callLegacyFunction(memberLogin.sessionToken, { action: 'content_add_zt', content: JSON.stringify({ ModelID: 56, nodeId: 291, inputer: memberUsername, status: 99, Hits: 1, title: memberUsername }), addon: JSON.stringify({ UserID: memberLegacyId, dqrq: '20991231', learned: 1, xxqs: JSON.stringify([{ GeneralID: 2505, Title: 'woman', check: 0 }]) }) });
- if (!/^\d{15}$/.test(String(scheduledStudy.result))) throw new Error('带复习计划的学习记录创建结果异常');
- const scheduledDetail = await callLegacyFunction(memberLogin.sessionToken, { action: 'content_get', id: scheduledStudy.result });
- const reviewDates = String(scheduledDetail.result?.[0]?.fxrl || '').split(',').filter(Boolean);
- if (reviewDates.length !== 15 || !reviewDates.every((date) => /^\d{8}$/.test(date))) throw new Error('15 段抗遗忘复习日期生成失败');
- await callLegacyFunction(coachLogin.sessionToken, { action: 'content_update', content: JSON.stringify({ GeneralID: scheduledStudy.result }), addon: JSON.stringify({ con: '越权更新' }) }, 403);
- const scheduledUpdate = await callLegacyFunction(memberLogin.sessionToken, { action: 'content_update', content: JSON.stringify({ GeneralID: scheduledStudy.result, Title: '已更新学习记录' }), addon: JSON.stringify({ con: '规范化内容更新', learned: 1 }) });
- if (String(scheduledUpdate.result) !== String(scheduledStudy.result)) throw new Error('规范化内容更新返回值异常');
- const updatedScheduledDetail = await callLegacyFunction(memberLogin.sessionToken, { action: 'content_get', id: scheduledStudy.result });
- if (updatedScheduledDetail.result?.[0]?.con !== '规范化内容更新' || updatedScheduledDetail.result?.[0]?.Title !== '已更新学习记录') throw new Error('规范化内容双表更新写后读失败');
- const assessment = await callLegacyFunction(memberLogin.sessionToken, { action: 'content_add', content: JSON.stringify({ ModelID: 61, nodeId: 389, inputer: memberUsername, status: 99, Hits: 1, title: memberUsername }), addon: JSON.stringify({ UserID: memberLegacyId, askid: 1, prev_score: 0, totalScore: 10, wrong: 2, dontKnow: 1, answerid: 7, df: 7 }) });
- if (!/^\d{15}$/.test(String(assessment.result))) throw new Error('规范化测评内容新增结果异常');
- const assessmentDetail = await callLegacyFunction(memberLogin.sessionToken, { action: 'content_get', id: assessment.result });
- if (String(assessmentDetail.result?.[0]?.df) !== '7' || String(assessmentDetail.result?.[0]?.prevScore) !== '0' || Number(assessmentDetail.result?.[0]?.UserID ?? assessmentDetail.result?.[0]?.userId) !== memberLegacyId) throw new Error('规范化测评内容新增写后读失败');
- const missingSchemaCreate = await callLegacyFunction(memberLogin.sessionToken, { action: 'content_add', content: JSON.stringify({ ModelID: 55, nodeId: 255 }), addon: JSON.stringify({ UserID: memberLegacyId, scnr: '[]' }) }, 501);
- if (!String(missingSchemaCreate.retmsg).includes('未迁移内容模型 55')) throw new Error('缺 Schema 内容新增未明确拒绝');
- const studyAddon = { con: '云函数学习记录冒烟测试', dqrq: '20260818', fxrl: '20260819,20260820', UserID: memberLegacyId, learned: 1, ygg: 0, djq: 0, xxqs: JSON.stringify([{ GeneralID: 2505, Title: 'woman', check: 0 }]) };
- const createdStudy = await callLegacyFunction(memberLogin.sessionToken, { action: 'stu_record_update_v2', orderId: temporaryAppointmentId, uid: memberLegacyId, inputer: memberUsername, addon: JSON.stringify(studyAddon) });
- if (!createdStudy.result?.created || !createdStudy.result?.GeneralID || !createdStudy.result?.recordObjectId) throw new Error('预约学习记录首次双表写入校验失败');
- const studyDetail = await callLegacyFunction(memberLogin.sessionToken, { action: 'e_record_detail', id: createdStudy.result.GeneralID });
- if (studyDetail.result?.[0]?.detail?.[0]?.Title !== 'woman') throw new Error('预约学习记录写后详情校验失败');
- const coachStudyDetail = await callLegacyFunction(coachLogin.sessionToken, { action: 'e_record_detail', id: createdStudy.result.GeneralID });
- if (coachStudyDetail.result?.[0]?.detail?.[0]?.Title !== 'woman') throw new Error('陪练老师无法查看关联学员的学习记录');
- studyAddon.xxqs = JSON.stringify([{ GeneralID: 2505, Title: 'woman', check: 1 }]);
- const updatedStudy = await callLegacyFunction(memberLogin.sessionToken, { action: 'stu_record_update_v2', orderId: temporaryAppointmentId, uid: memberLegacyId, inputer: memberUsername, addon: JSON.stringify(studyAddon) });
- if (updatedStudy.result?.created || updatedStudy.result?.GeneralID !== createdStudy.result.GeneralID) throw new Error('预约学习记录幂等更新校验失败');
- const studyList = await callLegacyFunction(memberLogin.sessionToken, { action: 'content_list', modelId: 56, myfield2: `UserId=${memberLegacyId}|dsid=${temporaryAppointmentId}`, page: 1, pageSize: 2 });
- if (studyList.page?.itemCount !== 1 || Number(studyList.result?.[0]?.ygg) !== 1 || Number(studyList.result?.[0]?.learned) !== 1) throw new Error('预约学习记录聚合字段写后读校验失败');
- const orderContent = JSON.stringify({ GeneralID: temporaryAppointmentId, UpDateTime: '2026-08-18 13:30' });
- await callLegacyFunction(memberLogin.sessionToken, { action: 'e_order_update_v2', uid: memberLegacyId, status: 10, content: orderContent }, 403);
- const startedOrder = await callLegacyFunction(coachLogin.sessionToken, { action: 'e_order_update_v2', uid: coachLegacyId, status: 10, content: orderContent });
- if (startedOrder.result?.previousStatus !== 0 || startedOrder.result?.status !== 10) throw new Error('预约开始状态迁移失败');
- const endedOrder = await callLegacyFunction(coachLogin.sessionToken, { action: 'e_order_update_v2', uid: coachLegacyId, status: 11, content: orderContent });
- if (endedOrder.result?.reviewCount !== 2 || !endedOrder.result?.periodDeducted) throw new Error('预约结束课时与抗遗忘副作用失败');
- const repeatedEnd = await callLegacyFunction(coachLogin.sessionToken, { action: 'e_order_update_v2', uid: coachLegacyId, status: 11, content: orderContent });
- if (!repeatedEnd.result?.unchanged) throw new Error('预约结束状态未保持幂等');
- const updatedMember = await jsonRequest(`${PARSE_URL}/users/${memberId}`, {}, true);
- if (Number(updatedMember.legacyUserData?.Purse) !== 1 || Number(updatedMember.legacyUserData?.UserPoint) !== 1.5) throw new Error(`预约结束课时扣减异常:${JSON.stringify(updatedMember.legacyUserData)}`);
- const sideEffectWhere = encodeURIComponent(JSON.stringify({ sourceKey: { $regex: `^cloud:e_order_update:${temporaryAppointmentId}:` } }));
- const [periodLogs, pointLogs, memoryRows, memoryCommonRows] = await Promise.all([
- jsonRequest(`${PARSE_URL}/classes/UserExpDomP?where=${sideEffectWhere}&count=1&limit=0`, {}, true),
- jsonRequest(`${PARSE_URL}/classes/UserUserPoint?where=${sideEffectWhere}&count=1&limit=0`, {}, true),
- jsonRequest(`${PARSE_URL}/classes/MemoryPracticeRecord?where=${sideEffectWhere}&count=1&limit=0`, {}, true),
- jsonRequest(`${PARSE_URL}/classes/CommonModel?where=${sideEffectWhere}&count=1&limit=0`, {}, true),
- ]);
- if (periodLogs.count !== 1 || pointLogs.count !== 1 || memoryRows.count !== 2 || memoryCommonRows.count !== 2) throw new Error(`预约结束账本/抗遗忘数量异常:${periodLogs.count}/${pointLogs.count}/${memoryRows.count}/${memoryCommonRows.count}`);
- const purseHistory = await callLegacyFunction(memberLogin.sessionToken, { action: 'user_point_list', uid: memberLegacyId, stype: 1, cpage: 1, psize: 10 });
- if (purseHistory.page?.itemCount !== 1 || Number(purseHistory.result?.[0]?.score) !== -1 || !purseHistory.result?.[0]?.ExpHisID || purseHistory.result?.[0]?.Detail === undefined || purseHistory.addon?.purseFeeRuleUnavailable !== true) throw new Error(`余额账本读取异常:${JSON.stringify(purseHistory)}`);
- const couponHistory = await callLegacyFunction(memberLogin.sessionToken, { action: 'user_point_list', uid: memberLegacyId, stype: 4, cpage: 1, psize: 10 });
- const couponOrderEntry = couponHistory.result?.find((entry) => entry.sourceKey === `cloud:e_order_update:${temporaryAppointmentId}:point`);
- if (couponHistory.page?.itemCount < 1 || Number(couponOrderEntry?.score) !== -0.5 || !couponOrderEntry?.HisTime) throw new Error(`点券账本读取异常:${JSON.stringify(couponHistory)}`);
- await callLegacyFunction(memberLogin.sessionToken, { action: 'user_point_list', uid: memberLegacyId, stype: 7 }, 400);
- await callLegacyFunction(coachLogin.sessionToken, { action: 'e_order_update_v2', uid: coachLegacyId, status: 20, content: orderContent }, 403);
- await callLegacyFunction(memberLogin.sessionToken, { action: 'e_order_update_v2', uid: memberLegacyId, status: 20, content: orderContent });
- await callLegacyFunction(coachLogin.sessionToken, { action: 'e_order_update_v2', uid: coachLegacyId, status: 30, content: orderContent });
- const completedOrder = await callLegacyFunction(memberLogin.sessionToken, { action: 'e_order_detail', id: temporaryAppointmentId });
- if (Number(completedOrder.result?.[0]?.dszt) !== 30) throw new Error('预约状态机写后读失败');
- const coachStats = await callLegacyFunction(coachLogin.sessionToken, { action: 'e_order_tongji', uid: coachLegacyId });
- if (coachStats.result?.t30 !== '1' || coachStats.result?.t60 !== '1' || coachStats.result?.t_tiyan !== '1' || coachStats.result?.t_total !== '3' || coachStats.result?.t_shichang !== '2.5' || coachStats.result?.t_yongji !== '100') throw new Error('陪练预约统计公式校验失败');
- const memberStats = await callLegacyFunction(memberLogin.sessionToken, { action: 'e_order_tongji', uid: memberLegacyId });
- if (memberStats.result?.t30 !== '1' || memberStats.result?.t60 !== '0' || memberStats.result?.t_tiyan !== '0' || memberStats.result?.t_total !== '1' || memberStats.result?.t_shichang !== '0.5' || memberStats.result?.t_yongji !== '0') throw new Error(`学员预约与生词统计公式校验失败:${JSON.stringify(memberStats.result)}`);
- const deniedCourseWords = await callLegacyFunction(memberLogin.sessionToken, { action: 'e_ck_list', uid: 58, nids: 40, page: 1, pageSize: 1 }, 403);
- if (!String(deniedCourseWords.retmsg).includes('无权')) throw new Error('普通用户跨用户课程词库未被拒绝');
- const denied = await callLegacyFunction(memberLogin.sessionToken, { action: 'content_list', modelId: 56, myfield2: 'UserId=3', page: 1, pageSize: 1 }, 403);
- if (!String(denied.retmsg).includes('无权')) throw new Error('普通用户跨用户记录未被拒绝');
- const profile = await callLegacyFunction(login.sessionToken, { action: 'user_get' });
- if (profile.retcode !== 0 || profile.result?.objectId !== userId) throw new Error('app gateway 用户会话校验失败');
- const privateCart = await callLegacyFunction('', { action: 'cart_list' }, 401);
- if (!String(privateCart.retmsg).includes('登录')) throw new Error('购物车未要求用户会话');
- const publicProducts = await callLegacyFunction('', { action: 'product_list', page: 1, pageSize: 2 });
- if (!Array.isArray(publicProducts.result) || !publicProducts.page) throw new Error('公开商品列表契约异常');
- const changedPassword = randomBytes(24).toString('base64url');
- const wrongPassword = await callFunctionError('xiaoshu/admin/gateway', login.sessionToken, { operation: 'changeOwnPassword', oldPassword: 'definitely-wrong-password', newPassword: changedPassword }, 400); if (!String(wrongPassword.message).includes('原密码')) throw new Error('管理员修改密码未校验原密码');
- const passwordChange = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'changeOwnPassword', oldPassword: password, newPassword: changedPassword }); if (passwordChange.objectId !== userId || passwordChange.reauthenticationRequired !== true || Number(passwordChange.revokedSessions) < 1) throw new Error(`管理员修改密码与会话撤销异常:${JSON.stringify(passwordChange)}`);
- const oldSessionResponse = await fetch(`${FUNCTION_URL}/xiaoshu/admin/gateway`, { method: 'POST', headers: { 'X-Parse-Application-Id': APP_ID, 'Content-Type': 'application/json' }, body: JSON.stringify({ token: login.sessionToken, params: { operation: 'meta' } }) }); if (oldSessionResponse.status !== 401) throw new Error(`管理员改密后旧会话仍可使用:${oldSessionResponse.status}`);
- const oldPasswordResponse = await fetch(`${PARSE_URL}/login`, { method: 'POST', headers: { 'X-Parse-Application-Id': APP_ID, 'Content-Type': 'application/json' }, body: JSON.stringify({ username, password }) }); if (oldPasswordResponse.ok) throw new Error('管理员旧密码在修改后仍可登录');
- const changedLogin = await jsonRequest(`${PARSE_URL}/login`, { method: 'POST', body: JSON.stringify({ username, password: changedPassword }) }); if (!changedLogin.sessionToken) throw new Error('管理员修改密码后无法用新密码登录'); login.sessionToken = changedLogin.sessionToken;
- const logout = await callFunction('xiaoshu/admin/gateway', login.sessionToken, { operation: 'logout', sessionToken: login.sessionToken });
- if (logout.revoked !== true) throw new Error('管理员退出未销毁当前 Parse 会话');
- const revokedResponse = await fetch(`${FUNCTION_URL}/xiaoshu/admin/gateway`, { method: 'POST', headers: { 'X-Parse-Application-Id': APP_ID, 'Content-Type': 'application/json' }, body: JSON.stringify({ token: login.sessionToken, params: { operation: 'meta' } }) });
- const revokedPayload = await revokedResponse.json().catch(() => ({}));
- if (revokedResponse.status !== 401 || !String(revokedPayload.message || revokedPayload.error || '').toLowerCase().includes('sessiontoken')) throw new Error(`已退出管理员会话仍可使用: ${revokedResponse.status}`);
- console.log('Cloud smoke passed: admin auth/logout/tenant/account lifecycle/group sync/node/special/guest-category/bar/exam-class/exam-point/knowledge/exam-teacher/dictionary/grade-dictionary/currency/holiday/search-navigation/advertising/font-shapes/design-scenes/design-templates/surveys/customer-service/stores/content-tags/shop-vendor-blockers/user-level/money-ledgers/balance-adjustment/user-blockers/user-addon-blockers/ask-blockers/biao-calc-blockers/office-chart-blocker/chat-blockers/design-class-blockers/structure-blockers/vue-blockers/workload/vbook/vdesign/spage/write-pearl blockers/com-blockers/common-blockers/site-config-blockers/baike/api-catalog/config-blockers/model/guestbook lifecycle/content workflow/CRUD reads, CMS projections, normalized learning joins, app action coverage, public content, session scope, 1,042-action coverage with zero pending items.');
- } finally {
- if (adZoneRestore) await jsonRequest(`${PARSE_URL}/classes/AdZone/${adZoneRestore.objectId}`, { method: 'PUT', body: JSON.stringify({ remind: adZoneRestore.remind, zstatus: adZoneRestore.zstatus }) }, true).catch((error) => { console.error(`广告位冒烟数据恢复失败:${error.message}`); process.exitCode = 1; });
- if (adInfoRestore) await jsonRequest(`${PARSE_URL}/classes/AdInfo/${adInfoRestore.objectId}`, { method: 'PUT', body: JSON.stringify({ remind: adInfoRestore.remind, zstatus: adInfoRestore.zstatus }) }, true).catch((error) => { console.error(`广告内容冒烟数据恢复失败:${error.message}`); process.exitCode = 1; });
- if (fontShapeRestore) await jsonRequest(`${PARSE_URL}/classes/FontPicShape/${fontShapeRestore.objectId}`, { method: 'PUT', body: JSON.stringify({ shape: fontShapeRestore.shape, remarks: fontShapeRestore.remarks, typeId: fontShapeRestore.typeId, ...(fontShapeRestore.updateTime ? { updateTime: fontShapeRestore.updateTime } : {}) }) }, true).catch((error) => { console.error(`图形素材冒烟数据恢复失败:${error.message}`); process.exitCode = 1; });
- if (temporaryFontShapeId) await jsonRequest(`${PARSE_URL}/classes/FontPicShape/${temporaryFontShapeId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时图形素材清理失败:${error.message}`); process.exitCode = 1; });
- if (temporaryFontShapeTypeId) await jsonRequest(`${PARSE_URL}/classes/FontPicShapeType/${temporaryFontShapeTypeId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时图形分类清理失败:${error.message}`); process.exitCode = 1; });
- if (designResourceRestore) await jsonRequest(`${PARSE_URL}/classes/DesignRes/${designResourceRestore.objectId}`, { method: 'PUT', body: JSON.stringify(designResourceRestore.fields) }, true).catch((error) => { console.error(`设计资源冒烟数据恢复失败:${error.message}`); process.exitCode = 1; });
- if (temporaryDesignResourceId) await jsonRequest(`${PARSE_URL}/classes/DesignRes/${temporaryDesignResourceId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时设计资源清理失败:${error.message}`); process.exitCode = 1; });
- if (temporaryDesignSceneId) await jsonRequest(`${PARSE_URL}/classes/DesignScence/${temporaryDesignSceneId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时可视化场景清理失败:${error.message}`); process.exitCode = 1; });
- if (temporaryDesignSceneCloneId) await jsonRequest(`${PARSE_URL}/classes/DesignScence/${temporaryDesignSceneCloneId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时模板场景副本清理失败:${error.message}`); process.exitCode = 1; });
- if (temporaryDesignSceneTemplateId) await jsonRequest(`${PARSE_URL}/classes/DesignTlp/${temporaryDesignSceneTemplateId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时可视化模板清理失败:${error.message}`); process.exitCode = 1; });
- if (temporaryDesignTemplateSceneId) await jsonRequest(`${PARSE_URL}/classes/DesignScence/${temporaryDesignTemplateSceneId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时空模板场景清理失败:${error.message}`); process.exitCode = 1; });
- if (temporaryDesignTemplateId) await jsonRequest(`${PARSE_URL}/classes/DesignTlp/${temporaryDesignTemplateId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时独立模板清理失败:${error.message}`); process.exitCode = 1; });
- if (temporaryRoleAuthId) await jsonRequest(`${PARSE_URL}/classes/ARoleAuth/${temporaryRoleAuthId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时角色权限清理失败:${error.message}`); process.exitCode = 1; });
- if (temporaryRoleId) await jsonRequest(`${PARSE_URL}/classes/Role/${temporaryRoleId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时角色清理失败:${error.message}`); process.exitCode = 1; });
- if (surveyRestore) await jsonRequest(`${PARSE_URL}/classes/DesignAsk/${surveyRestore.objectId}`, { method: 'PUT', body: JSON.stringify(surveyRestore.fields) }, true).catch((error) => { console.error(`问卷冒烟数据恢复失败:${error.message}`); process.exitCode = 1; });
- if (surveyQuestionRestore) await jsonRequest(`${PARSE_URL}/classes/DesignQuestion/${surveyQuestionRestore.objectId}`, { method: 'PUT', body: JSON.stringify(surveyQuestionRestore.fields) }, true).catch((error) => { console.error(`问卷题目冒烟数据恢复失败:${error.message}`); process.exitCode = 1; });
- if (temporarySurveyAnswerId) await jsonRequest(`${PARSE_URL}/classes/DesignAnswer/${temporarySurveyAnswerId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时问卷答卷清理失败:${error.message}`); process.exitCode = 1; });
- for (const objectId of temporarySurveyQuestionIds) await jsonRequest(`${PARSE_URL}/classes/DesignQuestion/${objectId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时问卷题目清理失败:${error.message}`); process.exitCode = 1; });
- if (temporarySurveyId) await jsonRequest(`${PARSE_URL}/classes/DesignAsk/${temporarySurveyId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时问卷清理失败:${error.message}`); process.exitCode = 1; });
- if (serviceSeatRestore) await jsonRequest(`${PARSE_URL}/classes/ServiceSeat/${serviceSeatRestore.objectId}`, { method: 'PUT', body: JSON.stringify(serviceSeatRestore.fields) }, true).catch((error) => { console.error(`客服席位冒烟数据恢复失败:${error.message}`); process.exitCode = 1; });
- if (serviceCodeRestore) await jsonRequest(`${PARSE_URL}/classes/Temp/${serviceCodeRestore.objectId}`, { method: 'PUT', body: JSON.stringify(serviceCodeRestore.fields) }, true).catch((error) => { console.error(`客服欢迎语冒烟数据恢复失败:${error.message}`); process.exitCode = 1; });
- if (temporaryServiceSeatId) await jsonRequest(`${PARSE_URL}/classes/ServiceSeat/${temporaryServiceSeatId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时客服席位清理失败:${error.message}`); process.exitCode = 1; });
- if (temporaryServiceCodeId) await jsonRequest(`${PARSE_URL}/classes/Temp/${temporaryServiceCodeId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时客服欢迎语清理失败:${error.message}`); process.exitCode = 1; });
- if (storeApplicationRestore) await jsonRequest(`${PARSE_URL}/classes/StoreApplication/${storeApplicationRestore.objectId}`, { method: 'PUT', body: JSON.stringify(storeApplicationRestore.fields) }, true).catch((error) => { console.error(`店铺冒烟数据恢复失败:${error.message}`); process.exitCode = 1; });
- if (storeStyleRestore) await jsonRequest(`${PARSE_URL}/classes/StoreStyle/${storeStyleRestore.objectId}`, { method: 'PUT', body: JSON.stringify(storeStyleRestore.fields) }, true).catch((error) => { console.error(`店铺样式冒烟数据恢复失败:${error.message}`); process.exitCode = 1; });
- if (temporaryStoreApplicationId) await jsonRequest(`${PARSE_URL}/classes/StoreApplication/${temporaryStoreApplicationId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时店铺清理失败:${error.message}`); process.exitCode = 1; });
- if (temporaryStoreStyleId) await jsonRequest(`${PARSE_URL}/classes/StoreStyle/${temporaryStoreStyleId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时店铺样式清理失败:${error.message}`); process.exitCode = 1; });
- if (contentTagsRestore) await jsonRequest(`${PARSE_URL}/config`, { method: 'PUT', body: JSON.stringify({ params: { legacyContentTags: contentTagsRestore } }) }, true).catch((error) => { console.error(`内容标签冒烟数据恢复失败:${error.message}`); process.exitCode = 1; });
- if (userLevelRestore) await jsonRequest(`${PARSE_URL}/classes/UserLevel/${userLevelRestore.objectId}`, { method: 'PUT', body: JSON.stringify(userLevelRestore.fields) }, true).catch((error) => { console.error(`积分等级冒烟数据恢复失败:${error.message}`); process.exitCode = 1; });
- if (temporaryUserLevelId) await jsonRequest(`${PARSE_URL}/classes/UserLevel/${temporaryUserLevelId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时积分等级清理失败:${error.message}`); process.exitCode = 1; });
- if (temporaryCrmClientTypeId) await jsonRequest(`${PARSE_URL}/classes/CRMSAttr/${temporaryCrmClientTypeId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时 CRM 客户类型清理失败:${error.message}`); process.exitCode = 1; });
- if (temporaryShopFareTemplateId) await jsonRequest(`${PARSE_URL}/classes/ShopFareTlp/${temporaryShopFareTemplateId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时商城运费模板清理失败:${error.message}`); process.exitCode = 1; });
- if (temporaryMisTypeId) await jsonRequest(`${PARSE_URL}/classes/MisType/${temporaryMisTypeId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时 OA 流程类型清理失败:${error.message}`); process.exitCode = 1; });
- if (temporaryPageStyleId) await jsonRequest(`${PARSE_URL}/classes/PageStyle/${temporaryPageStyleId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时黄页样式清理失败:${error.message}`); process.exitCode = 1; });
- if (temporaryPlatformMemberId) await jsonRequest(`${PARSE_URL}/users/${temporaryPlatformMemberId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时协同办公成员清理失败:${error.message}`); process.exitCode = 1; });
- if (temporaryPlatformCompanyId) await jsonRequest(`${PARSE_URL}/classes/PlatComp/${temporaryPlatformCompanyId}`, { method: 'DELETE' }, true).catch((error) => { console.error(`临时协同办公企业清理失败:${error.message}`); process.exitCode = 1; });
- if (baikeRestore) await jsonRequest(`${PARSE_URL}/classes/Baike/${baikeRestore.objectId}`, { method: 'PUT', body: JSON.stringify(baikeRestore.fields) }, true).catch((error) => { console.error(`百科冒烟数据恢复失败:${error.message}`); process.exitCode = 1; });
- if (contentHitObjectId) await jsonRequest(`${PARSE_URL}/classes/CommonModel/${contentHitObjectId}`, { method: 'PUT', body: JSON.stringify({ hits: contentHitOriginal }) }, true).catch((error) => {
- console.error(`公开内容浏览量恢复失败:${error.message}`);
- process.exitCode = 1;
- });
- if (registeredUserId) await jsonRequest(`${PARSE_URL}/users/${registeredUserId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时注册用户清理失败:${error.message}`);
- process.exitCode = 1;
- });
- if (adminCreatedUserId) await jsonRequest(`${PARSE_URL}/users/${adminCreatedUserId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`管理员开户临时用户清理失败:${error.message}`);
- process.exitCode = 1;
- });
- if (temporaryGroupObjectId) await jsonRequest(`${PARSE_URL}/classes/Group/${temporaryGroupObjectId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时用户组清理失败:${error.message}`);
- process.exitCode = 1;
- });
- for (const nodeId of temporaryNodeObjectIds) if (nodeId) await jsonRequest(`${PARSE_URL}/classes/Node/${nodeId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时栏目清理失败:${error.message}`);
- process.exitCode = 1;
- });
- for (const specialId of temporarySpecialObjectIds) if (specialId) await jsonRequest(`${PARSE_URL}/classes/Special/${specialId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时专题清理失败:${error.message}`);
- process.exitCode = 1;
- });
- for (const categoryId of temporaryGuestCategoryObjectIds) if (categoryId) await jsonRequest(`${PARSE_URL}/classes/Guestcate/${categoryId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时留言/贴吧分类清理失败:${error.message}`);
- process.exitCode = 1;
- });
- for (const knowledgeId of [...temporaryKnowledgeObjectIds].reverse()) if (knowledgeId) await jsonRequest(`${PARSE_URL}/classes/QuestionsKnowledge/${knowledgeId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时知识点清理失败:${error.message}`);
- process.exitCode = 1;
- });
- if (temporaryExamTeacherId) await jsonRequest(`${PARSE_URL}/classes/ExTeacher/${temporaryExamTeacherId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时考试教师清理失败:${error.message}`);
- process.exitCode = 1;
- });
- for (const dictionaryItemId of temporaryDictionaryItemIds) if (dictionaryItemId) await jsonRequest(`${PARSE_URL}/classes/Datadic/${dictionaryItemId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时字典项清理失败:${error.message}`);
- process.exitCode = 1;
- });
- for (const dictionaryCategoryId of temporaryDictionaryCategoryIds) if (dictionaryCategoryId) await jsonRequest(`${PARSE_URL}/classes/Datadiccategory/${dictionaryCategoryId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时字典分类清理失败:${error.message}`);
- process.exitCode = 1;
- });
- for (const gradeOptionId of [...temporaryGradeOptionIds].reverse()) if (gradeOptionId) await jsonRequest(`${PARSE_URL}/classes/Grade/${gradeOptionId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时多级字典选项清理失败:${error.message}`);
- process.exitCode = 1;
- });
- for (const gradeCategoryId of temporaryGradeCategoryIds) if (gradeCategoryId) await jsonRequest(`${PARSE_URL}/classes/GradeCate/${gradeCategoryId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时多级字典分类清理失败:${error.message}`);
- process.exitCode = 1;
- });
- for (const examClassId of [...temporaryExamClassObjectIds].reverse()) if (examClassId) await jsonRequest(`${PARSE_URL}/classes/ExamClass/${examClassId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时试题分类清理失败:${error.message}`);
- process.exitCode = 1;
- });
- for (const examPointId of [...temporaryExamPointObjectIds].reverse()) if (examPointId) await jsonRequest(`${PARSE_URL}/classes/ExamPoint/${examPointId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时考点清理失败:${error.message}`);
- process.exitCode = 1;
- });
- for (const fieldId of temporaryModelFieldObjectIds) if (fieldId) await jsonRequest(`${PARSE_URL}/classes/ModelField/${fieldId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时模型字段清理失败:${error.message}`);
- process.exitCode = 1;
- });
- if (temporaryModelObjectId) await jsonRequest(`${PARSE_URL}/classes/Model/${temporaryModelObjectId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时模型清理失败:${error.message}`);
- process.exitCode = 1;
- });
- if (temporaryGuestbookId) await jsonRequest(`${PARSE_URL}/classes/Guestbook/${temporaryGuestbookId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时留言清理失败:${error.message}`);
- process.exitCode = 1;
- });
- if (temporaryGuestbookReplyId) await jsonRequest(`${PARSE_URL}/classes/Guestbook/${temporaryGuestbookReplyId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时管理员留言回复清理失败:${error.message}`);
- process.exitCode = 1;
- });
- if (temporaryGuestBarId) await jsonRequest(`${PARSE_URL}/classes/GuestBar/${temporaryGuestBarId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时贴吧帖子清理失败:${error.message}`);
- process.exitCode = 1;
- });
- for (const lessonId of temporaryLessonIds) await jsonRequest(`${PARSE_URL}/classes/LessonRecord/${lessonId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时陪练课次清理失败:${error.message}`);
- process.exitCode = 1;
- });
- if (memberLegacyId) {
- const commonWhere = encodeURIComponent(JSON.stringify({ sourceKey: { $regex: `^cloud:(stu_record|content_add_zt|content_add):${memberLegacyId}:` } }));
- const commonRows = await jsonRequest(`${PARSE_URL}/classes/CommonModel?where=${commonWhere}&limit=1000`, {}, true).catch(() => ({ results: [] }));
- for (const row of commonRows.results || []) await jsonRequest(`${PARSE_URL}/classes/CommonModel/${row.objectId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时学习主记录清理失败:${error.message}`);
- process.exitCode = 1;
- });
- const studyWhere = encodeURIComponent(JSON.stringify({ userId: memberLegacyId }));
- const studyRows = await jsonRequest(`${PARSE_URL}/classes/DailyStudyRecord?where=${studyWhere}&limit=1000`, {}, true).catch(() => ({ results: [] }));
- for (const row of studyRows.results || []) await jsonRequest(`${PARSE_URL}/classes/DailyStudyRecord/${row.objectId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时学习 addon 清理失败:${error.message}`);
- process.exitCode = 1;
- });
- }
- if (temporaryAppointmentObjectId) await jsonRequest(`${PARSE_URL}/classes/CourseAppointment/${temporaryAppointmentObjectId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时预约清理失败:${error.message}`);
- process.exitCode = 1;
- });
- if (temporaryAppointmentId) {
- const sideEffectWhere = encodeURIComponent(JSON.stringify({ sourceKey: { $regex: `^cloud:e_order_update:${temporaryAppointmentId}:` } }));
- for (const className of ['CommonModel', 'MemoryPracticeRecord', 'UserExpDomP', 'UserUserPoint']) {
- const rows = await jsonRequest(`${PARSE_URL}/classes/${className}?where=${sideEffectWhere}&limit=1000`, {}, true).catch(() => ({ results: [] }));
- for (const row of rows.results || []) await jsonRequest(`${PARSE_URL}/classes/${className}/${row.objectId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时预约副作用清理失败(${className}):${error.message}`);
- process.exitCode = 1;
- });
- }
- }
- if (memberLegacyId) {
- const assessmentWhere = encodeURIComponent(JSON.stringify({ sourceKey: { $regex: `^cloud:content_add:${memberLegacyId}:` } }));
- const assessments = await jsonRequest(`${PARSE_URL}/classes/AssessmentProfile?where=${assessmentWhere}&limit=1000`, {}, true).catch(() => ({ results: [] }));
- for (const assessment of assessments.results || []) await jsonRequest(`${PARSE_URL}/classes/AssessmentProfile/${assessment.objectId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时测评记录清理失败:${error.message}`);
- process.exitCode = 1;
- });
- }
- if (memberLegacyId) {
- const where = encodeURIComponent(JSON.stringify({ yhid: String(memberLegacyId) }));
- const practices = await jsonRequest(`${PARSE_URL}/classes/PracticeRecord?where=${where}&limit=1000`, {}, true).catch(() => ({ results: [] }));
- for (const practice of practices.results || []) await jsonRequest(`${PARSE_URL}/classes/PracticeRecord/${practice.objectId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时学习进度清理失败:${error.message}`);
- process.exitCode = 1;
- });
- }
- if (teamChildId) {
- await jsonRequest(`${PARSE_URL}/users/${teamChildId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时团队成员清理失败:${error.message}`);
- process.exitCode = 1;
- });
- }
- for (const item of temporaryBalanceLogs) if (item.className && item.objectId) await jsonRequest(`${PARSE_URL}/classes/${item.className}/${item.objectId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时资金调整流水清理失败:${error.message}`);
- process.exitCode = 1;
- });
- if (memberId) {
- await jsonRequest(`${PARSE_URL}/users/${memberId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时普通用户清理失败:${error.message}`);
- process.exitCode = 1;
- });
- }
- if (coachId) {
- await jsonRequest(`${PARSE_URL}/users/${coachId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时陪练用户清理失败:${error.message}`);
- process.exitCode = 1;
- });
- }
- if (userId) {
- await jsonRequest(`${PARSE_URL}/users/${userId}`, { method: 'DELETE' }, true).catch((error) => {
- console.error(`临时管理员清理失败:${error.message}`);
- process.exitCode = 1;
- });
- }
- }
|