{ "info": { "_postman_id": "rmdc-api-collection-2026", "name": "RMDC API Collection", "description": "RMDC系统API测试集合\n\n## 使用说明\n\n1. 导入此Collection后,首先运行 `Auth > 1. 获取RSA公钥` 请求\n2. 然后运行 `Auth > 2. RSA加密登录` 请求\n3. 登录成功后Token会自动保存,其他请求无需手动配置认证\n\n## 环境变量\n- `baseUrl`: API基础地址,默认 http://localhost:8080\n- `username`: 登录用户名\n- `password`: 登录密码", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "auth": { "type": "bearer", "bearer": [ { "key": "token", "value": "{{token}}", "type": "string" } ] }, "event": [ { "listen": "prerequest", "script": { "type": "text/javascript", "exec": [ "// Collection级别的预处理脚本", "// 自动检查token是否存在" ] } }, { "listen": "test", "script": { "type": "text/javascript", "exec": [ "// Collection级别的测试脚本" ] } } ], "variable": [ { "key": "baseUrl", "value": "http://localhost:8080", "type": "string" }, { "key": "username", "value": "admin", "type": "string" }, { "key": "password", "value": "supercyy.1", "type": "string" }, { "key": "token", "value": "", "type": "string" }, { "key": "rsaPublicKey", "value": "", "type": "string" } ], "item": [ { "name": "Auth", "description": "认证相关接口", "item": [ { "name": "1. 获取RSA公钥", "event": [ { "listen": "test", "script": { "exec": [ "pm.test('获取公钥成功', function () {", " pm.response.to.have.status(200);", "});", "", "var jsonData = pm.response.json();", "if (jsonData.public_key) {", " pm.collectionVariables.set('rsaPublicKey', jsonData.public_key);", " console.log('RSA公钥已保存');", "}" ], "type": "text/javascript" } } ], "request": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/api/auth/rsa/public-key", "host": [ "{{baseUrl}}" ], "path": [ "api", "auth", "rsa", "public-key" ] } } }, { "name": "2. RSA加密登录", "event": [ { "listen": "prerequest", "script": { "exec": [ "// RSA加密函数 (使用PKCS1v15填充)", "const forge = require('node-forge');", "", "const publicKeyPem = pm.collectionVariables.get('rsaPublicKey');", "const password = pm.collectionVariables.get('password');", "", "if (!publicKeyPem) {", " console.error('请先运行\"获取RSA公钥\"请求');", " throw new Error('RSA公钥未获取');", "}", "", "try {", " // 解析PEM格式的公钥", " const publicKey = forge.pki.publicKeyFromPem(publicKeyPem);", " ", " // 使用RSA-OAEP加密 (SHA-256)", " const encrypted = publicKey.encrypt(password, 'RSA-OAEP', {", " md: forge.md.sha256.create()", " });", " ", " // 转换为Base64", " const encryptedBase64 = forge.util.encode64(encrypted);", " ", " pm.collectionVariables.set('encryptedPassword', encryptedBase64);", " console.log('密码加密成功');", "} catch (e) {", " console.error('RSA加密失败:', e);", " throw e;", "}" ], "type": "text/javascript" } }, { "listen": "test", "script": { "exec": [ "pm.test('登录成功', function () {", " pm.response.to.have.status(200);", "});", "", "var jsonData = pm.response.json();", "", "if (jsonData.token) {", " pm.collectionVariables.set('token', jsonData.token);", " console.log('Token已保存到Collection变量');", " console.log('用户:', jsonData.user?.username);", "}", "", "if (jsonData.must_change_password) {", " console.warn('警告: 密码已过期,需要修改');", "}", "", "if (jsonData.password_expire_days > 0) {", " console.warn('提示: 密码将在 ' + jsonData.password_expire_days + ' 天后过期');", "}" ], "type": "text/javascript" } } ], "request": { "auth": { "type": "noauth" }, "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n \"username\": \"{{username}}\",\n \"encrypted_password\": \"{{encryptedPassword}}\"\n}" }, "url": { "raw": "{{baseUrl}}/api/auth/login", "host": [ "{{baseUrl}}" ], "path": [ "api", "auth", "login" ] } } }, { "name": "3. 明文密码登录(备用)", "event": [ { "listen": "test", "script": { "exec": [ "pm.test('登录成功', function () {", " pm.response.to.have.status(200);", "});", "", "var jsonData = pm.response.json();", "", "if (jsonData.token) {", " pm.collectionVariables.set('token', jsonData.token);", " console.log('Token已保存');", "}" ], "type": "text/javascript" } } ], "request": { "auth": { "type": "noauth" }, "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n \"username\": \"{{username}}\",\n \"password\": \"{{password}}\"\n}" }, "url": { "raw": "{{baseUrl}}/api/auth/login", "host": [ "{{baseUrl}}" ], "path": [ "api", "auth", "login" ] } } } ] }, { "name": "Contacts", "description": "通信录接口", "item": [ { "name": "获取通信录列表", "request": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/api/contacts?page=1&size=20", "host": [ "{{baseUrl}}" ], "path": [ "api", "contacts" ], "query": [ { "key": "page", "value": "1" }, { "key": "size", "value": "20" }, { "key": "search", "value": "", "disabled": true } ] } } }, { "name": "获取联系人详情", "request": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/api/contacts/1", "host": [ "{{baseUrl}}" ], "path": [ "api", "contacts", "1" ] } } } ] }, { "name": "Users", "description": "用户管理接口 (需要Admin权限)", "item": [ { "name": "获取用户列表", "request": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/api/users?page=1&size=20", "host": [ "{{baseUrl}}" ], "path": [ "api", "users" ], "query": [ { "key": "page", "value": "1" }, { "key": "size", "value": "20" }, { "key": "status", "value": "active", "disabled": true }, { "key": "search", "value": "", "disabled": true } ] } } }, { "name": "获取用户详情", "request": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/api/users/1", "host": [ "{{baseUrl}}" ], "path": [ "api", "users", "1" ] } } } ] }, { "name": "User Profile", "description": "用户个人接口", "item": [ { "name": "修改密码", "request": { "method": "PUT", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n \"current_password\": \"{{password}}\",\n \"new_password\": \"NewPassword123\"\n}" }, "url": { "raw": "{{baseUrl}}/api/user/password", "host": [ "{{baseUrl}}" ], "path": [ "api", "user", "password" ] } } }, { "name": "更新个人资料", "request": { "method": "PUT", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n \"avatar_id\": \"default_1\",\n \"avatar_frame_id\": \"default\"\n}" }, "url": { "raw": "{{baseUrl}}/api/user/profile", "host": [ "{{baseUrl}}" ], "path": [ "api", "user", "profile" ] } } } ] }, { "name": "Permissions", "description": "权限管理接口", "item": [ { "name": "获取我的权限树", "request": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/api/permissions/my-tree/full", "host": [ "{{baseUrl}}" ], "path": [ "api", "permissions", "my-tree", "full" ] } } }, { "name": "获取我的组织列表", "request": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/api/permissions/my-tree/organizations", "host": [ "{{baseUrl}}" ], "path": [ "api", "permissions", "my-tree", "organizations" ] } } } ] } ] }