[TOC] ## 获取用户列表 ~~~[api] get:/v1/users integer:page=1#当前页码 integer:limit=10#单页显示数量 email#邮箱地址 name#用户名 phone#手机号码 qq#QQ号码 user_id#用户ID boolean:enable#启用或禁用状态 integer:type#用户类型,1为管理员,2为普通用户 <<< 返回结果 { "code": 0, "count": 2, "data": [ { "balance": 0, "cert_name": "xxx", "cert_no": "xxx", "cert_verified": 0, "create_at2": "2021-10-06 08:55:29", "des": "1636590913.91", "email": "1234@qq.com", "enable": 1, "freeze": 0, "id": 2, "name": "jason", "phone": "xxx", "qq": "", "type": 2 }, { "balance": 0, "cert_name": null, "cert_no": null, "cert_verified": 0, "create_at2": "2021-10-06 08:55:29", "des": "", "email": "admin@cdn.cn", "enable": 1, "freeze": 0, "id": 1, "name": "admin", "phone": "xxx", "qq": null, "type": 1 } ] } ~~~ ## 批量修改用户 (数据格式为数组) ~~~[api] get:/v1/users *string:id#用户ID email#用户邮箱 name#用户名 des#备注 phone#手机号码 qq#QQ号码 password#密码 type#账号类型 enable#禁用或启用 <<< 返回结果 { "code":0, "data": "", "msg": "更新用户成功" } <<< 提交内容 [{ "id": 22, "enable": 0 }, { "id": 33, "enable": 0 }] ~~~ ## 新增用户 ~~~[api] post:/v1/users *email#用户邮箱 *name#用户名 des#备注 phone#手机号码 qq#QQ号码 *password#密码 *type#账号类型 enable#禁用或启用 <<< 返回结果 { "code":0, "data": "22", "msg": "用户添加成功" } <<< 提交内容 { "email": "xxx@qq.com", "name": "xxx", "password": "123456", "type": 2 } ~~~ ## 获取单个用户 ~~~[api] get:/v1/users/<用户ID> name#说明文字 <<< 返回结果 { "code": 0, "data": { "balance": 0, "cert_id": "xxx", "cert_name": "xxx", "cert_no": "xxx", "cert_verified": 0, "create_at": null, "des": "xxx", "email": "xxx@qq.com", "enable": 1, "freeze": 0, "id": 2, "name": "jason", "password": "$2b$12$92Hh45wTvxkxbhq6b3YOeuJPSOgEwnRmBJMU1RCU1VevkOy.drmjG", "phone": "xxx", "qq": "", "type": 2 }, "msg": "获取用户成功" } ~~~ ## 修改单个用户 ~~~[api] put:/v1/users/<用户ID> email#用户邮箱 name#用户名 des#备注 phone#手机号码 qq#QQ号码 password#密码 type#账号类型 enable#禁用或启用 <<< 返回结果 { "code":0, "data": "", "msg": "更新用户成功" } <<< 提交内容 { "name": "xx" } ~~~ ## 删除用户 ~~~[api] delete:/v1/users/<用户ID,多个以逗号分隔> <<< 返回结果 { "code": 0, "data": "", "msg": "用户删除成功" } ~~~ ## 获取access_token用于自动登录后台 ~~~[api] get:/v1/users/<用户id>?token=1 <<< 返回结果 { "code": 0, "data": { "access_token": "j7HPqCsjTYjv2DjPe56pYO2qBY72CzyujMT/H/KAK+KsE6R8hHtQ8FWwUd7hmblVuNwy2mepgf+BNvsLYATiie6e6N60EaHlSZdIqDkeeXYoxdE67k6J3EMmvLS2jmF2fJ4BSZxOzcj3Vbj7TFXJ1g==", "type": 2, "uid": 2, "username": "jason" }, "msg": "登录成功!" } ~~~ 获取access_token后,需要左斜杠(/)转为下划线(_),等于号(=)转为逗号(,),对应的js代码为: ``` access_token = access_token.replace(/\\//g,"\_") access_token = access_token.replace(/\=/g,",") ``` 之后,跳转到后台地址,如js代码为: ``` var url = "http://"+域名 +"/console/index.html#/user/login/redirect=/access_token="+access_token+"/username="+username+"/uid="+uid window.open(url) ``` 替换代码中的域名,access_token,username和uid