{ "info": { "name": "YwxApp API v1", "description": "YwxApp 标准 App 接口集合(/api/v1)。code=0 成功,非0 失败,401 未登录。登录后从响应取 access_token,通过 Tests 脚本自动写入环境变量 token。", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "variable": [ { "key": "base_url", "value": "http://localhost/api/v1", "type": "string" }, { "key": "token", "value": "", "type": "string" } ], "item": [ { "name": "Common", "item": [ { "name": "init 启动初始化", "request": { "method": "GET", "url": "{{base_url}}/common/init" } }, { "name": "config 站点配置", "request": { "method": "GET", "url": "{{base_url}}/common/config" } } ] }, { "name": "User", "item": [ { "name": "register 注册", "request": { "method": "POST", "url": "{{base_url}}/user/register", "body": { "mode": "urlencoded", "urlencoded": [ { "key": "account", "value": "testuser", "type": "text" }, { "key": "password", "value": "123456", "type": "text" }, { "key": "nickname", "value": "测试用户", "type": "text" } ] } } }, { "name": "login 登录", "request": { "method": "POST", "url": "{{base_url}}/user/login", "body": { "mode": "urlencoded", "urlencoded": [ { "key": "account", "value": "testuser", "type": "text" }, { "key": "password", "value": "123456", "type": "text" } ] } }, "event": [ { "listen": "test", "script": { "exec": [ "var json = pm.response.json();", "if (json.code === 0 && json.data && json.data.access_token) {", " pm.collectionVariables.set('token', json.data.access_token);", " pm.collectionVariables.set('refresh_token', json.data.refresh_token);", "}" ], "type": "text/javascript" } } ] }, { "name": "refresh 刷新token", "request": { "method": "POST", "url": "{{base_url}}/user/refresh", "body": { "mode": "urlencoded", "urlencoded": [ { "key": "refresh_token", "value": "{{refresh_token}}", "type": "text" } ] } }, "event": [ { "listen": "test", "script": { "exec": [ "var json = pm.response.json();", "if (json.code === 0 && json.data && json.data.access_token) {", " pm.collectionVariables.set('token', json.data.access_token);", "}" ], "type": "text/javascript" } } ] }, { "name": "profile 获取资料(需登录)", "request": { "method": "GET", "url": "{{base_url}}/user/profile", "header": [ { "key": "Authorization", "value": "Bearer {{token}}" } ] } }, { "name": "updateProfile 修改资料(需登录)", "request": { "method": "POST", "url": "{{base_url}}/user/updateProfile", "header": [ { "key": "Authorization", "value": "Bearer {{token}}" } ], "body": { "mode": "urlencoded", "urlencoded": [ { "key": "nickname", "value": "新昵称", "type": "text" } ] } } }, { "name": "changePwd 修改密码(需登录)", "request": { "method": "POST", "url": "{{base_url}}/user/changePwd", "header": [ { "key": "Authorization", "value": "Bearer {{token}}" } ], "body": { "mode": "urlencoded", "urlencoded": [ { "key": "oldpassword", "value": "123456", "type": "text" }, { "key": "newpassword", "value": "654321", "type": "text" } ] } } }, { "name": "logout 退出登录(需登录)", "request": { "method": "POST", "url": "{{base_url}}/user/logout", "header": [ { "key": "Authorization", "value": "Bearer {{token}}" } ] } } ] } ] }