From 29fc6f5b1981775be5d2f0f9f8e61fec2f550252 Mon Sep 17 00:00:00 2001 From: lrj <owen.stl@gmail.com> Date: 星期一, 29 九月 2025 19:29:11 +0800 Subject: [PATCH] 删除所有test开头的测试文件 --- /dev/null | 114 --------------------------------------------------------- 1 files changed, 0 insertions(+), 114 deletions(-) diff --git a/test_activity_exists.js b/test_activity_exists.js deleted file mode 100644 index 52e5e4b..0000000 --- a/test_activity_exists.js +++ /dev/null @@ -1,33 +0,0 @@ -const axios = require('axios'); - -const API_URL = 'http://localhost:8080/api/graphql'; - -async function testActivityExists() { - try { - console.log('娴嬭瘯娲诲姩鏄惁瀛樺湪...'); - - // 鏌ヨ鐗瑰畾娲诲姩 - const activityQuery = { - query: ` - query { - activity(id: "55") { - id - name - description - signupDeadline - state - ratingSchemeId - } - } - ` - }; - - const response = await axios.post(API_URL, activityQuery); - console.log('娲诲姩鏌ヨ缁撴灉:', JSON.stringify(response.data, null, 2)); - - } catch (error) { - console.error('鏌ヨ澶辫触:', error.response?.data || error.message); - } -} - -testActivityExists(); \ No newline at end of file diff --git a/test_activity_stages.js b/test_activity_stages.js deleted file mode 100644 index 2a19406..0000000 --- a/test_activity_stages.js +++ /dev/null @@ -1,53 +0,0 @@ -const axios = require('axios'); - -const GRAPHQL_URL = 'http://localhost:8080/api/graphql'; - -async function testActivityStages() { - try { - console.log('馃攳 鏌ヨ娲诲姩55鐨勯樁娈典俊鎭�...'); - - const query = ` - query { - activity(id: "55") { - id - name - description - pid - path - stages { - id - name - description - pid - path - } - } - } - `; - - const response = await axios.post(GRAPHQL_URL, { - query: query - }, { - headers: { - 'Content-Type': 'application/json' - } - }); - - if (response.data.errors) { - console.error('鉂� GraphQL閿欒:', response.data.errors); - return; - } - - console.log('鉁� 鏌ヨ鎴愬姛!'); - console.log('娲诲姩55淇℃伅:', JSON.stringify(response.data.data.activities, null, 2)); - - } catch (error) { - console.error('鉂� 璇锋眰澶辫触:', error.message); - if (error.response) { - console.error('鍝嶅簲鐘舵��:', error.response.status); - console.error('鍝嶅簲鏁版嵁:', error.response.data); - } - } -} - -testActivityStages(); \ No newline at end of file diff --git a/test_avatar_integration.js b/test_avatar_integration.js deleted file mode 100644 index 660483d..0000000 --- a/test_avatar_integration.js +++ /dev/null @@ -1,174 +0,0 @@ -/** - * 澶村儚涓婁紶鍔熻兘闆嗘垚娴嬭瘯 - * 楠岃瘉灏忕▼搴忔敞鍐岄〉闈㈢殑澶村儚涓婁紶鍔熻兘鏄惁姝g‘瀹炵幇 - */ - -console.log('=== 澶村儚涓婁紶鍔熻兘闆嗘垚娴嬭瘯 ===\n'); - -// 1. 楠岃瘉WXML缁撴瀯 -console.log('1. 妫�鏌XML缁撴瀯...'); -const fs = require('fs'); -const path = require('path'); - -try { - const wxml = fs.readFileSync(path.join(__dirname, 'wx/pages/registration/registration.wxml'), 'utf8'); - - const checks = [ - { name: '澶村儚涓婁紶瀹瑰櫒', pattern: /avatar-upload-container/ }, - { name: '涓婁紶鎸夐挳', pattern: /avatar-upload-btn/ }, - { name: '澶村儚棰勮', pattern: /avatar-preview/ }, - { name: '涓婁紶杩涘害', pattern: /upload-progress/ }, - { name: '鎿嶄綔鎸夐挳', pattern: /avatar-actions/ }, - { name: '涓婁紶鎻愮ず', pattern: /avatar-upload-hint/ }, - { name: '閿欒鐘舵��', pattern: /errors\.avatar/ } - ]; - - checks.forEach(check => { - if (check.pattern.test(wxml)) { - console.log(` 鉁� ${check.name} - 宸插疄鐜癭); - } else { - console.log(` 鉁� ${check.name} - 缂哄け`); - } - }); - -} catch (error) { - console.log(` 鉁� 鏃犳硶璇诲彇WXML鏂囦欢: ${error.message}`); -} - -// 2. 楠岃瘉WXSS鏍峰紡 -console.log('\n2. 妫�鏌XSS鏍峰紡...'); -try { - const wxss = fs.readFileSync(path.join(__dirname, 'wx/pages/registration/registration.wxss'), 'utf8'); - - const styleChecks = [ - { name: '澶村儚瀹瑰櫒鏍峰紡', pattern: /\.avatar-upload-container/ }, - { name: '涓婁紶鎸夐挳鏍峰紡', pattern: /\.avatar-upload-btn/ }, - { name: '澶村儚棰勮鏍峰紡', pattern: /\.avatar-preview/ }, - { name: '杩涘害鏉℃牱寮�', pattern: /\.upload-progress/ }, - { name: '鍔ㄧ敾鏁堟灉', pattern: /@keyframes|animation/ }, - { name: '閿欒鐘舵�佹牱寮�', pattern: /\.error/ } - ]; - - styleChecks.forEach(check => { - if (check.pattern.test(wxss)) { - console.log(` 鉁� ${check.name} - 宸插疄鐜癭); - } else { - console.log(` 鉁� ${check.name} - 缂哄け`); - } - }); - -} catch (error) { - console.log(` 鉁� 鏃犳硶璇诲彇WXSS鏂囦欢: ${error.message}`); -} - -// 3. 楠岃瘉JS閫昏緫 -console.log('\n3. 妫�鏌S閫昏緫...'); -try { - const js = fs.readFileSync(path.join(__dirname, 'wx/pages/registration/registration.js'), 'utf8'); - - const jsChecks = [ - { name: '澶村儚鏁版嵁瀛楁', pattern: /avatarUrl.*avatarMediaId/ }, - { name: '涓婁紶鐘舵�佺鐞�', pattern: /avatarUploading/ }, - { name: '閫夋嫨澶村儚鏂规硶', pattern: /onChooseAvatar/ }, - { name: '鍒犻櫎澶村儚鏂规硶', pattern: /onDeleteAvatar/ }, - { name: '鏂囦欢绫诲瀷楠岃瘉', pattern: /allowedTypes.*image/ }, - { name: '鏂囦欢澶у皬楠岃瘉', pattern: /5.*1024.*1024/ }, - { name: '鍥剧墖灏哄楠岃瘉', pattern: /getImageInfo/ }, - { name: 'COS涓婁紶闆嗘垚', pattern: /cosUtil\.uploadAvatar/ }, - { name: '杩涘害鍥炶皟澶勭悊', pattern: /onProgress/ }, - { name: '閿欒澶勭悊', pattern: /catch.*error/ }, - { name: 'GraphQL闆嗘垚', pattern: /avatarMediaId.*playerInfo/ }, - { name: '琛ㄥ崟楠岃瘉', pattern: /errors\.avatar/ } - ]; - - jsChecks.forEach(check => { - if (check.pattern.test(js)) { - console.log(` 鉁� ${check.name} - 宸插疄鐜癭); - } else { - console.log(` 鉁� ${check.name} - 缂哄け`); - } - }); - -} catch (error) { - console.log(` 鉁� 鏃犳硶璇诲彇JS鏂囦欢: ${error.message}`); -} - -// 4. 楠岃瘉渚濊禆椤� -console.log('\n4. 妫�鏌ヤ緷璧栭」...'); -try { - const cosUtil = fs.readFileSync(path.join(__dirname, 'wx/lib/cosUtil.js'), 'utf8'); - - if (cosUtil.includes('uploadAvatar')) { - console.log(' 鉁� COS宸ュ叿绫� - uploadAvatar鏂规硶宸插疄鐜�'); - } else { - console.log(' 鉁� COS宸ュ叿绫� - uploadAvatar鏂规硶缂哄け'); - } - - if (cosUtil.includes('deleteFile')) { - console.log(' 鉁� COS宸ュ叿绫� - deleteFile鏂规硶宸插疄鐜�'); - } else { - console.log(' 鉁� COS宸ュ叿绫� - deleteFile鏂规硶缂哄け'); - } - -} catch (error) { - console.log(` 鉁� 鏃犳硶璇诲彇COS宸ュ叿绫�: ${error.message}`); -} - -// 5. 妯℃嫙GraphQL mutation -console.log('\n5. 楠岃瘉GraphQL闆嗘垚...'); -const mockPlayerInfo = { - name: "娴嬭瘯鐢ㄦ埛", - phone: "13800138000", - gender: "鐢�", - birthDate: "1990-01-01", - education: "鏈", - introduction: "娴嬭瘯绠�浠�", - avatarMediaId: "avatar_test_123456" -}; - -const mockMutation = ` - mutation SubmitRegistration($activityId: ID!, $playerInfo: PlayerInfoInput!, $regionId: ID, $projectName: String!, $description: String!) { - submitRegistration(activityId: $activityId, playerInfo: $playerInfo, regionId: $regionId, projectName: $projectName, description: $description) { - id - status - playerInfo { - name - phone - gender - avatarMediaId - } - } - } -`; - -console.log(' 鉁� GraphQL mutation鏍煎紡姝g‘'); -console.log(' 鉁� avatarMediaId瀛楁宸插寘鍚湪playerInfo涓�'); -console.log(` 鉁� 娴嬭瘯鏁版嵁: ${JSON.stringify(mockPlayerInfo, null, 2)}`); - -// 6. 鍔熻兘鐗规�ф�荤粨 -console.log('\n=== 澶村儚涓婁紶鍔熻兘鐗规�ф�荤粨 ==='); -console.log('鉁� 鏀寔浠庣浉鍐屽拰鐩告満閫夋嫨鍥剧墖'); -console.log('鉁� 鏂囦欢绫诲瀷楠岃瘉 (JPG, PNG, WebP)'); -console.log('鉁� 鏂囦欢澶у皬闄愬埗 (鏈�澶�5MB)'); -console.log('鉁� 鍥剧墖灏哄寤鸿 (鏈�灏�200x200)'); -console.log('鉁� 瀹炴椂涓婁紶杩涘害鏄剧ず'); -console.log('鉁� 澶村儚棰勮鍔熻兘'); -console.log('鉁� 閲嶆柊涓婁紶鍜屽垹闄ゅ姛鑳�'); -console.log('鉁� 瀹屾暣鐨勯敊璇鐞�'); -console.log('鉁� 浼橀泤鐨勭敤鎴风晫闈�'); -console.log('鉁� 琛ㄥ崟楠岃瘉闆嗘垚'); -console.log('鉁� GraphQL API闆嗘垚'); - -console.log('\n=== 娴嬭瘯寤鸿 ==='); -console.log('1. 鍦ㄥ井淇″紑鍙戣�呭伐鍏蜂腑鎵撳紑灏忕▼搴�'); -console.log('2. 瀵艰埅鍒版敞鍐岄〉闈�'); -console.log('3. 娴嬭瘯澶村儚涓婁紶娴佺▼锛�'); -console.log(' - 鐐瑰嚮涓婁紶鎸夐挳閫夋嫨鍥剧墖'); -console.log(' - 楠岃瘉鏂囦欢绫诲瀷鍜屽ぇ灏忛檺鍒�'); -console.log(' - 瑙傚療涓婁紶杩涘害鏄剧ず'); -console.log(' - 纭澶村儚棰勮姝e父'); -console.log(' - 娴嬭瘯閲嶆柊涓婁紶鍔熻兘'); -console.log(' - 娴嬭瘯鍒犻櫎鍔熻兘'); -console.log('4. 瀹屾垚鏁翠釜娉ㄥ唽娴佺▼锛岀‘璁ゅご鍍忔暟鎹纭彁浜�'); - -console.log('\n娴嬭瘯瀹屾垚锛�'); \ No newline at end of file diff --git a/test_avatar_upload.js b/test_avatar_upload.js deleted file mode 100644 index 17d325a..0000000 --- a/test_avatar_upload.js +++ /dev/null @@ -1,59 +0,0 @@ -// 娴嬭瘯澶村儚涓婁紶鍔熻兘 - -async function testAvatarUpload() { - try { - console.log('寮�濮嬫祴璇曞ご鍍忎笂浼犲姛鑳�...') - - // 娴嬭瘯GraphQL mutation鏄惁鏀寔avatarMediaId - const mutation = ` - mutation SubmitActivityRegistration($input: ActivityRegistrationInput!) { - submitActivityRegistration(input: $input) { - success - message - registrationId - } - } - ` - - const input = { - activityId: 1, - playerInfo: { - name: "娴嬭瘯鐢ㄦ埛", - phone: "13800138000", - gender: 0, - birthDate: "1990-01-01", - education: "鏈", - introduction: "杩欐槸涓�涓祴璇曠敤鎴�", - avatarMediaId: "avatars/20240101/test-avatar.jpg" - }, - regionId: 1, - projectName: "娴嬭瘯椤圭洰", - description: "娴嬭瘯椤圭洰鎻忚堪" - } - - console.log('鍙戦�丟raphQL璇锋眰...') - console.log('Input:', JSON.stringify(input, null, 2)) - - // 杩欓噷鍙槸楠岃瘉璇锋眰鏍煎紡锛屽疄闄呮祴璇曢渶瑕佸湪灏忕▼搴忕幆澧冧腑杩涜 - console.log('鉁� GraphQL mutation鏍煎紡姝g‘') - console.log('鉁� avatarMediaId瀛楁宸插寘鍚湪playerInfo涓�') - console.log('鉁� 澶村儚涓婁紶鍔熻兘闆嗘垚瀹屾垚') - - console.log('\n馃摑 娴嬭瘯璇存槑:') - console.log('1. 澶村儚涓婁紶UI宸叉坊鍔犲埌娉ㄥ唽椤甸潰') - console.log('2. 浣跨敤瀛椾綋鍥炬爣 ic-add 浣滀负涓婁紶鎸夐挳') - console.log('3. 鏀寔閫夋嫨鍥剧墖銆佹樉绀轰笂浼犺繘搴︺�侀瑙堝拰鍒犻櫎') - console.log('4. 闆嗘垚COS鐩存帴涓婁紶锛岄伩鍏嶅悗绔腑杞�') - console.log('5. GraphQL mutation宸叉洿鏂版敮鎸乤vatarMediaId') - console.log('\n馃敡 涓嬩竴姝ユ祴璇�:') - console.log('1. 鍦ㄥ井淇″紑鍙戣�呭伐鍏蜂腑鎵撳紑灏忕▼搴�') - console.log('2. 杩涘叆娲诲姩璇︽儏椤甸潰锛岀偣鍑绘姤鍚�') - console.log('3. 娴嬭瘯澶村儚涓婁紶鍔熻兘') - console.log('4. 楠岃瘉娉ㄥ唽娴佺▼鏄惁姝e父') - - } catch (error) { - console.error('娴嬭瘯澶辫触:', error) - } -} - -testAvatarUpload() \ No newline at end of file diff --git a/test_avatar_upload_fixed.js b/test_avatar_upload_fixed.js deleted file mode 100644 index 6c0972d..0000000 --- a/test_avatar_upload_fixed.js +++ /dev/null @@ -1,198 +0,0 @@ -// 娴嬭瘯淇鍚庣殑澶村儚涓婁紶娴佺▼ -// 杩欎釜娴嬭瘯妯℃嫙灏忕▼搴忕殑澶村儚閫夋嫨鍜屾彁浜ゆ祦绋� - -console.log('馃И 寮�濮嬫祴璇曚慨澶嶅悗鐨勫ご鍍忎笂浼犳祦绋�...\n') - -// 妯℃嫙灏忕▼搴忛〉闈㈡暟鎹粨鏋� -const mockPageData = { - localAvatarPath: '', // 鏈湴閫夋嫨鐨勫ご鍍忚矾寰� - formData: { - avatarUrl: '', - avatarMediaId: '' - }, - avatarUploading: false, - avatarUploadProgress: 0, - errors: {} -} - -// 妯℃嫙澶村儚閫夋嫨鍑芥暟锛堜慨澶嶅悗鐨勭増鏈級 -function mockChooseAvatar() { - console.log('馃摳 鐢ㄦ埛鐐瑰嚮閫夋嫨澶村儚...') - - // 妯℃嫙閫夋嫨浜嗕竴涓ご鍍忔枃浠� - const mockTempFilePath = '/temp/avatar_123.jpg' - - // 鍙繚瀛樻湰鍦拌矾寰勶紝涓嶇珛鍗充笂浼� - mockPageData.localAvatarPath = mockTempFilePath - mockPageData.errors.avatar = false - - console.log('鉁� 澶村儚閫夋嫨鎴愬姛锛屾湰鍦拌矾寰�:', mockTempFilePath) - console.log('馃挕 鎻愮ず锛氬ご鍍忓凡閫夋嫨锛屾彁浜ゆ椂灏嗚嚜鍔ㄤ笂浼�') - console.log('馃搳 褰撳墠鐘舵��:', { - localAvatarPath: mockPageData.localAvatarPath, - avatarUrl: mockPageData.formData.avatarUrl, - avatarMediaId: mockPageData.formData.avatarMediaId - }) - console.log('') -} - -// 妯℃嫙澶村儚鍒犻櫎鍑芥暟锛堜慨澶嶅悗鐨勭増鏈級 -function mockDeleteAvatar() { - console.log('馃棏锔� 鐢ㄦ埛鐐瑰嚮鍒犻櫎澶村儚...') - - const hasLocalAvatar = !!mockPageData.localAvatarPath - const hasUploadedAvatar = !!mockPageData.formData.avatarUrl - - if (hasLocalAvatar) { - console.log('馃摫 鍒犻櫎鏈湴閫夋嫨鐨勫ご鍍�') - mockPageData.localAvatarPath = '' - console.log('鉁� 鏈湴澶村儚宸插垹闄�') - } else if (hasUploadedAvatar) { - console.log('鈽侊笍 鍒犻櫎鏈嶅姟鍣ㄤ笂鐨勫ご鍍�') - mockPageData.formData.avatarUrl = '' - mockPageData.formData.avatarMediaId = '' - console.log('鉁� 鏈嶅姟鍣ㄥご鍍忓凡鍒犻櫎') - } - - console.log('馃搳 鍒犻櫎鍚庣姸鎬�:', { - localAvatarPath: mockPageData.localAvatarPath, - avatarUrl: mockPageData.formData.avatarUrl, - avatarMediaId: mockPageData.formData.avatarMediaId - }) - console.log('') -} - -// 妯℃嫙澶村儚楠岃瘉鍑芥暟锛堜慨澶嶅悗鐨勭増鏈級 -function mockValidateAvatar(requireAvatar = true) { - console.log('馃攳 楠岃瘉澶村儚...') - - if (requireAvatar) { - const hasAvatar = mockPageData.localAvatarPath || - (mockPageData.formData.avatarUrl && mockPageData.formData.avatarMediaId) - - if (!hasAvatar) { - mockPageData.errors.avatar = '璇烽�夋嫨澶村儚' - console.log('鉂� 楠岃瘉澶辫触锛氳閫夋嫨澶村儚') - return false - } - } - - console.log('鉁� 澶村儚楠岃瘉閫氳繃') - return true -} - -// 妯℃嫙鎻愪氦鍓嶄笂浼犲ご鍍忓嚱鏁帮紙鏂板鐨勫姛鑳斤級 -async function mockUploadAvatarBeforeSubmit() { - if (!mockPageData.localAvatarPath) { - console.log('馃挕 鏃犻渶涓婁紶澶村儚锛堟病鏈夋湰鍦伴�夋嫨鐨勫ご鍍忥級') - return - } - - console.log('鈽侊笍 寮�濮嬩笂浼犲ご鍍忓埌鏈嶅姟鍣�...') - console.log('馃搧 鏈湴鏂囦欢璺緞:', mockPageData.localAvatarPath) - - // 妯℃嫙涓婁紶杩涘害 - mockPageData.avatarUploading = true - for (let progress = 0; progress <= 100; progress += 25) { - mockPageData.avatarUploadProgress = progress - console.log(`馃搱 涓婁紶杩涘害: ${progress}%`) - await new Promise(resolve => setTimeout(resolve, 200)) // 妯℃嫙寤惰繜 - } - - // 妯℃嫙涓婁紶鎴愬姛 - const mockUploadResult = { - url: 'https://example.com/avatars/avatar_123.jpg', - key: 'avatars/avatar_123.jpg' - } - - mockPageData.formData.avatarUrl = mockUploadResult.url - mockPageData.formData.avatarMediaId = mockUploadResult.key - mockPageData.localAvatarPath = '' // 娓呯┖鏈湴璺緞 - mockPageData.avatarUploading = false - mockPageData.avatarUploadProgress = 0 - - console.log('鉁� 澶村儚涓婁紶鎴愬姛!') - console.log('馃敆 澶村儚URL:', mockUploadResult.url) - console.log('馃攽 Media ID:', mockUploadResult.key) - console.log('') -} - -// 妯℃嫙琛ㄥ崟鎻愪氦鍑芥暟锛堜慨澶嶅悗鐨勭増鏈級 -async function mockSubmitForm() { - console.log('馃摑 寮�濮嬫彁浜よ〃鍗�...') - - // 1. 楠岃瘉琛ㄥ崟锛堝寘鎷ご鍍忥級 - if (!mockValidateAvatar(true)) { - console.log('鉂� 琛ㄥ崟楠岃瘉澶辫触锛屽仠姝㈡彁浜�') - return false - } - - // 2. 濡傛灉鏈夋湰鍦板ご鍍忥紝鍏堜笂浼犲ご鍍� - await mockUploadAvatarBeforeSubmit() - - // 3. 鍑嗗鎻愪氦鏁版嵁 - const submitData = { - playerInfo: { - avatarMediaId: mockPageData.formData.avatarMediaId - } - // ... 鍏朵粬琛ㄥ崟鏁版嵁 - } - - console.log('馃摛 鎻愪氦鏁版嵁:', submitData) - console.log('鉁� 琛ㄥ崟鎻愪氦鎴愬姛!') - return true -} - -// 杩愯娴嬭瘯 -async function runTests() { - console.log('='.repeat(60)) - console.log('娴嬭瘯鍦烘櫙 1: 閫夋嫨澶村儚 -> 鎻愪氦') - console.log('='.repeat(60)) - - // 閲嶇疆鐘舵�� - mockPageData.localAvatarPath = '' - mockPageData.formData.avatarUrl = '' - mockPageData.formData.avatarMediaId = '' - - mockChooseAvatar() - await mockSubmitForm() - - console.log('\n' + '='.repeat(60)) - console.log('娴嬭瘯鍦烘櫙 2: 閫夋嫨澶村儚 -> 鍒犻櫎 -> 閲嶆柊閫夋嫨 -> 鎻愪氦') - console.log('='.repeat(60)) - - // 閲嶇疆鐘舵�� - mockPageData.localAvatarPath = '' - mockPageData.formData.avatarUrl = '' - mockPageData.formData.avatarMediaId = '' - - mockChooseAvatar() - mockDeleteAvatar() - mockChooseAvatar() - await mockSubmitForm() - - console.log('\n' + '='.repeat(60)) - console.log('娴嬭瘯鍦烘櫙 3: 鏈�夋嫨澶村儚鐩存帴鎻愪氦锛堝簲璇ュけ璐ワ級') - console.log('='.repeat(60)) - - // 閲嶇疆鐘舵�� - mockPageData.localAvatarPath = '' - mockPageData.formData.avatarUrl = '' - mockPageData.formData.avatarMediaId = '' - - await mockSubmitForm() - - console.log('\n' + '='.repeat(60)) - console.log('馃帀 鎵�鏈夋祴璇曞畬鎴�!') - console.log('='.repeat(60)) - - console.log('\n馃搵 淇鎬荤粨:') - console.log('鉁� 1. 澶村儚閫夋嫨鏃朵笉鍐嶇珛鍗充笂浼狅紝鍙仛鏈湴棰勮') - console.log('鉁� 2. 鎻愪氦琛ㄥ崟鏃舵墠涓婁紶澶村儚鍒版湇鍔″櫒') - console.log('鉁� 3. 鏀寔鍒犻櫎鏈湴閫夋嫨鐨勫ご鍍�') - console.log('鉁� 4. 琛ㄥ崟楠岃瘉鏀寔鏈湴閫夋嫨鐨勫ご鍍�') - console.log('鉁� 5. 涓婁紶杩涘害鏄剧ず姝e父') -} - -// 杩愯娴嬭瘯 -runTests().catch(console.error) \ No newline at end of file diff --git a/test_complete_phone_flow.js b/test_complete_phone_flow.js deleted file mode 100644 index 4c7d9cb..0000000 --- a/test_complete_phone_flow.js +++ /dev/null @@ -1,157 +0,0 @@ -const axios = require('axios'); - -// 缁煎悎娴嬭瘯鎵嬫満鍙疯幏鍙栨祦绋� -async function testCompletePhoneFlow() { - console.log('馃攳 缁煎悎娴嬭瘯鎵嬫満鍙疯幏鍙栨祦绋�'); - console.log('='.repeat(60)); - - const backendUrl = 'http://localhost:8080/api/graphql'; - const frontendUrl = 'http://localhost:3000'; - - // 1. 妫�鏌ュ悗绔湇鍔$姸鎬� - console.log('\n1锔忊儯 妫�鏌ュ悗绔湇鍔$姸鎬�'); - try { - const healthCheck = await axios.post(backendUrl, { - query: ` - query { - __schema { - queryType { - name - } - } - } - ` - }, { - headers: { 'Content-Type': 'application/json' }, - timeout: 5000 - }); - - if (healthCheck.status === 200) { - console.log('鉁� 鍚庣鏈嶅姟姝e父杩愯 (绔彛8080)'); - } - } catch (error) { - console.error('鉂� 鍚庣鏈嶅姟杩炴帴澶辫触:', error.message); - return; - } - - // 2. 妫�鏌ュ墠绔湇鍔$姸鎬� - console.log('\n2锔忊儯 妫�鏌ュ墠绔湇鍔$姸鎬�'); - try { - const frontendCheck = await axios.get(frontendUrl, { timeout: 5000 }); - if (frontendCheck.status === 200) { - console.log('鉁� 鍓嶇鏈嶅姟姝e父杩愯 (绔彛3000)'); - } - } catch (error) { - console.log('鈿狅笍 鍓嶇鏈嶅姟鍙兘鏈惎鍔ㄦ垨绔彛涓嶅悓'); - } - - // 3. 楠岃瘉鏂扮増API鍔熻兘 - console.log('\n3锔忊儯 楠岃瘉鏂扮増鎵嬫満鍙疯幏鍙朅PI'); - try { - const newApiTest = await axios.post(backendUrl, { - query: ` - mutation GetPhoneNumberByCode($code: String!) { - getPhoneNumberByCode(code: $code) { - phoneNumber - purePhoneNumber - countryCode - } - } - `, - variables: { code: "test_code_123" } - }, { - headers: { 'Content-Type': 'application/json' } - }); - - if (newApiTest.data.errors) { - console.log('鉁� 鏂扮増API鎺ュ彛姝e父锛堥鏈熼敊璇紝鍥犱负浣跨敤娴嬭瘯code锛�'); - console.log(' 閿欒淇℃伅:', newApiTest.data.errors[0].message.substring(0, 50) + '...'); - } - } catch (error) { - console.error('鉂� 鏂扮増API娴嬭瘯澶辫触:', error.message); - } - - // 4. 楠岃瘉鏃х増API鍔熻兘 - console.log('\n4锔忊儯 楠岃瘉鏃х増鎵嬫満鍙疯幏鍙朅PI'); - try { - const oldApiTest = await axios.post(backendUrl, { - query: ` - mutation DecryptPhoneNumber($encryptedData: String!, $iv: String!, $sessionKey: String!) { - decryptPhoneNumber(encryptedData: $encryptedData, iv: $iv, sessionKey: $sessionKey) { - phoneNumber - purePhoneNumber - countryCode - } - } - `, - variables: { - encryptedData: "test_encrypted", - iv: "test_iv", - sessionKey: "test_session_key" - } - }, { - headers: { 'Content-Type': 'application/json' } - }); - - if (oldApiTest.data.errors) { - console.log('鉁� 鏃х増API鎺ュ彛姝e父锛堥鏈熼敊璇紝鍥犱负浣跨敤娴嬭瘯鏁版嵁锛�'); - console.log(' 閿欒淇℃伅:', oldApiTest.data.errors[0].message.substring(0, 50) + '...'); - } - } catch (error) { - console.error('鉂� 鏃х増API娴嬭瘯澶辫触:', error.message); - } - - // 5. 妫�鏌ュ井淇¢厤缃� - console.log('\n5锔忊儯 妫�鏌ュ井淇PI閰嶇疆'); - console.log('鉁� 宸查厤缃柊鐗堟墜鏈哄彿鑾峰彇API绔偣'); - console.log(' URL: https://api.weixin.qq.com/wxa/business/getuserphonenumber'); - console.log('鉁� 宸查厤缃產ccess_token鑾峰彇绔偣'); - console.log('鉁� 宸查厤缃甤ode2session绔偣锛堝悜鍚庡吋瀹癸級'); - - // 6. 鍓嶇閫昏緫楠岃瘉 - console.log('\n6锔忊儯 鍓嶇閫昏緫楠岃瘉'); - console.log('鉁� 宸蹭慨澶峳egistration.js涓殑onGetPhoneNumber鏂规硶'); - console.log('鉁� 浼樺厛浣跨敤鏂扮増API (getPhoneNumberByCode)'); - console.log('鉁� 澶辫触鏃惰嚜鍔ㄥ洖閫�鍒版棫鐗圓PI (decryptPhoneNumber)'); - console.log('鉁� 鏀寔鎵�鏈夊井淇″皬绋嬪簭鍩虹搴撶増鏈�'); - - // 7. 鍏煎鎬ф鏌� - console.log('\n7锔忊儯 鍏煎鎬ф鏌�'); - console.log('鉁� 鍩虹搴� < 2.21.2: 浣跨敤鏃х増API (encryptedData + sessionKey)'); - console.log('鉁� 鍩虹搴� >= 2.21.2: 浼樺厛浣跨敤鏂扮増API (code)锛屽け璐ユ椂鍥為��'); - console.log('鉁� 褰撳墠椤圭洰鍩虹搴撶増鏈�: 3.10.1 (鏀寔鏂扮増API)'); - - // 8. 娴嬭瘯鍦烘櫙鎬荤粨 - console.log('\n8锔忊儯 娴嬭瘯鍦烘櫙鎬荤粨'); - console.log('馃摫 鍦烘櫙1: 寰俊杩斿洖code 鈫� 璋冪敤鏂扮増API'); - console.log('馃摫 鍦烘櫙2: 鏂扮増API澶辫触 鈫� 鑷姩鍥為��鍒版棫鐗圓PI'); - console.log('馃摫 鍦烘櫙3: 鏃燾ode浣嗘湁encryptedData 鈫� 鐩存帴浣跨敤鏃х増API'); - console.log('馃摫 鍦烘櫙4: 鎵�鏈夊弬鏁扮己澶� 鈫� 鏄剧ず閿欒鎻愮ず'); - - // 9. 閮ㄧ讲寤鸿 - console.log('\n9锔忊儯 閮ㄧ讲寤鸿'); - console.log('馃殌 寤鸿娴嬭瘯娴佺▼:'); - console.log(' 1. 鍦ㄥ井淇″紑鍙戣�呭伐鍏蜂腑娴嬭瘯灏忕▼搴�'); - console.log(' 2. 浣跨敤鐪熷疄寰俊璐﹀彿娴嬭瘯鎵嬫満鍙锋巿鏉�'); - console.log(' 3. 楠岃瘉鏂扮増API鍜屾棫鐗圓PI閮借兘姝e父宸ヤ綔'); - console.log(' 4. 妫�鏌ヤ笉鍚屽熀纭�搴撶増鏈殑鍏煎鎬�'); - - console.log('\n馃幆 鍏抽敭鏀硅繘鐐�:'); - console.log('鉁� 瑙e喅浜嗗熀纭�搴撶増鏈笉鍖归厤闂'); - console.log('鉁� 娣诲姞浜嗘柊鐗堝井淇℃墜鏈哄彿鑾峰彇API鏀寔'); - console.log('鉁� 淇濇寔浜嗗悜鍚庡吋瀹规��'); - console.log('鉁� 浼樺寲浜嗛敊璇鐞嗗拰鐢ㄦ埛浣撻獙'); - console.log('鉁� 娣诲姞浜嗚缁嗙殑鏃ュ織璁板綍渚夸簬璋冭瘯'); -} - -// 杩愯缁煎悎娴嬭瘯 -testCompletePhoneFlow().then(() => { - console.log('\n馃帀 缁煎悎娴嬭瘯瀹屾垚锛�'); - console.log('\n馃搵 涓嬩竴姝ユ搷浣滃缓璁�:'); - console.log('1. 鍦ㄥ井淇″紑鍙戣�呭伐鍏蜂腑鎵撳紑灏忕▼搴忛」鐩�'); - console.log('2. 杩涘叆娉ㄥ唽椤甸潰娴嬭瘯鎵嬫満鍙疯幏鍙栧姛鑳�'); - console.log('3. 瑙傚療鎺у埗鍙版棩蹇楃‘璁や娇鐢ㄧ殑API鐗堟湰'); - console.log('4. 楠岃瘉鎵嬫満鍙疯兘澶熸纭幏鍙栧拰鏄剧ず'); -}).catch(error => { - console.error('馃挜 缁煎悎娴嬭瘯寮傚父:', error); -}); \ No newline at end of file diff --git a/test_direct_activity.js b/test_direct_activity.js deleted file mode 100644 index 754bab2..0000000 --- a/test_direct_activity.js +++ /dev/null @@ -1,57 +0,0 @@ -const axios = require('axios'); - -const GRAPHQL_URL = 'http://localhost:8080/api/graphql'; - -async function testDirectActivity() { - try { - console.log('馃攳 鏌ヨ娲诲姩鍒楄〃...'); - - const query = ` - query { - allActivities { - id - name - description - pid - path - state - } - } - `; - - const response = await axios.post(GRAPHQL_URL, { - query: query - }, { - headers: { - 'Content-Type': 'application/json' - } - }); - - if (response.data.errors) { - console.error('鉂� GraphQL閿欒:', response.data.errors); - return; - } - - console.log('鉁� 鏌ヨ鎴愬姛!'); - console.log('鎵�鏈夋椿鍔�:', JSON.stringify(response.data.data.allActivities, null, 2)); - - // 鏌ユ壘娲诲姩55鎴栧叾浠栧彲鐢ㄦ椿鍔� - const activities = response.data.data.allActivities; - const activity55 = activities.find(a => a.id === "55"); - if (activity55) { - console.log('\n鎵惧埌娲诲姩55:', activity55); - } else { - console.log('\n鏈壘鍒版椿鍔�55锛屽彲鐢ㄦ椿鍔�:'); - activities.forEach(a => console.log(`- ID: ${a.id}, 鍚嶇О: ${a.name}, PID: ${a.pid}`)); - } - - } catch (error) { - console.error('鉂� 璇锋眰澶辫触:', error.message); - if (error.response) { - console.error('鍝嶅簲鐘舵��:', error.response.status); - console.error('鍝嶅簲鏁版嵁:', error.response.data); - } - } -} - -testDirectActivity(); \ No newline at end of file diff --git a/test_friendly_errors.js b/test_friendly_errors.js deleted file mode 100644 index 8485a3b..0000000 --- a/test_friendly_errors.js +++ /dev/null @@ -1,106 +0,0 @@ -const axios = require('axios'); - -async function testFriendlyErrors() { - console.log('馃攳 娴嬭瘯鍙嬪ソ閿欒淇℃伅'); - console.log('='.repeat(50)); - - const graphqlUrl = 'http://localhost:8080/api/graphql'; - - // 娴嬭瘯1: 鏂扮増API - 鏃犳晥code - console.log('1锔忊儯 娴嬭瘯鏂扮増API - 鏃犳晥code'); - try { - const query1 = ` - mutation { - getPhoneNumberByCode(code: "invalid_test_code_12345") { - phoneNumber - purePhoneNumber - countryCode - } - } - `; - - const response1 = await axios.post(graphqlUrl, { query: query1 }); - - if (response1.data.errors) { - console.log('閿欒淇℃伅:', response1.data.errors[0].message); - - // 妫�鏌ユ槸鍚﹀寘鍚弸濂界殑閿欒淇℃伅 - const errorMsg = response1.data.errors[0].message; - if (errorMsg.includes('鎺堟潈鐮佸凡杩囨湡鎴栨棤鏁�')) { - console.log('鉁� 鍙嬪ソ閿欒淇℃伅姝e父宸ヤ綔'); - } else if (errorMsg.includes('RuntimeException')) { - console.log('鈿狅笍 浠嶆樉绀烘妧鏈敊璇俊鎭�:', errorMsg); - } else { - console.log('馃摑 閿欒淇℃伅:', errorMsg); - } - } - } catch (error) { - console.log('鉂� 璇锋眰寮傚父:', error.message); - } - - // 娴嬭瘯2: 鏃х増API - 鏃犳晥鏁版嵁 - console.log('\n2锔忊儯 娴嬭瘯鏃х増API - 鏃犳晥鏁版嵁'); - try { - const query2 = ` - mutation { - decryptPhoneNumber( - encryptedData: "invalid_data" - iv: "invalid_iv" - sessionKey: "invalid_session_key" - ) { - phoneNumber - purePhoneNumber - countryCode - } - } - `; - - const response2 = await axios.post(graphqlUrl, { query: query2 }); - - if (response2.data.errors) { - console.log('閿欒淇℃伅:', response2.data.errors[0].message); - - // 妫�鏌ユ槸鍚﹀寘鍚弸濂界殑閿欒淇℃伅 - const errorMsg = response2.data.errors[0].message; - if (errorMsg.includes('鎺堟潈鏁版嵁鏍煎紡閿欒') || errorMsg.includes('鎺堟潈鏁版嵁宸茶繃鏈�')) { - console.log('鉁� 鍙嬪ソ閿欒淇℃伅姝e父宸ヤ綔'); - } else if (errorMsg.includes('RuntimeException')) { - console.log('鈿狅笍 浠嶆樉绀烘妧鏈敊璇俊鎭�:', errorMsg); - } else { - console.log('馃摑 閿欒淇℃伅:', errorMsg); - } - } - } catch (error) { - console.log('鉂� 璇锋眰寮傚父:', error.message); - } - - // 娴嬭瘯3: 绌篶ode鍙傛暟 - console.log('\n3锔忊儯 娴嬭瘯绌篶ode鍙傛暟'); - try { - const query3 = ` - mutation { - getPhoneNumberByCode(code: "") { - phoneNumber - purePhoneNumber - countryCode - } - } - `; - - const response3 = await axios.post(graphqlUrl, { query: query3 }); - - if (response3.data.errors) { - console.log('閿欒淇℃伅:', response3.data.errors[0].message); - } - } catch (error) { - console.log('鉂� 璇锋眰寮傚父:', error.message); - } - - console.log('\n馃敡 璇婃柇缁撴灉:'); - console.log('濡傛灉浠嶇劧鏄剧ず"RuntimeException"锛屽彲鑳界殑鍘熷洜锛�'); - console.log('1. GraphQL寮傚父澶勭悊鍣ㄨ鐩栦簡鎴戜滑鐨勫弸濂介敊璇俊鎭�'); - console.log('2. 闇�瑕佷慨鏀笹raphQL閰嶇疆浠ヤ紶閫掑師濮嬮敊璇俊鎭�'); - console.log('3. 寮傚父鍦ㄤ紶閫掕繃绋嬩腑琚寘瑁呬簡'); -} - -testFriendlyErrors().catch(console.error); \ No newline at end of file diff --git a/test_frontend_backend_integration.js b/test_frontend_backend_integration.js deleted file mode 100644 index 5de5390..0000000 --- a/test_frontend_backend_integration.js +++ /dev/null @@ -1,128 +0,0 @@ -/** - * 鍓嶇鍚庣闆嗘垚娴嬭瘯 - * 楠岃瘉灏忕▼搴忓墠绔笌鍚庣API鐨勫畬鏁撮泦鎴� - */ - -const fs = require('fs'); -const path = require('path'); - -console.log('=== 鍓嶇鍚庣闆嗘垚娴嬭瘯 ===\n'); - -// 1. 妫�鏌ュ墠绔枃浠� -console.log('1. 妫�鏌ュ墠绔枃浠剁粨鏋�...'); -const frontendFiles = [ - 'wx/pages/registration/registration.wxml', - 'wx/pages/registration/registration.wxss', - 'wx/pages/registration/registration.js' -]; - -frontendFiles.forEach(file => { - const filePath = path.join(__dirname, file); - if (fs.existsSync(filePath)) { - console.log(`鉁� ${file} - 瀛樺湪`); - } else { - console.log(`鉂� ${file} - 涓嶅瓨鍦╜); - } -}); - -// 2. 妫�鏌ュ墠绔姛鑳藉疄鐜� -console.log('\n2. 妫�鏌ュ墠绔姛鑳藉疄鐜�...'); -const jsFilePath = path.join(__dirname, 'wx/pages/registration/registration.js'); -if (fs.existsSync(jsFilePath)) { - const jsContent = fs.readFileSync(jsFilePath, 'utf8'); - - const features = [ - { name: '澶村儚涓婁紶', pattern: /onChooseAvatar|uploadAvatar/ }, - { name: '闄勪欢涓婁紶', pattern: /onChooseAttachment|uploadAttachment/ }, - { name: '鏂囦欢楠岃瘉', pattern: /validateAttachment/ }, - { name: '鏂囦欢鍒犻櫎', pattern: /onDeleteAttachment/ }, - { name: '杩涘害鏄剧ず', pattern: /uploadProgress/ }, - { name: 'GraphQL鎻愪氦', pattern: /submitActivityRegistration/ }, - { name: '闄勪欢ID浼犻��', pattern: /attachmentMediaIds/ } - ]; - - features.forEach(feature => { - if (feature.pattern.test(jsContent)) { - console.log(`鉁� ${feature.name} - 宸插疄鐜癭); - } else { - console.log(`鉂� ${feature.name} - 鏈疄鐜癭); - } - }); -} - -// 3. 妫�鏌ュ悗绔疓raphQL Schema -console.log('\n3. 妫�鏌ュ悗绔疓raphQL Schema...'); -const schemaPath = path.join(__dirname, 'backend/src/main/resources/graphql/player.graphqls'); -if (fs.existsSync(schemaPath)) { - const schemaContent = fs.readFileSync(schemaPath, 'utf8'); - - const schemaFeatures = [ - { name: 'submitActivityRegistration mutation', pattern: /submitActivityRegistration/ }, - { name: 'ActivityRegistrationInput', pattern: /input ActivityRegistrationInput/ }, - { name: 'attachmentMediaIds瀛楁', pattern: /attachmentMediaIds:\s*\[String!\]/ }, - { name: 'avatarMediaId瀛楁', pattern: /avatarMediaId:\s*String/ }, - { name: 'ActivityRegistrationResponse', pattern: /type ActivityRegistrationResponse/ } - ]; - - schemaFeatures.forEach(feature => { - if (feature.pattern.test(schemaContent)) { - console.log(`鉁� ${feature.name} - 宸插畾涔塦); - } else { - console.log(`鉂� ${feature.name} - 鏈畾涔塦); - } - }); -} - -// 4. 妫�鏌ユ暟鎹祦 -console.log('\n4. 鏁版嵁娴侀獙璇�...'); -console.log('鍓嶇 鈫� 鍚庣鏁版嵁娴�:'); -console.log(' 1. 鐢ㄦ埛閫夋嫨澶村儚 鈫� onChooseAvatar()'); -console.log(' 2. 涓婁紶澶村儚鍒癈OS 鈫� uploadAvatar()'); -console.log(' 3. 鑾峰彇澶村儚mediaId 鈫� 瀛樺偍鍒癴ormData.avatarMediaId'); -console.log(' 4. 鐢ㄦ埛閫夋嫨闄勪欢 鈫� onChooseAttachment()'); -console.log(' 5. 涓婁紶闄勪欢鍒癈OS 鈫� uploadAttachment()'); -console.log(' 6. 鑾峰彇闄勪欢mediaIds 鈫� 瀛樺偍鍒癮ttachments鏁扮粍'); -console.log(' 7. 鎻愪氦琛ㄥ崟 鈫� submitRegistration()'); -console.log(' 8. 鏋勫缓GraphQL璇锋眰 鈫� 鍖呭惈avatarMediaId鍜宎ttachmentMediaIds'); -console.log(' 9. 鍙戦�佸埌鍚庣 鈫� /api/graphql'); -console.log(' 10. 鍚庣澶勭悊 鈫� 瀛樺偍鍒版暟鎹簱'); - -// 5. 鏀寔鐨勬枃浠剁被鍨� -console.log('\n5. 鏀寔鐨勬枃浠剁被鍨�...'); -if (fs.existsSync(jsFilePath)) { - const jsContent = fs.readFileSync(jsFilePath, 'utf8'); - const fileTypeMatch = jsContent.match(/fileTypeConfig:\s*{[\s\S]*?}/); - if (fileTypeMatch) { - console.log('鉁� 鏂囦欢绫诲瀷閰嶇疆宸插畾涔�'); - console.log('鏀寔鐨勭被鍨�: 鍥剧墖銆佽棰戙�丳DF銆乄ord銆丒xcel銆丳PT銆佹枃鏈�'); - } -} - -// 6. 鏁版嵁搴撹〃缁撴瀯 -console.log('\n6. 棰勬湡鏁版嵁搴撹〃缁撴瀯...'); -console.log('t_user: 鐢ㄦ埛鍩烘湰淇℃伅'); -console.log(' - id, phone, name, gender, birth_date, education, introduction'); -console.log('t_player: 閫夋墜淇℃伅'); -console.log(' - id, user_id, avatar_media_id, description'); -console.log('t_activity_player: 鎶ュ悕璁板綍'); -console.log(' - id, activity_id, player_id, region_id, project_name, description'); -console.log('t_media: 濯掍綋鏂囦欢'); -console.log(' - id, file_name, file_url, file_type, file_size, related_type, related_id'); - -// 7. 娴嬭瘯寤鸿 -console.log('\n7. 娴嬭瘯寤鸿...'); -console.log('鎵嬪姩娴嬭瘯姝ラ:'); -console.log(' 1. 鍦ㄥ井淇″紑鍙戣�呭伐鍏蜂腑鎵撳紑灏忕▼搴�'); -console.log(' 2. 杩涘叆鎶ュ悕椤甸潰'); -console.log(' 3. 涓婁紶澶村儚锛岄獙璇侀瑙堝拰杩涘害'); -console.log(' 4. 涓婁紶澶氫釜闄勪欢锛岄獙璇佺被鍨嬮檺鍒跺拰澶у皬闄愬埗'); -console.log(' 5. 濉啓瀹屾暣琛ㄥ崟淇℃伅'); -console.log(' 6. 鎻愪氦鎶ュ悕锛屾鏌ョ綉缁滆姹�'); -console.log(' 7. 楠岃瘉鍚庣鏃ュ織鍜屾暟鎹簱璁板綍'); - -console.log('\n=== 闆嗘垚娴嬭瘯瀹屾垚 ==='); -console.log('鉁� 鍓嶇闄勪欢涓婁紶鍔熻兘宸插畬鏁村疄鐜�'); -console.log('鉁� 鍚庣GraphQL Schema宸叉洿鏂版敮鎸侀檮浠�'); -console.log('鉁� 鏁版嵁娴佽璁″悎鐞嗭紝鏀寔瀹屾暣鐨勬姤鍚嶆祦绋�'); -console.log('鉁� 鏂囦欢绫诲瀷鍜屽ぇ灏忛檺鍒跺凡閰嶇疆'); -console.log('鉁� 閿欒澶勭悊鍜岀敤鎴峰弽棣堝凡瀹炵幇'); \ No newline at end of file diff --git a/test_full_registration_flow.js b/test_full_registration_flow.js deleted file mode 100644 index 39f9b7d..0000000 --- a/test_full_registration_flow.js +++ /dev/null @@ -1,286 +0,0 @@ -// 娴嬭瘯瀹屾暣鐨勬姤鍚嶆祦绋嬶紝鍖呮嫭澶村儚鍜岄檮浠朵笂浼� -const fs = require('fs'); -const path = require('path'); - -console.log('=== 瀹屾暣鎶ュ悕娴佺▼娴嬭瘯 ===\n'); - -// 妯℃嫙瀹屾暣鐨勬姤鍚嶆暟鎹� -const fullRegistrationData = { - // 娲诲姩淇℃伅 - activityId: 1, - - // 鐢ㄦ埛鍩烘湰淇℃伅 - playerInfo: { - name: "鏉庡皬鏄�", - phone: "13912345678", - gender: 1, // 1-鐢�, 0-濂� - birthDate: "1995-08-20", - education: "鏈", - introduction: "鎴戞槸涓�鍚嶅叏鏍堝紑鍙戝伐绋嬪笀锛屾嫢鏈�5骞寸殑Web寮�鍙戠粡楠岋紝鐔熸倝React銆丯ode.js銆丳ython绛夋妧鏈爤銆傜儹鐖辨妧鏈垱鏂帮紝鍠勪簬鍥㈤槦鍗忎綔锛屽笇鏈涢�氳繃杩欐娲诲姩瀛︿範鏇村鍓嶆部鎶�鏈��", - avatarMediaId: "avatar_user_20240101_001.jpg" - }, - - // 鍦板尯淇℃伅 - regionId: 1, - - // 椤圭洰淇℃伅 - projectName: "鏅鸿兘鐜繚鐩戞祴绯荤粺", - description: "鍩轰簬鐗╄仈缃戝拰浜哄伐鏅鸿兘鎶�鏈殑鐜繚鐩戞祴瑙e喅鏂规锛岃兘澶熷疄鏃剁洃娴嬬┖姘旇川閲忋�佹按璐ㄣ�佸櫔闊崇瓑鐜鎸囨爣锛屽苟鎻愪緵鏁版嵁鍒嗘瀽鍜岄璀﹀姛鑳姐��", - - // 闄勪欢淇℃伅 - attachmentMediaIds: [ - "attachment_project_demo_video.mp4", // 椤圭洰婕旂ず瑙嗛 - "attachment_technical_doc.pdf", // 鎶�鏈枃妗� - "attachment_system_architecture.png", // 绯荤粺鏋舵瀯鍥� - "attachment_ui_design.jpg", // UI璁捐鍥� - "attachment_business_plan.docx" // 鍟嗕笟璁″垝涔� - ] -}; - -console.log('1. 妯℃嫙鐢ㄦ埛濉啓琛ㄥ崟鏁版嵁...'); -console.log('鐢ㄦ埛淇℃伅:'); -console.log(` 濮撳悕: ${fullRegistrationData.playerInfo.name}`); -console.log(` 鎵嬫満: ${fullRegistrationData.playerInfo.phone}`); -console.log(` 鎬у埆: ${fullRegistrationData.playerInfo.gender === 1 ? '鐢�' : '濂�'}`); -console.log(` 鐢熸棩: ${fullRegistrationData.playerInfo.birthDate}`); -console.log(` 瀛﹀巻: ${fullRegistrationData.playerInfo.education}`); -console.log(` 澶村儚: ${fullRegistrationData.playerInfo.avatarMediaId}`); - -console.log('\n椤圭洰淇℃伅:'); -console.log(` 椤圭洰鍚嶇О: ${fullRegistrationData.projectName}`); -console.log(` 椤圭洰鎻忚堪: ${fullRegistrationData.description.substring(0, 50)}...`); - -console.log('\n闄勪欢淇℃伅:'); -fullRegistrationData.attachmentMediaIds.forEach((mediaId, index) => { - const fileName = mediaId.split('_').slice(1).join('_'); - let fileType = '鏈煡'; - if (mediaId.includes('video')) fileType = '瑙嗛'; - else if (mediaId.includes('pdf')) fileType = 'PDF'; - else if (mediaId.includes('png') || mediaId.includes('jpg')) fileType = '鍥剧墖'; - else if (mediaId.includes('docx')) fileType = 'Word鏂囨。'; - - console.log(` ${index + 1}. ${fileName} (${fileType})`); -}); - -console.log('\n2. 鏋勫缓GraphQL Mutation...'); - -const mutation = ` -mutation SubmitActivityRegistration($input: ActivityRegistrationInput!) { - submitActivityRegistration(input: $input) { - success - message - registrationId - } -} -`; - -console.log('GraphQL Mutation:'); -console.log(mutation); - -console.log('\n3. 鍑嗗璇锋眰鏁版嵁...'); -const requestData = { - input: fullRegistrationData -}; - -console.log('璇锋眰鏁版嵁:'); -console.log(JSON.stringify(requestData, null, 2)); - -console.log('\n4. 妯℃嫙鏁版嵁搴撳瓨鍌ㄨ繃绋�...'); - -// 妯℃嫙t_user琛ㄦ暟鎹� -const userData = { - id: 1001, - name: fullRegistrationData.playerInfo.name, - phone: fullRegistrationData.playerInfo.phone, - gender: fullRegistrationData.playerInfo.gender, - birth_date: fullRegistrationData.playerInfo.birthDate, - education: fullRegistrationData.playerInfo.education, - avatar_media_id: fullRegistrationData.playerInfo.avatarMediaId, - created_at: new Date().toISOString() -}; - -console.log('t_user琛ㄦ暟鎹�:'); -console.log(JSON.stringify(userData, null, 2)); - -// 妯℃嫙t_player琛ㄦ暟鎹� -const playerData = { - id: 2001, - user_id: userData.id, - introduction: fullRegistrationData.playerInfo.introduction, - created_at: new Date().toISOString() -}; - -console.log('\nt_player琛ㄦ暟鎹�:'); -console.log(JSON.stringify(playerData, null, 2)); - -// 妯℃嫙t_activity_player琛ㄦ暟鎹� -const activityPlayerData = { - id: 3001, - activity_id: fullRegistrationData.activityId, - player_id: playerData.id, - region_id: fullRegistrationData.regionId, - project_name: fullRegistrationData.projectName, - description: fullRegistrationData.description, - status: 'pending', - created_at: new Date().toISOString() -}; - -console.log('\nt_activity_player琛ㄦ暟鎹�:'); -console.log(JSON.stringify(activityPlayerData, null, 2)); - -// 妯℃嫙t_media琛ㄦ暟鎹紙澶村儚锛� -const avatarMediaData = { - id: 4001, - media_id: fullRegistrationData.playerInfo.avatarMediaId, - file_name: 'avatar_user_20240101_001.jpg', - file_type: 'image/jpeg', - file_size: 256000, // 256KB - url: `https://cos.example.com/${fullRegistrationData.playerInfo.avatarMediaId}`, - related_type: 'user_avatar', - related_id: userData.id, - created_at: new Date().toISOString() -}; - -console.log('\nt_media琛ㄦ暟鎹紙澶村儚锛�:'); -console.log(JSON.stringify(avatarMediaData, null, 2)); - -// 妯℃嫙t_media琛ㄦ暟鎹紙闄勪欢锛� -console.log('\nt_media琛ㄦ暟鎹紙闄勪欢锛�:'); -fullRegistrationData.attachmentMediaIds.forEach((mediaId, index) => { - const attachmentMediaData = { - id: 4002 + index, - media_id: mediaId, - file_name: mediaId.split('_').slice(1).join('_'), - file_type: getFileType(mediaId), - file_size: getFileSize(mediaId), - url: `https://cos.example.com/${mediaId}`, - related_type: 'registration_attachment', - related_id: activityPlayerData.id, - created_at: new Date().toISOString() - }; - - console.log(`闄勪欢${index + 1}:`, JSON.stringify(attachmentMediaData, null, 2)); -}); - -function getFileType(mediaId) { - if (mediaId.includes('video')) return 'video/mp4'; - if (mediaId.includes('pdf')) return 'application/pdf'; - if (mediaId.includes('png')) return 'image/png'; - if (mediaId.includes('jpg')) return 'image/jpeg'; - if (mediaId.includes('docx')) return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; - return 'application/octet-stream'; -} - -function getFileSize(mediaId) { - if (mediaId.includes('video')) return 52428800; // 50MB - if (mediaId.includes('pdf')) return 2097152; // 2MB - if (mediaId.includes('png') || mediaId.includes('jpg')) return 1048576; // 1MB - if (mediaId.includes('docx')) return 524288; // 512KB - return 1024; // 1KB -} - -console.log('\n5. 楠岃瘉鏁版嵁瀹屾暣鎬�...'); - -const validationChecks = [ - { - name: '鐢ㄦ埛鍩烘湰淇℃伅', - check: userData.name && userData.phone && userData.gender !== undefined, - details: `濮撳悕: ${userData.name}, 鎵嬫満: ${userData.phone}, 鎬у埆: ${userData.gender}` - }, - { - name: '澶村儚淇℃伅', - check: userData.avatar_media_id && avatarMediaData.media_id, - details: `澶村儚MediaID: ${userData.avatar_media_id}` - }, - { - name: '涓汉浠嬬粛', - check: playerData.introduction && playerData.introduction.length > 0, - details: `浠嬬粛闀垮害: ${playerData.introduction.length}瀛楃` - }, - { - name: '椤圭洰淇℃伅', - check: activityPlayerData.project_name && activityPlayerData.description, - details: `椤圭洰: ${activityPlayerData.project_name}` - }, - { - name: '闄勪欢淇℃伅', - check: fullRegistrationData.attachmentMediaIds.length > 0, - details: `闄勪欢鏁伴噺: ${fullRegistrationData.attachmentMediaIds.length}涓猔 - }, - { - name: '鍏宠仈鍏崇郴', - check: playerData.user_id === userData.id && activityPlayerData.player_id === playerData.id, - details: `鐢ㄦ埛ID: ${userData.id} -> 閫夋墜ID: ${playerData.id} -> 鎶ュ悕ID: ${activityPlayerData.id}` - } -]; - -validationChecks.forEach(check => { - const status = check.check ? '鉁� 閫氳繃' : '鉂� 澶辫触'; - console.log(` ${status} ${check.name}: ${check.details}`); -}); - -console.log('\n6. 妯℃嫙鍚庣鍝嶅簲...'); - -const mockResponse = { - data: { - submitActivityRegistration: { - success: true, - message: "鎶ュ悕鎻愪氦鎴愬姛", - registrationId: activityPlayerData.id - } - } -}; - -console.log('鍚庣鍝嶅簲:'); -console.log(JSON.stringify(mockResponse, null, 2)); - -console.log('\n7. 鏁版嵁搴撴煡璇㈤獙璇�...'); - -const queries = [ - `SELECT * FROM t_user WHERE id = ${userData.id};`, - `SELECT * FROM t_player WHERE user_id = ${userData.id};`, - `SELECT * FROM t_activity_player WHERE player_id = ${playerData.id} AND activity_id = ${fullRegistrationData.activityId};`, - `SELECT * FROM t_media WHERE related_type = 'user_avatar' AND related_id = ${userData.id};`, - `SELECT * FROM t_media WHERE related_type = 'registration_attachment' AND related_id = ${activityPlayerData.id};` -]; - -console.log('楠岃瘉SQL鏌ヨ:'); -queries.forEach((query, index) => { - console.log(`${index + 1}. ${query}`); -}); - -console.log('\n=== 娴嬭瘯鎬荤粨 ==='); - -const summary = [ - '鉁� 鐢ㄦ埛鍩烘湰淇℃伅姝g‘瀛樺偍鍒皌_user琛�', - '鉁� 涓汉浠嬬粛淇℃伅姝g‘瀛樺偍鍒皌_player琛�', - '鉁� 鎶ュ悕淇℃伅姝g‘瀛樺偍鍒皌_activity_player琛�', - '鉁� 澶村儚鏂囦欢淇℃伅姝g‘瀛樺偍鍒皌_media琛�', - '鉁� 闄勪欢鏂囦欢淇℃伅姝g‘瀛樺偍鍒皌_media琛�', - '鉁� 鎵�鏈夎〃涔嬮棿鐨勫叧鑱斿叧绯绘纭缓绔�', - '鉁� GraphQL mutation姝g‘鏋勫缓', - '鉁� 鏁版嵁瀹屾暣鎬ч獙璇侀�氳繃' -]; - -summary.forEach(item => { - console.log(item); -}); - -console.log('\n馃帀 瀹屾暣鎶ュ悕娴佺▼娴嬭瘯鎴愬姛锛佹墍鏈夋暟鎹兘鑳芥纭瓨鍌ㄥ埌鏁版嵁搴撲腑銆�'); - -console.log('\n=== 涓嬩竴姝ユ祴璇曞缓璁� ==='); - -const nextSteps = [ - '1. 鍚姩鍚庣鏈嶅姟锛岀‘淇滸raphQL API姝e父杩愯', - '2. 鍦ㄥ井淇″紑鍙戣�呭伐鍏蜂腑鎵撳紑灏忕▼搴�', - '3. 浣跨敤鐪熷疄鐨勫浘鐗囨枃浠舵祴璇曞ご鍍忎笂浼�', - '4. 浣跨敤tmp鐩綍涓嬬殑娴嬭瘯鏂囦欢娴嬭瘯闄勪欢涓婁紶', - '5. 濉啓瀹屾暣鐨勬姤鍚嶈〃鍗曞苟鎻愪氦', - '6. 妫�鏌ュ悗绔棩蹇楃‘璁ゆ暟鎹鐞嗚繃绋�', - '7. 鏌ヨ鏁版嵁搴撻獙璇佹暟鎹瓨鍌ㄧ粨鏋�', - '8. 娴嬭瘯鍚勭寮傚父鎯呭喌鐨勫鐞�' -]; - -nextSteps.forEach(step => { - console.log(step); -}); \ No newline at end of file diff --git a/test_graphql_api.js b/test_graphql_api.js deleted file mode 100644 index b3ba324..0000000 --- a/test_graphql_api.js +++ /dev/null @@ -1,196 +0,0 @@ -// 娴嬭瘯GraphQL API - 鎶ュ悕鎺ュ彛 -const https = require('https'); -const http = require('http'); - -console.log('=== GraphQL API 娴嬭瘯 ===\n'); - -// GraphQL 鏌ヨ鍜屽彉鏇� -const queries = { - // 娴嬭瘯鍩虹杩炴帴 - healthCheck: { - query: ` - query { - __schema { - types { - name - } - } - } - ` - }, - - // 娴嬭瘯鎶ュ悕鎻愪氦 - submitRegistration: { - query: ` - mutation SubmitActivityRegistration($input: ActivityRegistrationInput!) { - submitActivityRegistration(input: $input) { - success - message - registrationId - } - } - `, - variables: { - input: { - activityId: 1, - playerInfo: { - name: "娴嬭瘯鐢ㄦ埛", - phone: "13912345678", - gender: 1, - birthDate: "1995-08-20", - education: "鏈", - introduction: "杩欐槸涓�涓祴璇曠敤鎴风殑涓汉浠嬬粛", - avatarMediaId: "test_avatar_001.jpg" - }, - regionId: 1, - projectName: "娴嬭瘯椤圭洰", - description: "杩欐槸涓�涓祴璇曢」鐩殑鎻忚堪", - attachmentMediaIds: [ - "test_attachment_001.pdf", - "test_attachment_002.jpg" - ] - } - } - } -}; - -// 娴嬭瘯閰嶇疆 -const testConfig = { - host: 'localhost', - port: 8080, - path: '/api/graphql', - method: 'POST', - headers: { - 'Content-Type': 'application/json', - 'Accept': 'application/json' - } -}; - -// 鎵цGraphQL璇锋眰 -function executeGraphQLRequest(testName, requestData) { - return new Promise((resolve, reject) => { - const postData = JSON.stringify(requestData); - - const options = { - ...testConfig, - headers: { - ...testConfig.headers, - 'Content-Length': Buffer.byteLength(postData) - } - }; - - console.log(`\n--- ${testName} ---`); - console.log(`璇锋眰鍦板潃: http://${options.host}:${options.port}${options.path}`); - console.log(`璇锋眰鏁版嵁:`, JSON.stringify(requestData, null, 2)); - - const req = http.request(options, (res) => { - let data = ''; - - res.on('data', (chunk) => { - data += chunk; - }); - - res.on('end', () => { - console.log(`鍝嶅簲鐘舵��: ${res.statusCode}`); - console.log(`鍝嶅簲澶�:`, res.headers); - - try { - const response = JSON.parse(data); - console.log(`鍝嶅簲鏁版嵁:`, JSON.stringify(response, null, 2)); - resolve({ statusCode: res.statusCode, data: response }); - } catch (error) { - console.log(`鍝嶅簲鍘熷鏁版嵁:`, data); - resolve({ statusCode: res.statusCode, data: data, error: '瑙f瀽JSON澶辫触' }); - } - }); - }); - - req.on('error', (error) => { - console.log(`璇锋眰閿欒:`, error.message); - reject(error); - }); - - req.write(postData); - req.end(); - }); -} - -// 涓绘祴璇曞嚱鏁� -async function runTests() { - console.log('寮�濮嬫祴璇旼raphQL API...\n'); - - try { - // 1. 娴嬭瘯鍩虹杩炴帴 - console.log('1. 娴嬭瘯GraphQL Schema鏌ヨ...'); - const healthResult = await executeGraphQLRequest('Schema鏌ヨ', queries.healthCheck); - - if (healthResult.statusCode === 200 && healthResult.data && !healthResult.data.errors) { - console.log('鉁� GraphQL鏈嶅姟杩炴帴姝e父'); - } else { - console.log('鉂� GraphQL鏈嶅姟杩炴帴寮傚父'); - if (healthResult.error) { - console.log('閿欒淇℃伅:', healthResult.error); - } - } - - // 绛夊緟涓�绉� - await new Promise(resolve => setTimeout(resolve, 1000)); - - // 2. 娴嬭瘯鎶ュ悕鎻愪氦 - console.log('\n2. 娴嬭瘯鎶ュ悕鎻愪氦鎺ュ彛...'); - const registrationResult = await executeGraphQLRequest('鎶ュ悕鎻愪氦', queries.submitRegistration); - - if (registrationResult.statusCode === 200 && registrationResult.data) { - if (registrationResult.data.errors) { - console.log('鉂� 鎶ュ悕鎻愪氦澶辫触'); - console.log('GraphQL閿欒:', registrationResult.data.errors); - } else if (registrationResult.data.data && registrationResult.data.data.submitActivityRegistration) { - const result = registrationResult.data.data.submitActivityRegistration; - if (result.success) { - console.log('鉁� 鎶ュ悕鎻愪氦鎴愬姛'); - console.log(`鎶ュ悕ID: ${result.registrationId}`); - console.log(`娑堟伅: ${result.message}`); - } else { - console.log('鉂� 鎶ュ悕鎻愪氦澶辫触'); - console.log(`閿欒娑堟伅: ${result.message}`); - } - } - } else { - console.log('鉂� 鎶ュ悕鎻愪氦璇锋眰澶辫触'); - } - - } catch (error) { - console.log('鉂� 娴嬭瘯杩囩▼涓彂鐢熼敊璇�:', error.message); - - if (error.code === 'ECONNREFUSED') { - console.log('\n馃挕 鎻愮ず: 鍚庣鏈嶅姟鍙兘鏈惎鍔ㄦ垨绔彛涓嶆纭�'); - console.log('璇风‘淇濆悗绔湇鍔℃鍦ㄨ繍琛屽湪 http://localhost:8080'); - } - } - - console.log('\n=== 娴嬭瘯瀹屾垚 ==='); - - // 杈撳嚭娴嬭瘯鎬荤粨 - console.log('\n=== 娴嬭瘯鎬荤粨 ==='); - console.log('鏈娴嬭瘯楠岃瘉浜嗕互涓嬪唴瀹�:'); - console.log('1. GraphQL鏈嶅姟鐨勫熀纭�杩炴帴'); - console.log('2. Schema鏌ヨ鍔熻兘'); - console.log('3. 鎶ュ悕鎻愪氦mutation'); - console.log('4. 鏁版嵁浼犺緭鍜屽搷搴斿鐞�'); - - console.log('\n=== 鏁版嵁搴撻獙璇佸缓璁� ==='); - console.log('濡傛灉鎶ュ悕鎻愪氦鎴愬姛锛岃妫�鏌ヤ互涓嬫暟鎹簱琛�:'); - console.log('1. t_user - 鐢ㄦ埛鍩烘湰淇℃伅'); - console.log('2. t_player - 閫夋墜璇︾粏淇℃伅'); - console.log('3. t_activity_player - 娲诲姩鎶ュ悕璁板綍'); - console.log('4. t_media - 澶村儚鍜岄檮浠舵枃浠惰褰�'); - - console.log('\n鍙互浣跨敤浠ヤ笅SQL鏌ヨ楠岃瘉鏁版嵁:'); - console.log('SELECT * FROM t_user WHERE phone = "13912345678";'); - console.log('SELECT * FROM t_player WHERE user_id = (SELECT id FROM t_user WHERE phone = "13912345678");'); - console.log('SELECT * FROM t_activity_player WHERE player_id = (SELECT id FROM t_player WHERE user_id = (SELECT id FROM t_user WHERE phone = "13912345678"));'); - console.log('SELECT * FROM t_media WHERE related_type IN ("user_avatar", "registration_attachment");'); -} - -// 杩愯娴嬭瘯 -runTests().catch(console.error); \ No newline at end of file diff --git a/test_media_api_integration.js b/test_media_api_integration.js deleted file mode 100644 index afd10d6..0000000 --- a/test_media_api_integration.js +++ /dev/null @@ -1,154 +0,0 @@ -const axios = require('axios'); - -// 閰嶇疆 -const BASE_URL = 'http://localhost:8080/api'; -const GRAPHQL_URL = `${BASE_URL}/graphql`; - -// 娴嬭瘯鏁版嵁 -const testData = { - activityId: "1", - playerInfo: { - name: "濯掍綋API娴嬭瘯鐢ㄦ埛", - phone: "13900139" + Date.now().toString().slice(-3), // 浣跨敤鏃堕棿鎴崇敓鎴愬敮涓�鎵嬫満鍙� - gender: 1, - birthDate: "1990-01-01", - education: "鏈", - introduction: "杩欐槸涓�涓獟浣揂PI娴嬭瘯鐢ㄦ埛", - description: "娴嬭瘯鎻忚堪", - avatarMediaId: "test-avatar-media-id-" + Date.now() // 妯℃嫙澶村儚濯掍綋ID - }, - regionId: "1", - projectName: "娴嬭瘯椤圭洰", - description: "娴嬭瘯鎶ュ悕", - attachmentMediaIds: [ - "test-attachment-" + Date.now() + "-1", - "test-attachment-" + Date.now() + "-2" - ] // 妯℃嫙闄勪欢濯掍綋ID鍒楄〃 -}; - -// GraphQL 鏌ヨ -const SUBMIT_REGISTRATION_MUTATION = ` - mutation SubmitActivityRegistration($input: ActivityRegistrationInput!) { - submitActivityRegistration(input: $input) { - success - message - registrationId - playerId - userId - } - } -`; - -// 鏌ヨ濯掍綋璁板綍鐨凣raphQL鏌ヨ -const GET_MEDIA_RECORDS_QUERY = ` - query MediasByTarget($targetType: Int!, $targetId: ID!) { - mediasByTarget(targetType: $targetType, targetId: $targetId) { - id - name - path - fileExt - mediaType - fullUrl - } - } -`; - -async function testMediaApiIntegration() { - console.log('馃殌 寮�濮嬫祴璇曟柊鐨勫獟浣揂PI闆嗘垚...\n'); - - try { - // 1. 鎻愪氦鎶ュ悕锛堝寘鍚ご鍍忓拰闄勪欢濯掍綋ID锛� - console.log('馃摑 姝ラ1: 鎻愪氦娲诲姩鎶ュ悕锛堝寘鍚獟浣揑D锛�...'); - const registrationResponse = await axios.post(GRAPHQL_URL, { - query: SUBMIT_REGISTRATION_MUTATION, - variables: { - input: testData - } - }); - - console.log('鎶ュ悕鍝嶅簲:', JSON.stringify(registrationResponse.data, null, 2)); - - if (registrationResponse.data.errors) { - console.error('鉂� 鎶ュ悕鎻愪氦澶辫触:', registrationResponse.data.errors); - return; - } - - const result = registrationResponse.data.data.submitActivityRegistration; - if (!result.success) { - console.error('鉂� 鎶ュ悕澶辫触:', result.message); - return; - } - - console.log('鉁� 鎶ュ悕鎴愬姛!'); - console.log(` - 娲诲姩鎶ュ悕ID: ${result.registrationId}`); - console.log(` - 閫夋墜ID: ${result.playerId}`); - console.log(` - 鐢ㄦ埛ID: ${result.userId}\n`); - - // 2. 楠岃瘉澶村儚濯掍綋璁板綍鏄惁淇濆瓨 - console.log('馃攳 姝ラ2: 楠岃瘉澶村儚濯掍綋璁板綍...'); - try { - const avatarMediaResponse = await axios.post(GRAPHQL_URL, { - query: GET_MEDIA_RECORDS_QUERY, - variables: { - targetType: 1, - targetId: result.playerId - } - }); - - if (avatarMediaResponse.data.data && avatarMediaResponse.data.data.mediaRecords) { - const avatarRecords = avatarMediaResponse.data.data.mediaRecords; - console.log(`鉁� 鎵惧埌 ${avatarRecords.length} 鏉″ご鍍忓獟浣撹褰昤); - avatarRecords.forEach(record => { - console.log(` - 濯掍綋ID: ${record.id}, 璺緞: ${record.path}, 绫诲瀷: ${record.mediaType}`); - }); - } else { - console.log('鈿狅笍 鏈壘鍒板ご鍍忓獟浣撹褰曪紙鍙兘鏌ヨ鎺ュ彛涓嶅瓨鍦級'); - } - } catch (error) { - console.log('鈿狅笍 澶村儚濯掍綋璁板綍鏌ヨ澶辫触锛堝彲鑳芥煡璇㈡帴鍙d笉瀛樺湪锛�:', error.message); - } - - // 3. 楠岃瘉闄勪欢濯掍綋璁板綍鏄惁淇濆瓨 - console.log('\n馃攳 姝ラ3: 楠岃瘉闄勪欢濯掍綋璁板綍...'); - try { - const attachmentMediaResponse = await axios.post(GRAPHQL_URL, { - query: GET_MEDIA_RECORDS_QUERY, - variables: { - targetType: 2, - targetId: result.registrationId - } - }); - - if (attachmentMediaResponse.data.data && attachmentMediaResponse.data.data.mediaRecords) { - const attachmentRecords = attachmentMediaResponse.data.data.mediaRecords; - console.log(`鉁� 鎵惧埌 ${attachmentRecords.length} 鏉¢檮浠跺獟浣撹褰昤); - attachmentRecords.forEach(record => { - console.log(` - 濯掍綋ID: ${record.id}, 璺緞: ${record.path}, 绫诲瀷: ${record.mediaType}`); - }); - } else { - console.log('鈿狅笍 鏈壘鍒伴檮浠跺獟浣撹褰曪紙鍙兘鏌ヨ鎺ュ彛涓嶅瓨鍦級'); - } - } catch (error) { - console.log('鈿狅笍 闄勪欢濯掍綋璁板綍鏌ヨ澶辫触锛堝彲鑳芥煡璇㈡帴鍙d笉瀛樺湪锛�:', error.message); - } - - // 4. 妫�鏌ユ暟鎹簱涓殑濯掍綋璁板綍锛堥�氳繃鏃ュ織锛� - console.log('\n馃搵 姝ラ4: 妫�鏌ュ悗绔棩蹇椾互楠岃瘉濯掍綋璁板綍淇濆瓨...'); - console.log('璇锋煡鐪嬪悗绔帶鍒跺彴鏃ュ織锛屽簲璇ヨ兘鐪嬪埌浠ヤ笅淇℃伅锛�'); - console.log(' - "寮�濮嬩繚瀛橀�夋墜澶村儚濯掍綋璁板綍"'); - console.log(' - "閫夋墜澶村儚濯掍綋璁板綍淇濆瓨鎴愬姛"'); - console.log(' - "寮�濮嬩繚瀛橀檮浠跺獟浣撹褰�"'); - console.log(' - "闄勪欢濯掍綋璁板綍淇濆瓨鎴愬姛"'); - - console.log('\n馃帀 濯掍綋API闆嗘垚娴嬭瘯瀹屾垚锛�'); - - } catch (error) { - console.error('鉂� 娴嬭瘯杩囩▼涓彂鐢熼敊璇�:', error.message); - if (error.response) { - console.error('鍝嶅簲鏁版嵁:', JSON.stringify(error.response.data, null, 2)); - } - } -} - -// 杩愯娴嬭瘯 -testMediaApiIntegration(); \ No newline at end of file diff --git a/test_media_query.js b/test_media_query.js deleted file mode 100644 index e64aa6e..0000000 --- a/test_media_query.js +++ /dev/null @@ -1,55 +0,0 @@ -const axios = require('axios'); - -// 閰嶇疆 -const GRAPHQL_URL = 'http://localhost:8080/api/graphql'; - -// 鏌ヨ濯掍綋璁板綍鐨凣raphQL鏌ヨ -const MEDIAS_BY_TARGET_QUERY = ` - query MediasByTarget($targetType: Int!, $targetId: ID!) { - mediasByTarget(targetType: $targetType, targetId: $targetId) { - id - name - path - fileExt - mediaType - fullUrl - } - } -`; - -async function testMediaQuery() { - console.log('馃攳 娴嬭瘯濯掍綋鏌ヨ鎺ュ彛...\n'); - - // 娴嬭瘯鏌ヨ閫夋墜澶村儚濯掍綋璁板綍 (targetType: 1, targetId: 42) - console.log('1. 鏌ヨ閫夋墜澶村儚濯掍綋璁板綍 (targetType: 1, targetId: 42)...'); - try { - const response = await axios.post(GRAPHQL_URL, { - query: MEDIAS_BY_TARGET_QUERY, - variables: { - targetType: 1, - targetId: "42" - } - }); - - console.log('閫夋墜澶村儚濯掍綋璁板綍:', JSON.stringify(response.data, null, 2)); - } catch (error) { - console.error('鏌ヨ閫夋墜澶村儚濯掍綋璁板綍澶辫触:', error.response?.data || error.message); - } - - console.log('\n2. 鏌ヨ娲诲姩鎶ュ悕闄勪欢濯掍綋璁板綍 (targetType: 2, targetId: 32)...'); - try { - const response = await axios.post(GRAPHQL_URL, { - query: MEDIAS_BY_TARGET_QUERY, - variables: { - targetType: 2, - targetId: "32" - } - }); - - console.log('娲诲姩鎶ュ悕闄勪欢濯掍綋璁板綍:', JSON.stringify(response.data, null, 2)); - } catch (error) { - console.error('鏌ヨ娲诲姩鎶ュ悕闄勪欢濯掍綋璁板綍澶辫触:', error.response?.data || error.message); - } -} - -testMediaQuery().catch(console.error); \ No newline at end of file diff --git a/test_new_phone_api.js b/test_new_phone_api.js deleted file mode 100644 index be1eaf8..0000000 --- a/test_new_phone_api.js +++ /dev/null @@ -1,112 +0,0 @@ -const axios = require('axios'); - -// 娴嬭瘯鏂扮殑鎵嬫満鍙疯幏鍙朅PI -async function testNewPhoneAPI() { - const graphqlEndpoint = 'http://localhost:8080/api/graphql'; - - // 娴嬭瘯GraphQL schema鏄惁鍖呭惈鏂扮殑mutation - const introspectionQuery = ` - query IntrospectionQuery { - __schema { - mutationType { - fields { - name - description - args { - name - type { - name - kind - } - } - type { - name - kind - } - } - } - } - } - `; - - try { - console.log('馃攳 妫�鏌raphQL schema涓殑mutation...'); - const introspectionResponse = await axios.post(graphqlEndpoint, { - query: introspectionQuery - }, { - headers: { - 'Content-Type': 'application/json' - } - }); - - if (introspectionResponse.data.errors) { - console.error('鉂� GraphQL introspection閿欒:', introspectionResponse.data.errors); - return; - } - - const mutations = introspectionResponse.data.data.__schema.mutationType.fields; - console.log('馃搵 鍙敤鐨刴utations:'); - mutations.forEach(mutation => { - console.log(` - ${mutation.name}: ${mutation.description || '鏃犳弿杩�'}`); - if (mutation.args && mutation.args.length > 0) { - console.log(` 鍙傛暟: ${mutation.args.map(arg => `${arg.name}(${arg.type.name || arg.type.kind})`).join(', ')}`); - } - }); - - // 妫�鏌ユ槸鍚﹀瓨鍦ㄦ柊鐨刧etPhoneNumberByCode mutation - const newPhoneAPI = mutations.find(m => m.name === 'getPhoneNumberByCode'); - if (newPhoneAPI) { - console.log('鉁� 鎵惧埌鏂扮殑鎵嬫満鍙疯幏鍙朅PI: getPhoneNumberByCode'); - console.log(' 鍙傛暟:', newPhoneAPI.args.map(arg => `${arg.name}(${arg.type.name || arg.type.kind})`).join(', ')); - console.log(' 杩斿洖绫诲瀷:', newPhoneAPI.type.name); - } else { - console.log('鉂� 鏈壘鍒版柊鐨勬墜鏈哄彿鑾峰彇API: getPhoneNumberByCode'); - } - - // 妫�鏌ユ棫鐨凙PI鏄惁杩樺瓨鍦� - const oldPhoneAPI = mutations.find(m => m.name === 'decryptPhoneNumber'); - if (oldPhoneAPI) { - console.log('鉁� 鏃х殑鎵嬫満鍙疯幏鍙朅PI浠嶇劧瀛樺湪: decryptPhoneNumber'); - } - - // 娴嬭瘯鏂癆PI璋冪敤锛堜娇鐢ㄦā鎷熺殑code锛� - console.log('\n馃И 娴嬭瘯鏂癆PI璋冪敤...'); - const testMutation = ` - mutation TestGetPhoneNumberByCode($code: String!) { - getPhoneNumberByCode(code: $code) { - phoneNumber - purePhoneNumber - countryCode - } - } - `; - - const testResponse = await axios.post(graphqlEndpoint, { - query: testMutation, - variables: { - code: "test_code_123" // 杩欐槸涓�涓祴璇昪ode锛岄鏈熶細澶辫触浣嗚兘楠岃瘉API缁撴瀯 - } - }, { - headers: { - 'Content-Type': 'application/json' - } - }); - - if (testResponse.data.errors) { - console.log('鈿狅笍 棰勬湡鐨勯敊璇紙浣跨敤娴嬭瘯code锛�:', testResponse.data.errors[0].message); - console.log('鉁� API缁撴瀯姝g‘锛岃兘澶熸帴鏀惰姹�'); - } else { - console.log('鉁� API璋冪敤鎴愬姛:', testResponse.data.data); - } - - } catch (error) { - console.error('鉂� 娴嬭瘯澶辫触:', error.response?.data || error.message); - } -} - -// 杩愯娴嬭瘯 -testNewPhoneAPI().then(() => { - console.log('\n馃帀 娴嬭瘯瀹屾垚'); -}).catch(error => { - console.error('馃挜 娴嬭瘯寮傚父:', error); -}); \ No newline at end of file diff --git a/test_phone_decrypt.js b/test_phone_decrypt.js deleted file mode 100644 index a82002a..0000000 --- a/test_phone_decrypt.js +++ /dev/null @@ -1,157 +0,0 @@ -/** - * 娴嬭瘯鎵嬫満鍙疯В瀵嗗姛鑳� - * 楠岃瘉淇鍚庣殑sessionKey澶勭悊閫昏緫 - */ - -const axios = require('axios'); - -// GraphQL 璇锋眰鍑芥暟 -async function graphqlRequest(query, variables = {}) { - try { - const response = await axios.post('http://localhost:8080/api/graphql', { - query, - variables - }, { - headers: { - 'Content-Type': 'application/json' - } - }); - - if (response.data.errors) { - console.error('GraphQL 閿欒:', response.data.errors); - return null; - } - - return response.data.data; - } catch (error) { - console.error('璇锋眰澶辫触:', error.message); - return null; - } -} - -// 娴嬭瘯寰俊鐧诲綍鑾峰彇sessionKey -async function testWxLogin() { - console.log('=== 娴嬭瘯寰俊鐧诲綍鑾峰彇sessionKey ==='); - - const loginQuery = ` - mutation WxLogin($code: String!, $loginIp: String!, $deviceInfo: String!) { - wxLogin(wxLoginRequest: { - code: $code - loginIp: $loginIp - deviceInfo: $deviceInfo - }) { - token - sessionKey - userInfo { - userId - name - phone - } - isNewUser - loginRecordId - } - } - `; - - const variables = { - code: "test_code_123", // 娴嬭瘯鐢ㄧ殑code - loginIp: "127.0.0.1", - deviceInfo: "娴嬭瘯璁惧" - }; - - const result = await graphqlRequest(loginQuery, variables); - - if (result && result.wxLogin) { - console.log('鉁� 鐧诲綍鎴愬姛'); - console.log('SessionKey瀛樺湪:', !!result.wxLogin.sessionKey); - console.log('SessionKey闀垮害:', result.wxLogin.sessionKey ? result.wxLogin.sessionKey.length : 0); - console.log('Token瀛樺湪:', !!result.wxLogin.token); - console.log('鐢ㄦ埛淇℃伅:', result.wxLogin.userInfo); - - return result.wxLogin.sessionKey; - } else { - console.log('鉂� 鐧诲綍澶辫触'); - return null; - } -} - -// 娴嬭瘯鎵嬫満鍙疯В瀵嗭紙浣跨敤绌簊essionKey锛� -async function testPhoneDecryptWithEmptyKey() { - console.log('\n=== 娴嬭瘯绌簊essionKey鐨勬墜鏈哄彿瑙e瘑 ==='); - - const decryptQuery = ` - mutation DecryptPhoneNumber($encryptedData: String!, $iv: String!, $sessionKey: String!) { - decryptPhoneNumber(encryptedData: $encryptedData, iv: $iv, sessionKey: $sessionKey) { - phoneNumber - } - } - `; - - const variables = { - encryptedData: "test_encrypted_data", - iv: "test_iv", - sessionKey: "" // 绌虹殑sessionKey锛屽簲璇ヤ細琚垜浠殑淇閫昏緫鎷︽埅 - }; - - const result = await graphqlRequest(decryptQuery, variables); - - if (result) { - console.log('鉂� 鎰忓鎴愬姛 - 绌簊essionKey搴旇琚嫤鎴�'); - } else { - console.log('鉁� 姝g‘鎷︽埅浜嗙┖sessionKey'); - } -} - -// 娴嬭瘯鎵嬫満鍙疯В瀵嗭紙浣跨敤鏈夋晥sessionKey锛� -async function testPhoneDecryptWithValidKey(sessionKey) { - console.log('\n=== 娴嬭瘯鏈夋晥sessionKey鐨勬墜鏈哄彿瑙e瘑 ==='); - - if (!sessionKey) { - console.log('鈿狅笍 娌℃湁鏈夋晥鐨剆essionKey锛岃烦杩囨祴璇�'); - return; - } - - const decryptQuery = ` - mutation DecryptPhoneNumber($encryptedData: String!, $iv: String!, $sessionKey: String!) { - decryptPhoneNumber(encryptedData: $encryptedData, iv: $iv, sessionKey: $sessionKey) { - phoneNumber - } - } - `; - - const variables = { - encryptedData: "test_encrypted_data", - iv: "test_iv", - sessionKey: sessionKey - }; - - const result = await graphqlRequest(decryptQuery, variables); - - if (result && result.decryptPhoneNumber) { - console.log('鉁� 瑙e瘑鎴愬姛:', result.decryptPhoneNumber.phoneNumber); - } else { - console.log('鉂� 瑙e瘑澶辫触锛堝彲鑳芥槸娴嬭瘯鏁版嵁鏃犳晥锛岃繖鏄甯哥殑锛�'); - } -} - -// 涓绘祴璇曞嚱鏁� -async function runTests() { - console.log('寮�濮嬫祴璇曟墜鏈哄彿瑙e瘑鍔熻兘淇...\n'); - - // 娴嬭瘯1: 寰俊鐧诲綍鑾峰彇sessionKey - const sessionKey = await testWxLogin(); - - // 娴嬭瘯2: 绌簊essionKey搴旇琚嫤鎴� - await testPhoneDecryptWithEmptyKey(); - - // 娴嬭瘯3: 鏈夋晥sessionKey鐨勮В瀵� - await testPhoneDecryptWithValidKey(sessionKey); - - console.log('\n=== 娴嬭瘯瀹屾垚 ==='); - console.log('濡傛灉鐪嬪埌"姝g‘鎷︽埅浜嗙┖sessionKey"锛岃鏄庝慨澶嶇敓鏁堜簡锛�'); -} - -// 杩愯娴嬭瘯 -runTests().catch(error => { - console.error('娴嬭瘯杩囩▼涓彂鐢熼敊璇�:', error); -}); \ No newline at end of file diff --git a/test_phone_decrypt_flow.js b/test_phone_decrypt_flow.js deleted file mode 100644 index e4e7ba1..0000000 --- a/test_phone_decrypt_flow.js +++ /dev/null @@ -1,132 +0,0 @@ -/** - * 娴嬭瘯鎵嬫満鍙疯В瀵嗘祦绋� - * 楠岃瘉浠庡井淇$櫥褰曞埌鎵嬫満鍙疯В瀵嗙殑瀹屾暣娴佺▼ - */ - -const axios = require('axios'); - -// 閰嶇疆 -const BACKEND_URL = 'http://localhost:8080/api/graphql'; - -// 妯℃嫙寰俊灏忕▼搴忕殑鎵嬫満鍙疯В瀵嗘祦绋� -async function testPhoneDecryptFlow() { - console.log('馃И 寮�濮嬫祴璇曟墜鏈哄彿瑙e瘑娴佺▼...\n'); - - try { - // 姝ラ1: 娴嬭瘯寰俊鐧诲綍鑾峰彇sessionKey - console.log('馃摫 姝ラ1: 娴嬭瘯寰俊鐧诲綍鑾峰彇sessionKey'); - const loginResponse = await axios.post(BACKEND_URL, { - query: ` - mutation WxLogin($input: WxLoginRequest!) { - wxLogin(input: $input) { - token - sessionKey - userInfo { - userId - name - phone - } - isNewUser - } - } - `, - variables: { - input: { - code: "test_code_123", - loginIp: "127.0.0.1", - deviceInfo: "test_device" - } - } - }); - - if (loginResponse.data.errors) { - console.error('鉂� 寰俊鐧诲綍澶辫触:', loginResponse.data.errors); - return; - } - - const { token, sessionKey, userInfo } = loginResponse.data.data.wxLogin; - console.log('鉁� 寰俊鐧诲綍鎴愬姛'); - console.log(' - Token:', token ? '宸茶幏鍙�' : '鏈幏鍙�'); - console.log(' - SessionKey:', sessionKey ? `宸茶幏鍙� (闀垮害: ${sessionKey.length})` : '鏈幏鍙�'); - console.log(' - 鐢ㄦ埛ID:', userInfo.userId); - console.log(' - 鐢ㄦ埛鍚�:', userInfo.name); - console.log(' - 褰撳墠鎵嬫満鍙�:', userInfo.phone || '鏈缃�'); - - if (!sessionKey) { - console.error('鉂� SessionKey涓虹┖锛屾棤娉曡繘琛屾墜鏈哄彿瑙e瘑娴嬭瘯'); - return; - } - - // 姝ラ2: 妯℃嫙鎵嬫満鍙疯В瀵� - console.log('\n馃攼 姝ラ2: 娴嬭瘯鎵嬫満鍙疯В瀵�'); - - // 妯℃嫙寰俊杩斿洖鐨勫姞瀵嗘暟鎹紙杩欓噷浣跨敤娴嬭瘯鏁版嵁锛� - const mockEncryptedData = "test_encrypted_data"; - const mockIv = "test_iv"; - - console.log(' - 妯℃嫙encryptedData:', mockEncryptedData); - console.log(' - 妯℃嫙iv:', mockIv); - console.log(' - 浣跨敤sessionKey:', sessionKey); - - try { - const decryptResponse = await axios.post(BACKEND_URL, { - query: ` - mutation DecryptPhoneNumber($encryptedData: String!, $iv: String!, $sessionKey: String!) { - decryptPhoneNumber(encryptedData: $encryptedData, iv: $iv, sessionKey: $sessionKey) { - phoneNumber - purePhoneNumber - countryCode - } - } - `, - variables: { - encryptedData: mockEncryptedData, - iv: mockIv, - sessionKey: sessionKey - } - }); - - if (decryptResponse.data.errors) { - console.log('鈿狅笍 鎵嬫満鍙疯В瀵嗗け璐ワ紙棰勬湡鐨勶紝鍥犱负浣跨敤浜嗘ā鎷熸暟鎹級:', decryptResponse.data.errors[0].message); - console.log('鉁� 浣嗘槸鎺ュ彛璋冪敤姝e父锛岃鏄嶨raphQL鎺ュ彛閰嶇疆姝g‘'); - } else { - const phoneInfo = decryptResponse.data.data.decryptPhoneNumber; - console.log('鉁� 鎵嬫満鍙疯В瀵嗘垚鍔�:'); - console.log(' - 瀹屾暣鎵嬫満鍙�:', phoneInfo.phoneNumber); - console.log(' - 绾墜鏈哄彿:', phoneInfo.purePhoneNumber); - console.log(' - 鍥藉浠g爜:', phoneInfo.countryCode); - } - } catch (decryptError) { - console.log('鈿狅笍 鎵嬫満鍙疯В瀵嗚皟鐢ㄥけ璐ワ紙棰勬湡鐨勶紝鍥犱负浣跨敤浜嗘ā鎷熸暟鎹級'); - console.log('鉁� 浣嗘槸鎺ュ彛瀛樺湪涓斿彲璋冪敤锛岃鏄庡悗绔厤缃纭�'); - } - - // 姝ラ3: 楠岃瘉鍓嶇閫昏緫 - console.log('\n馃幆 姝ラ3: 楠岃瘉鍓嶇閫昏緫'); - console.log('鉁� 鍓嶇registration.js宸叉纭疄鐜�:'); - console.log(' - 浣跨敤鍚庣decryptPhoneNumber鎺ュ彛'); - console.log(' - 姝g‘浼犻�抏ncryptedData, iv, sessionKey鍙傛暟'); - console.log(' - 姝g‘澶勭悊杩斿洖鐨刾honeNumber'); - console.log(' - 鍖呭惈瀹屾暣鐨勯敊璇鐞嗛�昏緫'); - - // 姝ラ4: 鎬荤粨 - console.log('\n馃搵 娴嬭瘯鎬荤粨:'); - console.log('鉁� 鍚庣wxLogin鎺ュ彛姝e父锛岃兘杩斿洖sessionKey'); - console.log('鉁� 鍚庣decryptPhoneNumber鎺ュ彛瀛樺湪涓斿彲璋冪敤'); - console.log('鉁� 鍓嶇宸叉纭疄鐜板悗绔墜鏈哄彿瑙e瘑閫昏緫'); - console.log('鉁� 鏁翠釜鎵嬫満鍙疯В瀵嗘祦绋嬫灦鏋勬纭�'); - - console.log('\n馃帀 鎵嬫満鍙疯В瀵嗘祦绋嬫祴璇曞畬鎴愶紒'); - console.log('馃挕 娉ㄦ剰: 瀹為檯浣跨敤鏃堕渶瑕佺湡瀹炵殑寰俊鍔犲瘑鏁版嵁鎵嶈兘鎴愬姛瑙e瘑'); - - } catch (error) { - console.error('鉂� 娴嬭瘯杩囩▼涓彂鐢熼敊璇�:', error.message); - if (error.response) { - console.error(' 鍝嶅簲鐘舵��:', error.response.status); - console.error(' 鍝嶅簲鏁版嵁:', error.response.data); - } - } -} - -// 杩愯娴嬭瘯 -testPhoneDecryptFlow(); \ No newline at end of file diff --git a/test_phone_fix.js b/test_phone_fix.js deleted file mode 100644 index af651c9..0000000 --- a/test_phone_fix.js +++ /dev/null @@ -1,159 +0,0 @@ -const axios = require('axios'); - -// 娴嬭瘯淇鍚庣殑鎵嬫満鍙疯幏鍙栧姛鑳� -async function testPhoneFix() { - const graphqlEndpoint = 'http://localhost:8080/api/graphql'; - - console.log('馃И 娴嬭瘯淇鍚庣殑鎵嬫満鍙疯幏鍙栧姛鑳�'); - console.log('='.repeat(50)); - - // 1. 娴嬭瘯鏂扮増API - console.log('\n1锔忊儯 娴嬭瘯鏂扮増API (getPhoneNumberByCode)'); - try { - const newApiMutation = ` - mutation GetPhoneNumberByCode($code: String!) { - getPhoneNumberByCode(code: $code) { - phoneNumber - purePhoneNumber - countryCode - } - } - `; - - const newApiResponse = await axios.post(graphqlEndpoint, { - query: newApiMutation, - variables: { - code: "test_code_new_api" - } - }, { - headers: { - 'Content-Type': 'application/json' - } - }); - - if (newApiResponse.data.errors) { - console.log('鈿狅笍 棰勬湡鐨勯敊璇紙浣跨敤娴嬭瘯code锛�:', newApiResponse.data.errors[0].message); - console.log('鉁� 鏂扮増API缁撴瀯姝g‘锛岃兘澶熸帴鏀惰姹�'); - } else { - console.log('鉁� 鏂扮増API璋冪敤鎴愬姛:', newApiResponse.data.data); - } - } catch (error) { - console.error('鉂� 鏂扮増API娴嬭瘯澶辫触:', error.response?.data || error.message); - } - - // 2. 娴嬭瘯鏃х増API锛堢‘淇濆悜鍚庡吋瀹癸級 - console.log('\n2锔忊儯 娴嬭瘯鏃х増API (decryptPhoneNumber)'); - try { - const oldApiMutation = ` - mutation DecryptPhoneNumber($encryptedData: String!, $iv: String!, $sessionKey: String!) { - decryptPhoneNumber(encryptedData: $encryptedData, iv: $iv, sessionKey: $sessionKey) { - phoneNumber - purePhoneNumber - countryCode - } - } - `; - - const oldApiResponse = await axios.post(graphqlEndpoint, { - query: oldApiMutation, - variables: { - encryptedData: "test_encrypted_data", - iv: "test_iv", - sessionKey: "test_session_key" - } - }, { - headers: { - 'Content-Type': 'application/json' - } - }); - - if (oldApiResponse.data.errors) { - console.log('鈿狅笍 棰勬湡鐨勯敊璇紙浣跨敤娴嬭瘯鏁版嵁锛�:', oldApiResponse.data.errors[0].message); - console.log('鉁� 鏃х増API缁撴瀯姝g‘锛岃兘澶熸帴鏀惰姹�'); - } else { - console.log('鉁� 鏃х増API璋冪敤鎴愬姛:', oldApiResponse.data.data); - } - } catch (error) { - console.error('鉂� 鏃х増API娴嬭瘯澶辫触:', error.response?.data || error.message); - } - - // 3. 妫�鏌raphQL schema - console.log('\n3锔忊儯 妫�鏌raphQL schema'); - try { - const introspectionQuery = ` - query { - __schema { - mutationType { - fields { - name - description - args { - name - type { - name - kind - } - } - } - } - } - } - `; - - const schemaResponse = await axios.post(graphqlEndpoint, { - query: introspectionQuery - }, { - headers: { - 'Content-Type': 'application/json' - } - }); - - const mutations = schemaResponse.data.data.__schema.mutationType.fields; - const phoneAPIs = mutations.filter(m => - m.name === 'getPhoneNumberByCode' || m.name === 'decryptPhoneNumber' - ); - - console.log('馃搵 鎵嬫満鍙风浉鍏崇殑API:'); - phoneAPIs.forEach(api => { - console.log(` - ${api.name}: ${api.description || '鏃犳弿杩�'}`); - if (api.args && api.args.length > 0) { - console.log(` 鍙傛暟: ${api.args.map(arg => `${arg.name}(${arg.type.name || arg.type.kind})`).join(', ')}`); - } - }); - - const hasNewAPI = phoneAPIs.some(api => api.name === 'getPhoneNumberByCode'); - const hasOldAPI = phoneAPIs.some(api => api.name === 'decryptPhoneNumber'); - - if (hasNewAPI && hasOldAPI) { - console.log('鉁� 鏂版棫API閮藉瓨鍦紝鏀寔鍚戝悗鍏煎'); - } else { - console.log('鉂� API涓嶅畬鏁�'); - console.log(' 鏂癆PI瀛樺湪:', hasNewAPI); - console.log(' 鏃PI瀛樺湪:', hasOldAPI); - } - - } catch (error) { - console.error('鉂� Schema妫�鏌ュけ璐�:', error.response?.data || error.message); - } - - // 4. 鎬荤粨 - console.log('\n馃搳 淇鎬荤粨:'); - console.log('鉁� 鍚庣宸叉坊鍔犳柊鐗堟墜鏈哄彿鑾峰彇API (getPhoneNumberByCode)'); - console.log('鉁� 鍚庣淇濈暀鏃х増API浠ョ‘淇濆悜鍚庡吋瀹� (decryptPhoneNumber)'); - console.log('鉁� 鍓嶇宸蹭慨澶嶄负浼樺厛浣跨敤鏂扮増API锛屽け璐ユ椂鍥為��鍒版棫鐗圓PI'); - console.log('鉁� 鏀寔寰俊灏忕▼搴忓熀纭�搴�3.10.1+鐨勬柊鐗规��'); - - console.log('\n馃幆 鍓嶇閫昏緫:'); - console.log('1. 妫�鏌ュ井淇¤繑鍥炵殑e.detail.code'); - console.log('2. 濡傛灉鏈塩ode锛屼紭鍏堣皟鐢ㄦ柊鐗圓PI (getPhoneNumberByCode)'); - console.log('3. 濡傛灉鏂扮増API澶辫触锛屽洖閫�鍒版棫鐗圓PI (decryptPhoneNumber)'); - console.log('4. 濡傛灉娌℃湁code锛岀洿鎺ヤ娇鐢ㄦ棫鐗圓PI'); - console.log('5. 纭繚鍚戝悗鍏煎锛屾敮鎸佹墍鏈夊熀纭�搴撶増鏈�'); -} - -// 杩愯娴嬭瘯 -testPhoneFix().then(() => { - console.log('\n馃帀 娴嬭瘯瀹屾垚'); -}).catch(error => { - console.error('馃挜 娴嬭瘯寮傚父:', error); -}); \ No newline at end of file diff --git a/test_rating_scheme.js b/test_rating_scheme.js deleted file mode 100644 index cb18e8b..0000000 --- a/test_rating_scheme.js +++ /dev/null @@ -1,35 +0,0 @@ -const axios = require('axios'); - -const API_URL = 'http://localhost:8080/api/graphql'; - -async function testRatingScheme() { - try { - console.log('娴嬭瘯璇勫垎鏂规鏄惁瀛樺湪...'); - - // 鏌ヨ鐗瑰畾璇勫垎鏂规 - const ratingSchemeQuery = { - query: ` - query { - ratingScheme(id: "3") { - id - name - description - items { - id - name - maxScore - } - } - } - ` - }; - - const response = await axios.post(API_URL, ratingSchemeQuery); - console.log('璇勫垎鏂规鏌ヨ缁撴灉:', JSON.stringify(response.data, null, 2)); - - } catch (error) { - console.error('鏌ヨ澶辫触:', error.response?.data || error.message); - } -} - -testRatingScheme(); \ No newline at end of file diff --git a/test_real_wechat_login.js b/test_real_wechat_login.js deleted file mode 100644 index 6fb5fe5..0000000 --- a/test_real_wechat_login.js +++ /dev/null @@ -1,120 +0,0 @@ -/** - * 娴嬭瘯鐪熷疄寰俊鐧诲綍娴佺▼ - * 楠岃瘉淇鍚庣殑wxLogin鎺ュ彛鏄惁鑳芥纭鐞嗙湡瀹炲井淇ode - */ -async function testRealWechatLogin() { - // 鍔ㄦ�佸鍏� node-fetch - const { default: fetch } = await import('node-fetch'); - console.log('=== 娴嬭瘯鐪熷疄寰俊鐧诲綍娴佺▼ ==='); - console.log('娴嬭瘯鏃堕棿:', new Date().toLocaleString()); - - const graphqlUrl = 'http://localhost:8080/api/graphql'; - - // 妯℃嫙涓�涓湡瀹炵殑寰俊code锛堝疄闄呬娇鐢ㄦ椂搴旇浠庡皬绋嬪簭绔幏鍙栵級 - const testCode = 'real_wechat_code_from_miniprogram'; - - const mutation = ` - mutation { - wxLogin(input: { - code: "${testCode}" - loginIp: "192.168.1.100" - deviceInfo: "iPhone 13 Pro" - phoneAuthorized: false - }) { - token - userInfo { - userId - name - userType - } - isNewUser - loginRecordId - sessionKey - } - } - `; - - try { - console.log('姝ラ1: 鍙戦�亀xLogin璇锋眰'); - console.log('- GraphQL绔偣:', graphqlUrl); - console.log('- 浣跨敤code:', testCode); - console.log('- 娴嬭瘯妯″紡: false (搴旇璋冪敤鐪熷疄寰俊API)'); - - const response = await fetch(graphqlUrl, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - query: mutation - }) - }); - - const result = await response.json(); - - console.log('\n姝ラ2: 鍒嗘瀽鍝嶅簲缁撴灉'); - console.log('HTTP鐘舵�佺爜:', response.status); - - if (result.errors) { - console.log('鉂� GraphQL閿欒:'); - result.errors.forEach((error, index) => { - console.log(` ${index + 1}. ${error.message}`); - if (error.extensions) { - console.log(` 鍒嗙被: ${error.extensions.classification}`); - } - }); - - // 妫�鏌ユ槸鍚︽槸寰俊API鐩稿叧鐨勯敊璇� - const wechatApiError = result.errors.find(error => - error.message.includes('寰俊API') || - error.message.includes('AppSecret') || - error.message.includes('code2session') - ); - - if (wechatApiError) { - console.log('\n馃攳 妫�娴嬪埌寰俊API鐩稿叧閿欒:'); - console.log('杩欒〃鏄庣郴缁熸鍦ㄥ皾璇曡皟鐢ㄧ湡瀹炵殑寰俊API锛岃�屼笉鏄繑鍥炴祴璇曟暟鎹�'); - console.log('閿欒鍘熷洜鍙兘鏄�:'); - console.log('1. 浣跨敤鐨刢ode涓嶆槸鐪熷疄鐨勫井淇$櫥褰昪ode'); - console.log('2. 寰俊灏忕▼搴忛厤缃紙AppID/AppSecret锛夐渶瑕侀獙璇�'); - console.log('3. 缃戠粶杩炴帴闂'); - - console.log('\n鉁� 淇楠岃瘉: test-mode宸叉垚鍔熻缃负false'); - console.log('绯荤粺鐜板湪浼氳皟鐢ㄧ湡瀹炵殑寰俊API鑰屼笉鏄繑鍥炴祴璇曟暟鎹�'); - } - } else { - console.log('鉁� 璇锋眰鎴愬姛'); - console.log('鍝嶅簲鏁版嵁:', JSON.stringify(result.data, null, 2)); - - const wxLoginData = result.data.wxLogin; - if (wxLoginData) { - console.log('\n馃搳 鐧诲綍缁撴灉鍒嗘瀽:'); - console.log('- Token瀛樺湪:', !!wxLoginData.token); - console.log('- 鐢ㄦ埛ID:', wxLoginData.userInfo?.userId); - console.log('- 鏄惁鏂扮敤鎴�:', wxLoginData.isNewUser); - console.log('- 鐧诲綍璁板綍ID:', wxLoginData.loginRecordId); - console.log('- SessionKey瀛樺湪:', !!wxLoginData.sessionKey); - console.log('- SessionKey闀垮害:', wxLoginData.sessionKey?.length || 0); - - // 妫�鏌essionKey鏄惁鏄祴璇曟暟鎹� - if (wxLoginData.sessionKey && wxLoginData.sessionKey.startsWith('test_session_key_')) { - console.log('鈿狅笍 璀﹀憡: SessionKey浠嶇劧鏄祴璇曟暟鎹�'); - console.log('杩欒〃鏄巘est-mode鍙兘浠嶇劧涓簍rue锛屾垨鑰呴厤缃湭鐢熸晥'); - } else if (wxLoginData.sessionKey) { - console.log('鉁� SessionKey鐪嬭捣鏉ユ槸鐪熷疄鏁版嵁锛堜笉鏄痶est_寮�澶达級'); - } - } - } - - } catch (error) { - console.log('鉂� 璇锋眰寮傚父:', error.message); - console.log('閿欒璇︽儏:', error); - } - - console.log('\n=== 娴嬭瘯瀹屾垚 ==='); - console.log('涓嬩竴姝�: 濡傛灉鐪嬪埌寰俊API鐩稿叧閿欒锛岃鏄庝慨澶嶆垚鍔�'); - console.log('闇�瑕佷娇鐢ㄧ湡瀹炵殑寰俊灏忕▼搴忕櫥褰昪ode杩涜鏈�缁堟祴璇�'); -} - -// 杩愯娴嬭瘯 -testRealWechatLogin().catch(console.error); \ No newline at end of file diff --git a/test_registration_api.js b/test_registration_api.js deleted file mode 100644 index e549605..0000000 --- a/test_registration_api.js +++ /dev/null @@ -1,110 +0,0 @@ -// 娴嬭瘯鎶ュ悕API鐨勮剼鏈� -const axios = require('axios'); - -const API_URL = 'http://localhost:8080/api/graphql'; - -// 娴嬭瘯鑾峰彇娲诲姩鍒楄〃 -async function testGetActivities() { - console.log('馃攳 娴嬭瘯鑾峰彇娲诲姩鍒楄〃...'); - try { - const response = await axios.post(API_URL, { - query: ` - query { - allActivities { - id - name - signupDeadline - state - } - } - ` - }, { - headers: { - 'Content-Type': 'application/json' - } - }); - - console.log('鉁� 娲诲姩鍒楄〃鑾峰彇鎴愬姛:'); - console.log(JSON.stringify(response.data, null, 2)); - return response.data.data.allActivities; - } catch (error) { - console.error('鉂� 鑾峰彇娲诲姩鍒楄〃澶辫触:', error.response?.data || error.message); - return []; - } -} - -// 娴嬭瘯鎶ュ悕API -async function testRegistration(activityId) { - console.log(`馃殌 娴嬭瘯鎶ュ悕API (娲诲姩ID: ${activityId})...`); - try { - const response = await axios.post(API_URL, { - query: ` - mutation { - submitActivityRegistration(input: { - activityId: "${activityId}", - playerInfo: { - name: "娴嬭瘯瀛﹀憳${Date.now()}", - phone: "138${String(Date.now()).slice(-8)}", - gender: 1, - education: "鏈", - introduction: "杩欐槸涓�涓祴璇曟姤鍚�", - description: "娴嬭瘯鎻忚堪" - }, - regionId: "1", - description: "娴嬭瘯鎶ュ悕鎻忚堪", - mediaFiles: [] - }) { - success - message - registrationId - } - } - ` - }, { - headers: { - 'Content-Type': 'application/json' - } - }); - - console.log('鉁� 鎶ュ悕API璋冪敤鎴愬姛:'); - console.log(JSON.stringify(response.data, null, 2)); - return response.data.data.submitActivityRegistration; - } catch (error) { - console.error('鉂� 鎶ュ悕API璋冪敤澶辫触:', error.response?.data || error.message); - return null; - } -} - -// 涓绘祴璇曞嚱鏁� -async function runTests() { - console.log('馃幆 寮�濮嬫祴璇曟姤鍚岮PI鍔熻兘...\n'); - - // 1. 鑾峰彇娲诲姩鍒楄〃 - const activities = await testGetActivities(); - console.log('\n' + '='.repeat(50) + '\n'); - - if (activities.length === 0) { - console.log('鈿狅笍 娌℃湁鎵惧埌鍙敤鐨勬椿鍔紝鏃犳硶娴嬭瘯鎶ュ悕鍔熻兘'); - return; - } - - // 2. 浣跨敤绗竴涓椿鍔ㄨ繘琛屾姤鍚嶆祴璇� - const firstActivity = activities[0]; - console.log(`馃摑 浣跨敤娲诲姩 "${firstActivity.name}" (ID: ${firstActivity.id}) 杩涜鎶ュ悕娴嬭瘯`); - - const registrationResult = await testRegistration(firstActivity.id); - console.log('\n' + '='.repeat(50) + '\n'); - - if (registrationResult && registrationResult.success) { - console.log('馃帀 鎶ュ悕鍔熻兘娴嬭瘯鎴愬姛锛�'); - console.log(`馃搵 鎶ュ悕ID: ${registrationResult.registrationId}`); - } else { - console.log('鉂� 鎶ュ悕鍔熻兘娴嬭瘯澶辫触'); - if (registrationResult && registrationResult.message) { - console.log(`閿欒淇℃伅: ${registrationResult.message}`); - } - } -} - -// 杩愯娴嬭瘯 -runTests().catch(console.error); \ No newline at end of file diff --git a/test_registration_fix.js b/test_registration_fix.js deleted file mode 100644 index 72bfe23..0000000 --- a/test_registration_fix.js +++ /dev/null @@ -1,219 +0,0 @@ -// 娴嬭瘯娉ㄥ唽椤甸潰淇 -// 妯℃嫙灏忕▼搴忕幆澧冨拰registration.js鐨勫叧閿�昏緫 - -// 妯℃嫙寰俊灏忕▼搴廇PI -const wx = { - showToast: (options) => console.log('Toast:', options.title), - showModal: (options) => { - console.log('Modal:', options.title, '-', options.content) - if (options.success) { - options.success({ confirm: true }) - } - }, - navigateBack: () => console.log('Navigate back') -} - -// 妯℃嫙GraphQL璇锋眰 -const graphqlRequest = async (query, variables) => { - console.log('GraphQL Request:', { query: query.substring(0, 50) + '...', variables }) - - // 娣诲姞寤惰繜妯℃嫙缃戠粶璇锋眰 - await new Promise(resolve => setTimeout(resolve, 100)) - - // 妯℃嫙涓嶅悓鐨勫搷搴旀儏鍐� - if (variables.id === 'invalid') { - return { data: null } - } else if (variables.id === 'error') { - throw new Error('Network error') - } else { - return { - data: { - activity: { - id: variables.id, - title: '娴嬭瘯娲诲姩', - description: '娴嬭瘯娲诲姩鎻忚堪', - registrationRequirements: '娴嬭瘯瑕佹眰', - isTeamActivity: false, - maxTeamSize: 1, - requiredFields: ['name', 'phone'], - allowedFileTypes: ['jpg', 'png'], - maxFileSize: 10485760 - } - } - } - } -} - -// 妯℃嫙椤甸潰鏁版嵁 -class RegistrationPage { - constructor() { - this.data = { - activityId: null, - activity: null, - loading: false, - isSubmitting: false, - formData: { - name: '娴嬭瘯鐢ㄦ埛', - phone: '13800138000', - gender: '鐢�', - regionId: '1' - } - } - } - - setData(newData) { - Object.assign(this.data, newData) - console.log('Data updated:', Object.keys(newData)) - } - - // 鍔犺浇娲诲姩淇℃伅锛堜慨澶嶅悗鐨勭増鏈級 - async loadActivityInfo() { - try { - this.setData({ loading: true }) - - const query = ` - query GetActivity($id: ID!) { - activity(id: $id) { - id - title - description - registrationRequirements - isTeamActivity - maxTeamSize - requiredFields - allowedFileTypes - maxFileSize - } - } - ` - - const result = await graphqlRequest(query, { id: this.data.activityId }) - - if (result.data && result.data.activity) { - this.setData({ - activity: result.data.activity - }) - - console.log('Activity loaded successfully:', result.data.activity.title) - } else { - // 娲诲姩淇℃伅涓嶅瓨鍦ㄦ垨鍔犺浇澶辫触 - wx.showModal({ - title: '鎻愮ず', - content: '娲诲姩淇℃伅涓嶅瓨鍦ㄦ垨宸插け鏁�', - showCancel: false, - success: () => { - wx.navigateBack() - } - }) - } - } catch (error) { - console.error('鍔犺浇娲诲姩淇℃伅澶辫触:', error) - wx.showModal({ - title: '鍔犺浇澶辫触', - content: '缃戠粶杩炴帴寮傚父锛岃妫�鏌ョ綉缁滃悗閲嶈瘯', - showCancel: true, - cancelText: '杩斿洖', - confirmText: '閲嶈瘯', - success: (res) => { - if (res.confirm) { - console.log('鐢ㄦ埛閫夋嫨閲嶈瘯') - } else { - wx.navigateBack() - } - } - }) - } finally { - this.setData({ loading: false }) - } - } - - validateForm() { - return true // 绠�鍖栭獙璇� - } - - // 鎻愪氦鏂规硶锛堜慨澶嶅悗鐨勭増鏈級 - async onSubmit() { - if (this.data.isSubmitting) return - - // 妫�鏌ユ椿鍔ㄤ俊鎭槸鍚﹀姞杞藉畬鎴� - if (!this.data.activity || !this.data.activity.id) { - wx.showToast({ - title: '娲诲姩淇℃伅鍔犺浇涓紝璇风◢鍚庨噸璇�', - icon: 'none' - }) - return - } - - // 琛ㄥ崟楠岃瘉 - if (!this.validateForm()) { - wx.showToast({ - title: '璇锋鏌ヨ〃鍗曚俊鎭�', - icon: 'none' - }) - return - } - - this.setData({ isSubmitting: true }) - - try { - const { formData } = this.data - const activityId = this.data.activity.id - - console.log('Submitting registration for activity:', activityId) - - // 妯℃嫙鎻愪氦鎴愬姛 - wx.showToast({ - title: '鎶ュ悕鎴愬姛', - icon: 'success' - }) - - } catch (error) { - console.error('鎻愪氦澶辫触:', error) - wx.showToast({ - title: error.message || '鎻愪氦澶辫触锛岃閲嶈瘯', - icon: 'none' - }) - } finally { - this.setData({ isSubmitting: false }) - } - } -} - -// 娴嬭瘯鍦烘櫙 -async function runTests() { - console.log('=== 娴嬭瘯娉ㄥ唽椤甸潰淇 ===\n') - - // 娴嬭瘯1: 姝e父鎯呭喌 - console.log('娴嬭瘯1: 姝e父鍔犺浇娲诲姩淇℃伅') - const page1 = new RegistrationPage() - page1.data.activityId = '123' - await page1.loadActivityInfo() - await page1.onSubmit() - console.log('') - - // 娴嬭瘯2: 娲诲姩涓嶅瓨鍦� - console.log('娴嬭瘯2: 娲诲姩淇℃伅涓嶅瓨鍦�') - const page2 = new RegistrationPage() - page2.data.activityId = 'invalid' - await page2.loadActivityInfo() - await page2.onSubmit() - console.log('') - - // 娴嬭瘯3: 缃戠粶閿欒 - console.log('娴嬭瘯3: 缃戠粶杩炴帴閿欒') - const page3 = new RegistrationPage() - page3.data.activityId = 'error' - await page3.loadActivityInfo() - await page3.onSubmit() - console.log('') - - // 娴嬭瘯4: 娲诲姩鏈姞杞芥椂鎻愪氦 - console.log('娴嬭瘯4: 娲诲姩淇℃伅鏈姞杞芥椂鎻愪氦') - const page4 = new RegistrationPage() - await page4.onSubmit() - console.log('') - - console.log('=== 娴嬭瘯瀹屾垚 ===') -} - -runTests().catch(console.error) \ No newline at end of file diff --git a/test_registration_simple.js b/test_registration_simple.js deleted file mode 100644 index d60c81a..0000000 --- a/test_registration_simple.js +++ /dev/null @@ -1,73 +0,0 @@ -const axios = require('axios'); - -const API_URL = 'http://localhost:8080/api/graphql'; - -async function testRegistration() { - try { - console.log('寮�濮嬫祴璇曟姤鍚岮PI...'); - - // 1. 鍏堟煡璇㈡墍鏈夋椿鍔� - const activitiesQuery = { - query: ` - query { - allActivities { - id - name - description - signupDeadline - } - } - ` - }; - - console.log('1. 鏌ヨ鎵�鏈夋椿鍔�...'); - const activitiesResponse = await axios.post(API_URL, activitiesQuery); - console.log('娲诲姩鍒楄〃:', JSON.stringify(activitiesResponse.data, null, 2)); - - const activities = activitiesResponse.data.data.allActivities; - if (activities.length === 0) { - console.log('娌℃湁鎵惧埌娲诲姩锛屾棤娉曟祴璇曟姤鍚�'); - return; - } - - const activityId = activities[0].id; - console.log(`浣跨敤娲诲姩ID: ${activityId} 杩涜娴嬭瘯`); - - // 2. 娴嬭瘯鎶ュ悕 - const timestamp = Date.now(); - const testPhone = `138${String(timestamp).slice(-8)}`; - const registrationMutation = { - query: ` - mutation { - submitActivityRegistration(input: { - activityId: "${activityId}" - playerInfo: { - name: "娴嬭瘯鐢ㄦ埛${timestamp}" - phone: "${testPhone}" - gender: 1 - education: "鏈" - introduction: "杩欐槸涓�涓祴璇曠敤鎴�" - description: "娴嬭瘯鎻忚堪" - } - regionId: null - description: "娴嬭瘯鎶ュ悕鎻忚堪" - mediaFiles: [] - }) { - success - message - registrationId - } - } - ` - }; - - console.log('2. 鎻愪氦鎶ュ悕...'); - const registrationResponse = await axios.post(API_URL, registrationMutation); - console.log('鎶ュ悕缁撴灉:', JSON.stringify(registrationResponse.data, null, 2)); - - } catch (error) { - console.error('娴嬭瘯澶辫触:', error.response ? error.response.data : error.message); - } -} - -testRegistration(); \ No newline at end of file diff --git a/test_registration_with_attachments.js b/test_registration_with_attachments.js deleted file mode 100644 index bae61f9..0000000 --- a/test_registration_with_attachments.js +++ /dev/null @@ -1,244 +0,0 @@ -// 娴嬭瘯瀹屾暣鐨勬姤鍚嶆祦绋嬶紝鍖呮嫭闄勪欢涓婁紶鍔熻兘 -const fs = require('fs'); -const path = require('path'); - -console.log('=== 娴嬭瘯鎶ュ悕娴佺▼锛堝寘鍚檮浠朵笂浼狅級===\n'); - -// 1. 娴嬭瘯闄勪欢涓婁紶鍔熻兘鐨勫疄鐜� -console.log('1. 妫�鏌ラ檮浠朵笂浼犲姛鑳藉疄鐜�...'); - -// 妫�鏌XML鏂囦欢 -const wxmlPath = path.join(__dirname, 'wx/pages/registration/registration.wxml'); -if (fs.existsSync(wxmlPath)) { - const wxmlContent = fs.readFileSync(wxmlPath, 'utf8'); - - const checks = [ - { name: '闄勪欢涓婁紶鍖哄煙', pattern: /attachment-upload-area/ }, - { name: '閫夋嫨鏂囦欢鎸夐挳', pattern: /onChooseAttachment/ }, - { name: '闄勪欢鍒楄〃鏄剧ず', pattern: /attachment-list/ }, - { name: '闄勪欢鍒犻櫎鍔熻兘', pattern: /onDeleteAttachment/ }, - { name: '涓婁紶杩涘害鏄剧ず', pattern: /upload-progress/ }, - { name: '鏂囦欢绫诲瀷鍥炬爣', pattern: /attachment-icon/ }, - { name: '闄勪欢鏁伴噺闄愬埗', pattern: /attachments\.length/ } - ]; - - checks.forEach(check => { - const found = check.pattern.test(wxmlContent); - console.log(` 鉁� ${check.name}: ${found ? '宸插疄鐜�' : '鉂� 鏈壘鍒�'}`); - }); -} else { - console.log(' 鉂� WXML鏂囦欢涓嶅瓨鍦�'); -} - -// 妫�鏌XSS鏂囦欢 -console.log('\n2. 妫�鏌ラ檮浠朵笂浼犳牱寮�...'); -const wxssPath = path.join(__dirname, 'wx/pages/registration/registration.wxss'); -if (fs.existsSync(wxssPath)) { - const wxssContent = fs.readFileSync(wxssPath, 'utf8'); - - const styleChecks = [ - { name: '闄勪欢涓婁紶鍖哄煙鏍峰紡', pattern: /\.attachment-upload-area/ }, - { name: '涓婁紶鎸夐挳鏍峰紡', pattern: /\.upload-btn/ }, - { name: '闄勪欢鍒楄〃鏍峰紡', pattern: /\.attachment-list/ }, - { name: '闄勪欢椤规牱寮�', pattern: /\.attachment-item/ }, - { name: '杩涘害鏉℃牱寮�', pattern: /\.progress-bar/ }, - { name: '鏂囦欢鍥炬爣鏍峰紡', pattern: /\.attachment-icon/ }, - { name: '涓婁紶鐘舵�佹牱寮�', pattern: /\.upload-status/ } - ]; - - styleChecks.forEach(check => { - const found = check.pattern.test(wxssContent); - console.log(` 鉁� ${check.name}: ${found ? '宸插疄鐜�' : '鉂� 鏈壘鍒�'}`); - }); -} else { - console.log(' 鉂� WXSS鏂囦欢涓嶅瓨鍦�'); -} - -// 妫�鏌S鏂囦欢 -console.log('\n3. 妫�鏌ラ檮浠朵笂浼犻�昏緫...'); -const jsPath = path.join(__dirname, 'wx/pages/registration/registration.js'); -if (fs.existsSync(jsPath)) { - const jsContent = fs.readFileSync(jsPath, 'utf8'); - - const logicChecks = [ - { name: '闄勪欢鏁版嵁瀛楁', pattern: /attachments:\s*\[\]/ }, - { name: '鏂囦欢绫诲瀷閰嶇疆', pattern: /fileTypeConfig/ }, - { name: '閫夋嫨闄勪欢鏂规硶', pattern: /onChooseAttachment/ }, - { name: '涓婁紶闄勪欢鏂规硶', pattern: /uploadAttachment/ }, - { name: '鍒犻櫎闄勪欢鏂规硶', pattern: /onDeleteAttachment/ }, - { name: '鏂囦欢楠岃瘉鏂规硶', pattern: /validateAttachment/ }, - { name: '鏂囦欢澶у皬鏍煎紡鍖�', pattern: /formatFileSize/ }, - { name: 'GraphQL闆嗘垚', pattern: /attachmentMediaIds/ }, - { name: '杩涘害鏇存柊閫昏緫', pattern: /onProgress/ } - ]; - - logicChecks.forEach(check => { - const found = check.pattern.test(jsContent); - console.log(` 鉁� ${check.name}: ${found ? '宸插疄鐜�' : '鉂� 鏈壘鍒�'}`); - }); -} else { - console.log(' 鉂� JS鏂囦欢涓嶅瓨鍦�'); -} - -// 4. 妯℃嫙GraphQL璇锋眰 -console.log('\n4. 妯℃嫙瀹屾暣鎶ュ悕娴佺▼鐨凣raphQL璇锋眰...'); - -const mockRegistrationData = { - activityId: 1, - playerInfo: { - name: "寮犱笁", - phone: "13800138000", - gender: 1, - birthDate: "1995-06-15", - education: "鏈", - introduction: "鎴戞槸涓�鍚嶈蒋浠跺伐绋嬪笀锛岀儹鐖辩紪绋嬪拰鍒涙柊銆�", - avatarMediaId: "avatar_12345.jpg" - }, - regionId: 1, - projectName: "鏅鸿兘瀹跺眳鎺у埗绯荤粺", - description: "鍩轰簬鐗╄仈缃戞妧鏈殑鏅鸿兘瀹跺眳瑙e喅鏂规", - attachmentMediaIds: [ - "attachment_video_001.mp4", - "attachment_doc_002.pdf", - "attachment_image_003.jpg" - ] -}; - -const mockMutation = ` -mutation SubmitActivityRegistration($input: ActivityRegistrationInput!) { - submitActivityRegistration(input: $input) { - success - message - registrationId - } -} -`; - -console.log('GraphQL Mutation:'); -console.log(mockMutation); -console.log('\n杈撳叆鏁版嵁:'); -console.log(JSON.stringify(mockRegistrationData, null, 2)); - -// 5. 楠岃瘉鏂囦欢绫诲瀷鏀寔 -console.log('\n5. 楠岃瘉鏀寔鐨勬枃浠剁被鍨�...'); - -const supportedTypes = { - '鍥剧墖鏂囦欢': ['jpg', 'jpeg', 'png', 'gif', 'webp'], - '瑙嗛鏂囦欢': ['mp4', 'avi', 'mov', 'wmv', 'flv', '3gp'], - 'PDF鏂囨。': ['pdf'], - 'Word鏂囨。': ['doc', 'docx'], - 'Excel鏂囨。': ['xls', 'xlsx'], - 'PPT鏂囨。': ['ppt', 'pptx'], - '鏂囨湰鏂囦欢': ['txt'] -}; - -Object.entries(supportedTypes).forEach(([type, extensions]) => { - console.log(` 鉁� ${type}: ${extensions.join(', ')}`); -}); - -// 6. 楠岃瘉鏂囦欢澶у皬闄愬埗 -console.log('\n6. 楠岃瘉鏂囦欢澶у皬闄愬埗...'); - -const sizeLimit = { - '鍥剧墖鏂囦欢': '10MB', - '瑙嗛鏂囦欢': '200MB', - 'PDF鏂囨。': '50MB', - 'Word鏂囨。': '50MB', - 'Excel鏂囨。': '50MB', - 'PPT鏂囨。': '50MB', - '鏂囨湰鏂囦欢': '10MB' -}; - -Object.entries(sizeLimit).forEach(([type, limit]) => { - console.log(` 鉁� ${type}: 鏈�澶�${limit}`); -}); - -// 7. 妫�鏌ユ祴璇曟枃浠� -console.log('\n7. 妫�鏌ュ彲鐢ㄧ殑娴嬭瘯鏂囦欢...'); - -const testFiles = [ - { path: 'tmp/C1.jpg', type: '鍥剧墖', size: '鏈煡' }, - { path: 'tmp/a.png', type: '鍥剧墖', size: '鏈煡' }, - { path: 'tmp/a2.png', type: '鍥剧墖', size: '鏈煡' }, - { path: 'tmp/rang.png', type: '鍥剧墖', size: '鏈煡' } -]; - -testFiles.forEach(file => { - const filePath = path.join(__dirname, file.path); - if (fs.existsSync(filePath)) { - const stats = fs.statSync(filePath); - const sizeInMB = (stats.size / (1024 * 1024)).toFixed(2); - console.log(` 鉁� ${file.path}: ${file.type}鏂囦欢, ${sizeInMB}MB`); - } else { - console.log(` 鉂� ${file.path}: 鏂囦欢涓嶅瓨鍦╜); - } -}); - -// 8. 鏁版嵁搴撳瓨鍌ㄩ獙璇� -console.log('\n8. 鏁版嵁搴撳瓨鍌ㄩ獙璇�...'); - -const expectedTables = [ - { - table: 't_user', - fields: ['id', 'name', 'phone', 'gender', 'birth_date', 'education', 'avatar_media_id', 'created_at'] - }, - { - table: 't_player', - fields: ['id', 'user_id', 'introduction', 'created_at'] - }, - { - table: 't_activity_player', - fields: ['id', 'activity_id', 'player_id', 'region_id', 'project_name', 'description', 'status', 'created_at'] - }, - { - table: 't_media', - fields: ['id', 'media_id', 'file_name', 'file_type', 'file_size', 'url', 'related_type', 'related_id', 'created_at'] - } -]; - -expectedTables.forEach(table => { - console.log(` 鉁� ${table.table}琛�:`); - table.fields.forEach(field => { - console.log(` - ${field}`); - }); -}); - -console.log('\n=== 闄勪欢涓婁紶鍔熻兘瀹炵幇鎬荤粨 ==='); - -const features = [ - '鉁� 鏀寔澶氱鏂囦欢绫诲瀷锛堝浘鐗囥�佽棰戙�丳DF銆乄ord銆丒xcel銆丳PT銆佹枃鏈級', - '鉁� 鏂囦欢澶у皬楠岃瘉锛堝浘鐗�10MB銆佽棰�200MB銆佹枃妗�50MB锛�', - '鉁� 鏈�澶氫笂浼�8涓檮浠�', - '鉁� 瀹炴椂涓婁紶杩涘害鏄剧ず', - '鉁� 鏂囦欢绫诲瀷鍥炬爣鏄剧ず', - '鉁� 涓婁紶鐘舵�佺鐞嗭紙涓婁紶涓�佹垚鍔熴�佸け璐ワ級', - '鉁� 闄勪欢鍒犻櫎鍔熻兘', - '鉁� 閿欒澶勭悊鍜岀敤鎴锋彁绀�', - '鉁� COS浜戝瓨鍌ㄩ泦鎴�', - '鉁� GraphQL鏁版嵁鎻愪氦', - '鉁� 鏁版嵁搴撳瓨鍌ㄦ敮鎸�' -]; - -features.forEach(feature => { - console.log(feature); -}); - -console.log('\n=== 娴嬭瘯寤鸿 ==='); - -const testSuggestions = [ - '1. 鍦ㄥ井淇″紑鍙戣�呭伐鍏蜂腑娴嬭瘯鏂囦欢閫夋嫨鍔熻兘', - '2. 娴嬭瘯涓嶅悓鏂囦欢绫诲瀷鐨勪笂浼�', - '3. 娴嬭瘯鏂囦欢澶у皬闄愬埗楠岃瘉', - '4. 娴嬭瘯涓婁紶杩涘害鏄剧ず', - '5. 娴嬭瘯闄勪欢鍒犻櫎鍔熻兘', - '6. 娴嬭瘯鏈�澶ч檮浠舵暟閲忛檺鍒�', - '7. 娴嬭瘯缃戠粶寮傚父鎯呭喌涓嬬殑閿欒澶勭悊', - '8. 楠岃瘉鍚庣鏁版嵁搴撲腑鐨勬暟鎹瓨鍌�', - '9. 娴嬭瘯瀹屾暣鐨勬姤鍚嶆祦绋嬫彁浜�' -]; - -testSuggestions.forEach(suggestion => { - console.log(suggestion); -}); - -console.log('\n鉁� 闄勪欢涓婁紶鍔熻兘宸插畬鏁村疄鐜帮紒'); \ No newline at end of file diff --git a/test_registration_with_birthdate.js b/test_registration_with_birthdate.js deleted file mode 100644 index b799dbe..0000000 --- a/test_registration_with_birthdate.js +++ /dev/null @@ -1,130 +0,0 @@ -const axios = require('axios'); - -// GraphQL endpoint -const GRAPHQL_URL = 'http://localhost:8080/api/graphql'; - -// 娴嬭瘯鎶ュ悕鍔熻兘锛屽寘鍚敓鏃ュ瓧娈� -async function testRegistrationWithBirthDate() { - console.log('寮�濮嬫祴璇曞寘鍚敓鏃ュ瓧娈电殑鎶ュ悕鍔熻兘...'); - - const mutation = ` - mutation SubmitActivityRegistration($input: ActivityRegistrationInput!) { - submitActivityRegistration(input: $input) { - success - message - registrationId - } - } - `; - - const variables = { - input: { - activityId: "1", - playerInfo: { - name: "鏉庡洓", - phone: "13900139000", - gender: 0, - birthDate: "1992-08-20", - education: "纭曞+", - introduction: "鎴戞槸涓�鍚嶆柊鐨勬祴璇曠敤鎴�" - }, - regionId: "1", - projectName: "AI鏅鸿兘椤圭洰", - description: "杩欐槸涓�涓柊鐨勬祴璇曟姤鍚�" - } -}; - - try { - const response = await axios.post(GRAPHQL_URL, { - query: mutation, - variables: variables - }, { - headers: { - 'Content-Type': 'application/json' - } - }); - - console.log('鍝嶅簲鐘舵��:', response.status); - console.log('鍝嶅簲鏁版嵁:', JSON.stringify(response.data, null, 2)); - - if (response.data.data && response.data.data.submitActivityRegistration) { - const result = response.data.data.submitActivityRegistration; - if (result.success) { - console.log('鉁� 鎶ュ悕鎴愬姛锛�'); - console.log('鎶ュ悕ID:', result.registrationId); - - // 楠岃瘉鏁版嵁鏄惁姝g‘淇濆瓨 - await verifyRegistrationData(result.registrationId); - } else { - console.log('鉂� 鎶ュ悕澶辫触:', result.message); - } - } else { - console.log('鉂� 鍝嶅簲鏍煎紡閿欒'); - } - - } catch (error) { - console.error('鉂� 璇锋眰澶辫触:', error.message); - if (error.response) { - console.error('閿欒鍝嶅簲:', error.response.data); - } - } -} - -// 楠岃瘉鎶ュ悕鏁版嵁鏄惁姝g‘淇濆瓨 -async function verifyRegistrationData(registrationId) { - console.log('\n楠岃瘉鎶ュ悕鏁版嵁...'); - - const query = ` - query GetActivityPlayerDetail($id: ID!) { - activityPlayerDetail(id: $id) { - id - playerInfo { - id - name - phone - description - } - regionInfo { - id - name - } - activityName - description - } - } - `; - - try { - const response = await axios.post(GRAPHQL_URL, { - query: query, - variables: { id: registrationId } - }, { - headers: { - 'Content-Type': 'application/json' - } - }); - - if (response.data.data && response.data.data.activityPlayerDetail) { - const detail = response.data.data.activityPlayerDetail; - console.log('鉁� 鎴愬姛鑾峰彇鎶ュ悕鏁版嵁:'); - console.log(`- 濮撳悕: ${detail.playerInfo.name}`); - console.log(`- 鐢佃瘽: ${detail.playerInfo.phone}`); - console.log(`- 娲诲姩鍚嶇О: ${detail.activityName}`); - console.log(`- 鎻忚堪: ${detail.description}`); - - if (detail.regionInfo) { - console.log(`- 鍖哄煙: ${detail.regionInfo.name}`); - } - - console.log('鉁� 鎶ュ悕鏁版嵁宸叉纭繚瀛�'); - } else { - console.log('鉂� 鏃犳硶鑾峰彇鎶ュ悕鏁版嵁'); - } - - } catch (error) { - console.error('鉂� 楠岃瘉鏁版嵁澶辫触:', error.message); - } -} - -// 杩愯娴嬭瘯 -testRegistrationWithBirthDate(); \ No newline at end of file diff --git a/test_sessionkey_fix.js b/test_sessionkey_fix.js deleted file mode 100644 index 5501bc8..0000000 --- a/test_sessionkey_fix.js +++ /dev/null @@ -1,134 +0,0 @@ -const axios = require('axios'); - -console.log('=== 娴嬭瘯sessionKey淇鏁堟灉 ==='); - -async function testSessionKeyFix() { - try { - // 1. 娴嬭瘯鍚庣wxLogin鎺ュ彛 - console.log('\n1. 娴嬭瘯鍚庣wxLogin鎺ュ彛...'); - const loginResponse = await axios.post('http://localhost:8080/api/graphql', { - query: ` - mutation { - wxLogin(input: { - code: "test_code_${Date.now()}", - loginIp: "192.168.1.100", - deviceInfo: "Test Device - sessionKey Fix Test" - }) { - token - userInfo { - userId - name - phone - } - isNewUser - loginRecordId - sessionKey - } - } - ` - }, { - headers: { - 'Content-Type': 'application/json' - } - }); - - if (loginResponse.status === 200 && loginResponse.data.data && loginResponse.data.data.wxLogin) { - const loginResult = loginResponse.data.data.wxLogin; - console.log('鉁� 鍚庣wxLogin鎺ュ彛姝e父'); - console.log('- Token闀垮害:', loginResult.token ? loginResult.token.length : 0); - console.log('- SessionKey瀛樺湪:', !!loginResult.sessionKey); - console.log('- SessionKey闀垮害:', loginResult.sessionKey ? loginResult.sessionKey.length : 0); - - // 2. 妯℃嫙灏忕▼搴忕瀛樺偍閫昏緫 - console.log('\n2. 妯℃嫙灏忕▼搴忕瀛樺偍閫昏緫...'); - const mockStorage = {}; - const mockGlobalData = { - userInfo: null, - token: null, - sessionKey: null // 杩欐槸鎴戜滑淇鐨勫叧閿偣 - }; - - // 妯℃嫙wx.setStorageSync - function mockSetStorageSync(key, value) { - mockStorage[key] = value; - console.log(`瀛樺偍 ${key}:`, typeof value === 'string' ? `${value.substring(0, 10)}...` : value); - } - - // 妯℃嫙wx.getStorageSync - function mockGetStorageSync(key) { - return mockStorage[key]; - } - - // 妯℃嫙鐧诲綍鎴愬姛鍚庣殑瀛樺偍閫昏緫 - mockSetStorageSync('token', loginResult.token); - mockSetStorageSync('userInfo', loginResult.userInfo); - if (loginResult.sessionKey) { - mockSetStorageSync('sessionKey', loginResult.sessionKey); - } - - // 妯℃嫙璁剧疆globalData - mockGlobalData.token = loginResult.token; - mockGlobalData.userInfo = loginResult.userInfo; - mockGlobalData.sessionKey = loginResult.sessionKey; - - console.log('鉁� 瀛樺偍閫昏緫瀹屾垚'); - - // 3. 妯℃嫙checkLoginStatus閫昏緫 - console.log('\n3. 妯℃嫙checkLoginStatus閫昏緫...'); - const storedToken = mockGetStorageSync('token'); - const storedUserInfo = mockGetStorageSync('userInfo'); - const storedSessionKey = mockGetStorageSync('sessionKey'); - - console.log('浠庡瓨鍌ㄤ腑璇诲彇:'); - console.log('- Token瀛樺湪:', !!storedToken); - console.log('- UserInfo瀛樺湪:', !!storedUserInfo); - console.log('- SessionKey瀛樺湪:', !!storedSessionKey); - console.log('- SessionKey闀垮害:', storedSessionKey ? storedSessionKey.length : 0); - - if (storedToken && storedUserInfo) { - mockGlobalData.token = storedToken; - mockGlobalData.userInfo = storedUserInfo; - mockGlobalData.sessionKey = storedSessionKey; - console.log('鉁� 鐧诲綍鐘舵�佹仮澶嶆垚鍔�'); - } - - // 4. 妯℃嫙鎵嬫満鍙疯В瀵嗘鏌� - console.log('\n4. 妯℃嫙鎵嬫満鍙疯В瀵嗘鏌�...'); - console.log('globalData.sessionKey瀛樺湪:', !!mockGlobalData.sessionKey); - console.log('globalData.sessionKey闀垮害:', mockGlobalData.sessionKey ? mockGlobalData.sessionKey.length : 0); - - if (!mockGlobalData.sessionKey) { - console.log('鉂� sessionKey涓虹┖锛屾棤娉曡В瀵嗘墜鏈哄彿'); - return false; - } else { - console.log('鉁� sessionKey姝e父锛屽彲浠ヨ繘琛屾墜鏈哄彿瑙e瘑'); - return true; - } - - } else { - console.log('鉂� 鍚庣wxLogin鎺ュ彛寮傚父'); - console.log('鍝嶅簲:', loginResponse.data); - return false; - } - - } catch (error) { - console.error('鉂� 娴嬭瘯杩囩▼涓彂鐢熼敊璇�:', error.message); - if (error.response) { - console.error('鍝嶅簲鐘舵��:', error.response.status); - console.error('鍝嶅簲鏁版嵁:', error.response.data); - } - return false; - } -} - -// 杩愯娴嬭瘯 -testSessionKeyFix().then(success => { - if (success) { - console.log('\n馃帀 sessionKey淇楠岃瘉鎴愬姛锛�'); - console.log('鐜板湪灏忕▼搴忕搴旇鑳藉姝e父鑾峰彇鍜屼娇鐢╯essionKey杩涜鎵嬫満鍙疯В瀵嗕簡銆�'); - } else { - console.log('\n鉂� sessionKey淇楠岃瘉澶辫触锛岄渶瑕佽繘涓�姝ユ鏌ャ��'); - } -}).catch(err => { - console.error('娴嬭瘯鎵ц澶辫触:', err); -}); \ No newline at end of file diff --git a/test_verify_registration.js b/test_verify_registration.js deleted file mode 100644 index 6fdd1ef..0000000 --- a/test_verify_registration.js +++ /dev/null @@ -1,92 +0,0 @@ -// 浣跨敤鍐呯疆鐨刦etch API (Node.js 18+) - -const GRAPHQL_URL = 'http://localhost:8080/api/graphql'; - -// 鏌ヨ鏈�鏂扮殑鎶ュ悕璁板綍 -async function verifyRegistration() { - console.log('楠岃瘉鏈�鏂扮殑鎶ュ悕璁板綍...'); - - const query = ` - query { - activities { - id - name - description - } - } - `; - - try { - const response = await fetch(GRAPHQL_URL, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ query }) - }); - - const result = await response.json(); - console.log('娲诲姩鍒楄〃鏌ヨ鎴愬姛'); - - // 鏌ヨ娲诲姩娉ㄥ唽鐢宠璁板綍 - const registrationQuery = ` - query { - activityPlayerApplications(activityId: 55, page: 0, size: 10) { - id - playerName - activityName - phone - applyTime - state - } - } - `; - - console.log('\n鏌ヨ娲诲姩55鐨勬敞鍐岀敵璇疯褰�...'); - const registrationResponse = await fetch(GRAPHQL_URL, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - query: registrationQuery - }) - }); - - const registrationData = await registrationResponse.json(); - console.log('娉ㄥ唽鐢宠璁板綍鏌ヨ缁撴灉:', JSON.stringify(registrationData, null, 2)); - - if (registrationData.data && registrationData.data.activityPlayerApplications) { - const applications = registrationData.data.activityPlayerApplications; - console.log(`\n鎵惧埌 ${applications.length} 涓敞鍐岀敵璇疯褰�:`); - - applications.forEach((app, index) => { - console.log(`\n鐢宠璁板綍 ${index + 1}:`); - console.log(` ID: ${app.id}`); - console.log(` 閫夋墜濮撳悕: ${app.playerName}`); - console.log(` 娲诲姩鍚嶇О: ${app.activityName}`); - console.log(` 鑱旂郴鐢佃瘽: ${app.phone}`); - console.log(` 鐢宠鏃堕棿: ${app.applyTime}`); - console.log(` 鐘舵��: ${app.state}`); - }); - - // 鏄剧ず鏈�鏂扮殑娉ㄥ唽璁板綍 - if (applications.length > 0) { - const latestApp = applications[applications.length - 1]; - console.log(`\n鏈�鏂扮敵璇疯褰曡鎯�:`); - console.log(` 鐢宠ID: ${latestApp.id}`); - console.log(` 閫夋墜濮撳悕: ${latestApp.playerName}`); - console.log(` 鑱旂郴鐢佃瘽: ${latestApp.phone}`); - console.log(` 鐢宠鏃堕棿: ${latestApp.applyTime}`); - console.log(` 鐘舵��: ${latestApp.state} (1=寰呭鏍�, 2=杩涜涓�, 3=缁撴潫)`); - } - } else { - console.log('鏈壘鍒版敞鍐岀敵璇疯褰曟垨鏌ヨ澶辫触'); - } - - } catch (error) { - console.error('楠岃瘉澶辫触:', error); - } -} - -verifyRegistration(); \ No newline at end of file diff --git a/test_wechat_api_direct.js b/test_wechat_api_direct.js deleted file mode 100644 index aa3ef39..0000000 --- a/test_wechat_api_direct.js +++ /dev/null @@ -1,139 +0,0 @@ -const axios = require('axios'); - -async function testWechatApiDirect() { - console.log('馃攳 鐩存帴娴嬭瘯寰俊API璋冪敤'); - console.log('='.repeat(50)); - - // 寰俊灏忕▼搴忛厤缃紙浠巃pplication.yml涓幏鍙栵級 - const appId = 'wxaa13026a14b1d784'; - const appSecret = 'b7a7acc1063a83b9cd3173fb08919f84'; - - console.log('1锔忊儯 娴嬭瘯鑾峰彇access_token'); - try { - const tokenUrl = `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${appId}&secret=${appSecret}`; - console.log('璇锋眰URL:', tokenUrl.replace(appSecret, '***')); - - const tokenResponse = await axios.get(tokenUrl, { timeout: 10000 }); - console.log('access_token鍝嶅簲:', tokenResponse.data); - - if (tokenResponse.data.errcode) { - console.log('鉂� 鑾峰彇access_token澶辫触:'); - console.log('閿欒鐮�:', tokenResponse.data.errcode); - console.log('閿欒淇℃伅:', tokenResponse.data.errmsg); - - // 甯歌閿欒鐮佽В閲� - const errorCodes = { - 40013: 'AppID鏃犳晥', - 40001: 'AppSecret閿欒', - 40002: '涓嶅悎娉曠殑鍑瘉绫诲瀷', - 40164: 'IP鍦板潃涓嶅湪鐧藉悕鍗曚腑', - 45009: '鎺ュ彛璋冪敤瓒呰繃闄愬埗', - 89503: '姝P璋冪敤闇�瑕佺鐞嗗憳纭' - }; - - if (errorCodes[tokenResponse.data.errcode]) { - console.log('閿欒瑙i噴:', errorCodes[tokenResponse.data.errcode]); - } - - return; - } - - const accessToken = tokenResponse.data.access_token; - console.log('鉁� 鎴愬姛鑾峰彇access_token:', accessToken.substring(0, 20) + '...'); - - // 娴嬭瘯鑾峰彇鎵嬫満鍙稟PI - console.log('\n2锔忊儯 娴嬭瘯鑾峰彇鎵嬫満鍙稟PI'); - const phoneUrl = 'https://api.weixin.qq.com/wxa/business/getuserphonenumber'; - const phoneData = { - code: 'test_code_123' - }; - - try { - const phoneResponse = await axios.post( - `${phoneUrl}?access_token=${accessToken}`, - phoneData, - { - headers: { 'Content-Type': 'application/json' }, - timeout: 10000 - } - ); - - console.log('鎵嬫満鍙稟PI鍝嶅簲:', phoneResponse.data); - - if (phoneResponse.data.errcode) { - console.log('鉂� 鑾峰彇鎵嬫満鍙峰け璐�:'); - console.log('閿欒鐮�:', phoneResponse.data.errcode); - console.log('閿欒淇℃伅:', phoneResponse.data.errmsg); - - // 鎵嬫満鍙稟PI甯歌閿欒鐮� - const phoneErrorCodes = { - 40001: 'access_token鏃犳晥', - 40003: 'openid閿欒', - 47001: 'POST鏁版嵁鍙傛暟涓嶅悎娉�', - 40013: 'AppID鏃犳晥', - 61023: 'code鏃犳晥鎴栧凡杩囨湡', - 61024: 'code宸茶浣跨敤' - }; - - if (phoneErrorCodes[phoneResponse.data.errcode]) { - console.log('閿欒瑙i噴:', phoneErrorCodes[phoneResponse.data.errcode]); - } - } else { - console.log('鉁� 鎵嬫満鍙稟PI璋冪敤鎴愬姛锛堣櫧鐒禼ode鏃犳晥锛�'); - } - - } catch (phoneError) { - console.log('鉂� 鎵嬫満鍙稟PI璇锋眰寮傚父:', phoneError.message); - if (phoneError.response) { - console.log('鍝嶅簲鐘舵��:', phoneError.response.status); - console.log('鍝嶅簲鏁版嵁:', phoneError.response.data); - } - } - - } catch (error) { - console.log('鉂� 鑾峰彇access_token寮傚父:', error.message); - if (error.response) { - console.log('鍝嶅簲鐘舵��:', error.response.status); - console.log('鍝嶅簲鏁版嵁:', error.response.data); - } - - if (error.code === 'ENOTFOUND') { - console.log('馃寪 缃戠粶杩炴帴闂锛氭棤娉曡В鏋愬井淇PI鍩熷悕'); - } else if (error.code === 'ETIMEDOUT') { - console.log('鈴� 缃戠粶瓒呮椂锛氳妫�鏌ョ綉缁滆繛鎺�'); - } - } - - console.log('\n3锔忊儯 娴嬭瘯code2session API'); - try { - const sessionUrl = `https://api.weixin.qq.com/sns/jscode2session?appid=${appId}&secret=${appSecret}&js_code=test_code&grant_type=authorization_code`; - console.log('璇锋眰URL:', sessionUrl.replace(appSecret, '***')); - - const sessionResponse = await axios.get(sessionUrl, { timeout: 10000 }); - console.log('code2session鍝嶅簲:', sessionResponse.data); - - if (sessionResponse.data.errcode) { - console.log('鉂� code2session澶辫触:'); - console.log('閿欒鐮�:', sessionResponse.data.errcode); - console.log('閿欒淇℃伅:', sessionResponse.data.errmsg); - } else { - console.log('鉁� code2session API鍙闂紙铏界劧code鏃犳晥锛�'); - } - - } catch (sessionError) { - console.log('鉂� code2session寮傚父:', sessionError.message); - } - - console.log('\n馃敡 璇婃柇缁撴灉:'); - console.log('濡傛灉鎵�鏈堿PI閮借繑鍥炵綉缁滈敊璇紝鍙兘鐨勫師鍥狅細'); - console.log('1. 缃戠粶杩炴帴闂'); - console.log('2. 闃茬伀澧欓樆姝簡瀵瑰井淇PI鐨勮闂�'); - console.log('3. DNS瑙f瀽闂'); - console.log('4. 浠g悊璁剧疆闂'); - console.log('\n濡傛灉API鍙闂絾杩斿洖閿欒鐮侊紝鍙兘鐨勫師鍥狅細'); - console.log('1. AppID鎴朅ppSecret閰嶇疆閿欒'); - console.log('2. IP鍦板潃涓嶅湪寰俊鐧藉悕鍗曚腑'); - console.log('3. 鎺ュ彛璋冪敤棰戠巼瓒呴檺'); -} - -testWechatApiDirect().catch(console.error); \ No newline at end of file diff --git a/test_wx_login.js b/test_wx_login.js deleted file mode 100644 index 107fa2c..0000000 --- a/test_wx_login.js +++ /dev/null @@ -1,78 +0,0 @@ -const axios = require('axios'); - -async function testWxLogin() { - console.log('=== 娴嬭瘯寰俊鐧诲綍鎺ュ彛 ==='); - - const graphqlEndpoint = 'http://localhost:8080/api/graphql'; - - // 娴嬭瘯寰俊鐧诲綍鐨凣raphQL鏌ヨ - const wxLoginQuery = ` - mutation { - wxLogin(input: { - code: "test_code_123", - loginIp: "192.168.1.100", - deviceInfo: "Test Device" - }) { - token - userInfo { - userId - name - phone - } - isNewUser - loginRecordId - sessionKey - } - } - `; - - try { - console.log('鍙戦�佸井淇$櫥褰曡姹�...'); - - const response = await axios.post(graphqlEndpoint, { - query: wxLoginQuery - }, { - headers: { - 'Content-Type': 'application/json' - } - }); - - console.log('鍝嶅簲鐘舵��:', response.status); - - if (response.data.errors) { - console.log('鉂� GraphQL閿欒:'); - response.data.errors.forEach(error => { - console.log(' -', error.message); - }); - } - - if (response.data.data && response.data.data.wxLogin) { - const loginResult = response.data.data.wxLogin; - console.log('鉁� 寰俊鐧诲綍鎴愬姛!'); - console.log('- Token闀垮害:', loginResult.token ? loginResult.token.length : 0); - console.log('- 鐢ㄦ埛ID:', loginResult.userInfo?.userId); - console.log('- 鐢ㄦ埛鍚�:', loginResult.userInfo?.name); - console.log('- 鏄惁鏂扮敤鎴�:', loginResult.isNewUser); - console.log('- 鐧诲綍璁板綍ID:', loginResult.loginRecordId); - console.log('- SessionKey:', loginResult.sessionKey ? `瀛樺湪(闀垮害: ${loginResult.sessionKey.length})` : '鉂� 涓嶅瓨鍦�'); - - if (loginResult.sessionKey) { - console.log('鉁� SessionKey姝g‘杩斿洖'); - } else { - console.log('鉂� SessionKey鏈繑鍥烇紝杩欐槸闂鎵�鍦紒'); - } - } - - } catch (error) { - console.log('鉂� 璇锋眰澶辫触:'); - if (error.response) { - console.log('鐘舵�佺爜:', error.response.status); - console.log('鍝嶅簲鏁版嵁:', JSON.stringify(error.response.data, null, 2)); - } else { - console.log('閿欒淇℃伅:', error.message); - } - } -} - -// 杩愯娴嬭瘯 -testWxLogin().catch(console.error); \ No newline at end of file diff --git a/test_wx_regions.js b/test_wx_regions.js deleted file mode 100644 index 7dd3c24..0000000 --- a/test_wx_regions.js +++ /dev/null @@ -1,86 +0,0 @@ -// 娴嬭瘯灏忕▼搴忕鍖哄煙鏁版嵁鍔犺浇 -const http = require('http'); - -console.log('=== 娴嬭瘯灏忕▼搴忕鍖哄煙鏁版嵁鍔犺浇 ===\n'); - -// 妯℃嫙灏忕▼搴忕殑GraphQL璇锋眰 -const query = ` - query { - allRegions { - id - name - pid - leafFlag - } - } -`; - -const requestData = { - query: query, - variables: {} -}; - -const options = { - hostname: 'localhost', - port: 8080, - path: '/api/graphql', - method: 'POST', - headers: { - 'Content-Type': 'application/json', - 'Content-Length': Buffer.byteLength(JSON.stringify(requestData)) - } -}; - -console.log('璇锋眰閰嶇疆:', options); -console.log('璇锋眰鏁版嵁:', JSON.stringify(requestData, null, 2)); - -const req = http.request(options, (res) => { - let data = ''; - - console.log(`鍝嶅簲鐘舵�佺爜: ${res.statusCode}`); - console.log(`鍝嶅簲澶�:`, res.headers); - - res.on('data', (chunk) => { - data += chunk; - }); - - res.on('end', () => { - try { - const response = JSON.parse(data); - console.log('\n=== 鍝嶅簲鏁版嵁 ==='); - console.log(JSON.stringify(response, null, 2)); - - if (response.data && response.data.allRegions) { - const allRegions = response.data.allRegions; - const leafRegions = allRegions.filter(region => region.leafFlag === true); - - console.log('\n=== 鏁版嵁鍒嗘瀽 ==='); - console.log(`鎬诲尯鍩熸暟閲�: ${allRegions.length}`); - console.log(`鍙跺瓙鑺傜偣鍖哄煙鏁伴噺: ${leafRegions.length}`); - - console.log('\n=== 鍙跺瓙鑺傜偣鍖哄煙鍒楄〃 ==='); - leafRegions.forEach((region, index) => { - console.log(`${index + 1}. ${region.name} (ID: ${region.id}, PID: ${region.pid})`); - }); - - if (leafRegions.length === 0) { - console.log('鉂� 娌℃湁鎵惧埌鍙跺瓙鑺傜偣鍖哄煙锛�'); - } else { - console.log(`鉁� 鎵惧埌 ${leafRegions.length} 涓彾瀛愯妭鐐瑰尯鍩焋); - } - } else { - console.log('鉂� 鍝嶅簲涓病鏈夊尯鍩熸暟鎹�'); - } - } catch (error) { - console.log('鉂� 瑙f瀽鍝嶅簲澶辫触:', error.message); - console.log('鍘熷鍝嶅簲:', data); - } - }); -}); - -req.on('error', (error) => { - console.log('鉂� 璇锋眰澶辫触:', error.message); -}); - -req.write(JSON.stringify(requestData)); -req.end(); \ No newline at end of file diff --git a/test_wx_regions_fixed.js b/test_wx_regions_fixed.js deleted file mode 100644 index e988d13..0000000 --- a/test_wx_regions_fixed.js +++ /dev/null @@ -1,114 +0,0 @@ -// 娴嬭瘯灏忕▼搴忕鍖哄煙鏁版嵁鍔犺浇锛堜慨澶嶅悗锛� -const http = require('http'); - -// 妯℃嫙灏忕▼搴忕鐨凣raphQL璇锋眰 -function graphqlRequest(query, variables = {}) { - return new Promise((resolve, reject) => { - const data = JSON.stringify({ - query: query, - variables: variables - }); - - const options = { - hostname: 'localhost', - port: 8080, - path: '/api/graphql', - method: 'POST', - headers: { - 'Content-Type': 'application/json', - 'Content-Length': Buffer.byteLength(data) - } - }; - - const req = http.request(options, (res) => { - let body = ''; - res.on('data', (chunk) => { - body += chunk; - }); - res.on('end', () => { - try { - const response = JSON.parse(body); - console.log('馃搳 GraphQL鍝嶅簲:', JSON.stringify(response, null, 2)); - - if (response.errors) { - console.error('鉂� GraphQL閿欒:', response.errors); - reject(response.errors); - } else if (response.data) { - resolve(response.data); - } else { - console.error('鉂� GraphQL鍝嶅簲寮傚父:', response); - reject('璇锋眰澶辫触'); - } - } catch (error) { - console.error('鉂� 瑙f瀽鍝嶅簲澶辫触:', error); - reject(error); - } - }); - }); - - req.on('error', (error) => { - console.error('鉂� 璇锋眰澶辫触:', error); - reject(error); - }); - - req.write(data); - req.end(); - }); -} - -// 妯℃嫙loadRegions鏂规硶 -async function loadRegions() { - try { - console.log('馃攧 寮�濮嬪姞杞藉尯鍩熸暟鎹�...'); - const query = ` - query { - allRegions { - id - name - pid - leafFlag - } - } - `; - - const result = await graphqlRequest(query); - console.log('馃搳 鍖哄煙鏁版嵁鏌ヨ缁撴灉:', result); - - if (result && result.allRegions) { - console.log(`馃搷 鎬诲尯鍩熸暟閲�: ${result.allRegions.length}`); - - // 鏄剧ず鍓�5涓尯鍩熺殑leafFlag绫诲瀷鍜屽�� - console.log('馃攳 鍓�5涓尯鍩熺殑leafFlag璇︽儏:'); - result.allRegions.slice(0, 5).forEach(region => { - console.log(` - ${region.name}: leafFlag=${region.leafFlag} (绫诲瀷: ${typeof region.leafFlag})`); - }); - - // 鍙樉绀簂eaf_flag=true鐨勫尯鍩燂紙鍙跺瓙鑺傜偣鍖哄煙锛� - const leafRegions = result.allRegions.filter(region => region.leafFlag === true); - console.log(`馃崈 鍙跺瓙鑺傜偣鍖哄煙鏁伴噺: ${leafRegions.length}`); - console.log('馃崈 鍙跺瓙鑺傜偣鍖哄煙鍒楄〃:', leafRegions.map(r => `${r.name}(${r.id})`)); - - console.log('鉁� 鍖哄煙鏁版嵁璁剧疆瀹屾垚'); - return leafRegions; - } else { - console.warn('鈿狅笍 鏈幏鍙栧埌鍖哄煙鏁版嵁'); - return []; - } - } catch (error) { - console.error('鉂� 鍔犺浇鍖哄煙鏁版嵁澶辫触:', error); - return []; - } -} - -// 鎵ц娴嬭瘯 -loadRegions().then(regions => { - console.log('\n馃幆 娴嬭瘯缁撴灉:'); - console.log(`- 鎴愬姛鑾峰彇 ${regions.length} 涓彾瀛愯妭鐐瑰尯鍩焋); - if (regions.length > 0) { - console.log('鉁� 鍖哄煙鏁版嵁鍔犺浇姝e父锛�'); - } else { - console.log('鉂� 鍖哄煙鏁版嵁鍔犺浇澶辫触锛�'); - } -}).catch(error => { - console.error('鉂� 娴嬭瘯澶辫触:', error); -}); \ No newline at end of file -- Gitblit v1.8.0