Skip to content

用户模块

sfyr111 edited this page Feb 26, 2018 · 1 revision

POST 用户登录

{{host}}/user/login

request

params

username
password

response

success

{
    "status": 0,
    "msg": "登录成功",
    "data": {
        "id": 12,
        "username": "xiaoyang",
        "email": "1@2.com",
        "phone": null,
        "role": 0
    }
}

error

{
    "status": 1,
    "msg": "密码错误",
    "data": null
}

POST 用户登出

{{host}}/user/logout

response

success

{
    "status": 0
}

POST 后台管理员登录

{{host}}/manage/user/login

request

params

username
password

response

success

{
    "status": 0,
    "msg": "登录成功",
    "data": {
        "id": 14,
        "username": "laoyang",
        "email": "laoyang@123.com",
        "phone": null,
        "role": 1
    }
}

error

{
    "status": 1,
    "msg": "密码错误",
    "data": null
}

POST 注册

{{host}}/user/register

request

params

username
password
email
phone
question
answer

response

success

{
    "status": 0,
    "msg": "注册成功",
    "data": {
        "createTime": "2018-02-26T07:05:49.599Z",
        "updateTime": "2018-02-26T07:05:49.599Z",
        "id": 15,
        "username": "xiaoyang2",
        "email": "xiaoyang2@123.com",
        "question": "你好吗?",
        "answer": "是的",
        "role": 0
    }
}

error

{
    "status": 1,
    "msg": "用户名已存在",
    "data": null
}

GET 校验用户名和邮箱

{{host}}/user/checkValid/:type/:value

request

params

type: email | username
value

response

success

{
    "status": 0,
    "msg": "用户名不存在",
    "data": null
}

error

{
    "status": 1,
    "msg": "用户名已存在",
    "data": null
}

GET 获取当前用户登录状态

{{host}}/user/getUserSession

response

success

{
    "status": 0,
    "msg": "用户已登录",
    "data": {
        "id": 14,
        "username": "laoyang",
        "email": "laoyang@123.com",
        "phone": null,
        "role": 1
    }
}

error

{
    "status": 1,
    "msg": "用户未登录,无法获取用户信息",
    "data": null
}

GET 获取密码提示问题

{{host}}/user/forgetGetQuestion/:username

response

success

{
    "status": 0,
    "msg": null,
    "data": {
        "question": "你好吗?"
    }
}

error

{
    "status": 1,
    "msg": "用户不存在",
    "data": null
}

POST 校验找回密码问题并返回修改密码凭证token

{{host}}/user/forgetCheckAnswer

request

params

username
question
answer

response

success

{
    "status": 0,
    "msg": "问题回答正确",
    "data": {
        "token": "95b54140-1aca-11e8-8ac0-911848615e93"
    }
}

error

{
    "status": 1,
    "msg": "问题的答案错误",
    "data": null
}

PUT 使用修改密码凭证token 修改密码

{{host}}/user/forgetRestPassword

request

params

username
forgetToken
paswordNew

response

success

{
    "status": 0,
    "msg": "修改密码成功",
    "data": null
}

error

{
    "status": 0,
    "msg": "token错误, 请重新获取充值密码的token",
    "data": null
}

PUT 在线修改密码

{{host}}/user/resetPassword

request

params

passwordOld
passwordNew

response

success

{
    "status": 0,
    "msg": "修改密码成功",
    "data": null
}

error

{
    "status": 1,
    "msg": "旧密码错误",
    "data": null
}

PUT 修改用户信息

{{host}}/user/updateUserInfo

request

params

email
phone

response

success

{
    "status": 0,
    "msg": "更新个人信息成功",
    "data": {
        "id": 12,
        "username": "xiaoyang",
        "email": "1@2.com",
        "phone": null
    }
}

error

{
    "status": 1,
    "msg": "email已经存在, 请更换",
    "data": null
}

GET 获取用户详细信息

{{host}}/user/getUserInfo

response

success

{
    "status": 0,
    "msg": null,
    "data": {
        "id": 12,
        "username": "xiaoyang",
        "email": "1@2.com",
        "phone": null,
        "question": "你好吗?"
    }
}

error

{
    "status": 10,
    "msg": "用户未登录",
    "data": null
}