门户_用户接口 - SilentJhin/mmall GitHub Wiki

1.登录

/user/login.do post(代码需要post方式请求),开放get,方便调试

request

username,password

response fail

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

success

{
    "status": 0,
    "msg": "登录成功",
    "data": {
        "id": 1,
        "username": "admin",
        "password": "",
        "email": "[email protected]",
        "phone": "13800138000",
        "question": "问题",
        "answer": "答案",
        "role": 1,
        "createTime": 1478422605000,
        "updateTime": 1550836719000
    }
}

2.注册

/user/register.do

request

username,password,email,phone,question,answer

response success

{
    "status": 0,
    "msg": "注册成功"
}

fail

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

3.检查用户名是否有效

/user/check_valid.do /check_valid.do?str=admin&type=username就是检查用户名。

request

str,type
str可以是用户名也可以是email。对应的type是username和email
校验成功说明数据库里没有值

response success

{
    "status": 0,
    "msg": "校验成功"
}

fail

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

4.获取登录用户信息

/user/get_user_info.do

request

无参数,不会获取密码

response success

{
    "status": 0,
    "data": {
        "id": 1,
        "username": "admin",
        "password": "",
        "email": "[email protected]",
        "phone": "13800138000",
        "question": "问题",
        "answer": "答案",
        "role": 1,
        "createTime": 1478422605000,
        "updateTime": 1550836719000
    }
}

fail

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

5.忘记密码

/user/forget_get_question.do localhost:8080/user/forget_get_question.do?username=geely

request

username

response success

{
    "status": 0,
    "data": "question"
}

fail

{
    "status": 1,
    "msg": "该用户未设置找回密码问题"
}

6.提交问题答案

/user/forget_check_answer.do localhost:8080/user/forget_check_answer.do?username=aaa&question=aa&answer=sss

request

username,question,answer

response 正确的返回值里面有一个token,修改密码的时候需要用这个。传递给下一个接口 success

{
    "status": 0,
    "data": "4c3345ca-793f-4789-8314-e113d6e21573"
}

fail

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

7.忘记密码的重设密码

/user/forget_reset_password.do localhost:8080/user/forget_reset_password.do?username=aaa&passwordNew=xxx&forgetToken=531ef4b4-9663-4e6d-9a20-fb56367446a5

request

username,passwordNew,forgetToken

response success

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

fail

{
    "status": 1,
    "msg": "修改密码操作失效"
}

{
    "status": 1,
    "msg": "token错误,请重新获取密码token"
}

8.登录中状态重置密码

/user/reset_password.do

request

passwordOld,passwordNew

response success

{
    "status": 0,
    "msg": "密码更新成功"
}

fail

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

9.登录状态更新个人信息

/user/update_information.do

request

email,phone,question,answer

response success

{
    "status": 0,
    "msg": "更新个人信息成功"
}

fail

{
    "status": 1,
    "msg": "用户未登录"
}

10.获取当前登录用户的详细信息,并强制登录

/user/get_information.do

request

无参数

response success

{
    "status": 0,
    "data": {
        "id": 1,
        "username": "admin",
        "password": "",
        "email": "[email protected]",
        "phone": "13800138000",
        "question": "问题",
        "answer": "答案",
        "role": 1,
        "createTime": 1478422605000,
        "updateTime": 1491305256000
    }
}

fail

{
    "status": 10,
    "msg": "用户未登录,无法获取当前用户信息,status=10,强制登录"
}

11.退出登录

/user/logout.do

request

无参数

response

success

{
    "status": 0
}

fail

{
    "status": 1,
    "msg": "服务端异常"
}