物联网应用网站前后端接口说明

文章目录

  • 项目实战——物联网应用网站前后端接口说明
    • 1. 用户模块
      • 1.1 用户登录
      • 1.2 用户注册
      • 1.3 用户忘记密码
      • 1.4 发送验证码
      • 1.5 获取用户基本信息
      • 1.6 上传头像
      • 1.7 修改用户信息
      • 1.8 修改密码
      • 1.9 修改绑定手机号
    • 2. 设备管理与配置模块
      • 2.1 获取用户设备种类及数量
      • 2.2 查询设备是否存在
      • 2.3 添加设备
      • 2.4 移除设备
      • 2.5 获取某设备基本信息
      • 2.6 修改设备基本信息
      • 2.7 获取某设备累计数据信息列表
      • 2.8 获取设备历史位置信息列表
    • 3. 设备数据可视化模块
      • 3.1 获取个人所有设备id列表
      • 3.2 获取网站统计信息
  • 4. 帮助模块
    • 4.1 用户进行反馈

项目实战——物联网应用网站前后端接口说明

1. 用户模块

1.1 用户登录

  • url: http://localhost:8000/login/

  • method: post

  • front data

    {
        "email": "[email protected]",
        "password": "123456",
        "remember": true
    }
    
  • back data

    {
        "code": 1,
        "message": "login succeed",
        "token": "2f7108ac307fd06f5995948f35a70f2f"
    }
    
    code 说明
    0 用户名不存在
    1 登录成功
    2 密码错误
    3 其他错误

1.2 用户注册

  • url: http://localhost:8000/register/

  • mehtod: post

  • front data

    {
        "email": "[email protected]",
        "password": "123456",
        "user_name": "ZJU_SLM",
        "auth_code": "123456"
    }
    
  • back data

    {
        "code": 1,
        "message": "注册成功",
        "token": "2f7108ac307fd06f5995948f35a70f2f"
    }
    
    code 说明
    0 验证码错误
    1 注册成功
    2 注册失败

1.3 用户忘记密码

  • url: http://localhost:8000/forget/

  • method: post

  • front data

    {
        "email": "[email protected]",
        "auth_code": "256984",
        "password": "123456"
    }
    
  • back data

    {
        "code": 1,
        "message": "update succeed"
    }
    
    code 说明
    0 验证码错误
    1 修改成功
    2 修改失败

1.4 发送验证码

  • url: http://localhost:8000/sendemail/

  • method: post

  • front data

    {
        "email": "[email protected]",
        "type": 1 /* 1 代表注册所需,0代表验证邮件正确性 */
    }
    
  • back data

    {
        "code": 1,
        "message": "send email succeed"
    }
    
    code 说明
    0 发送失败
    1 发送成功
    2 用户不存在或已经存在

1.5 获取用户基本信息

  • url: http://localhost:8000/user/get_user_information/

  • method: get

  • front data

    {
        "email": "[email protected]"
    }
    
  • back data

    {
        "code": 1,
        "user_name": "ZJU_SLM",
        "name": "沈乐明",
        "gender": "男",
        "phone": "15381145750",
        "address": "浙江省 杭州市",
        "work": "浙江大学 网络空间安全学院",
        "description": "# test"
    }
    
    code 说明
    0 获取失败
    1 获取成功

1.6 上传头像

  • url: http://localhost:8000/user/upload/[email protected]/

  • method: post

  • front data

    {
        file stream
    }
    
  • back data

    {
        "code": 1,
        "message": "上传成功"
    }
    
    code 说明
    0 上传失败
    1 上传成功

1.7 修改用户信息

  • url: http://localhost:8000/user/settings/

  • method: post

  • front data

    {
        "email": "[email protected]",
        "user_name": "ZJU_SLM",
        "name": "沈乐明",
        "gender": 1,
        "phone": "15381145750",
        "address": "浙江省 杭州市",
        "work_school": "浙江大学 网络空间安全学院",
        "description": "Software Engineering, College of Computer Science and Technology, Zhejiang University"
    }
    
  • back data

    {
        "code": 1,
        "message": "修改成功",
    }
    
    code 说明
    0 修改失败
    1 修改成功

1.8 修改密码

  • url: http://localhost:8000/user/update_password

  • method: post

  • front data

    {
        "type": 0,	/* 0 代表通过输入旧密码修改,1 代表通过验证邮箱修改 */
        "email": "[email protected]",
        "old_password": "123456",
        "new_password": "123",
        "auth_code": "123456"
    }
    
  • back data

    {
        "code": 1,
        "message": "修改成功"
    }
    
    code 说明
    0 验证码错误
    1 修改成功
    2 旧密码错误
    3 修改失败

1.9 修改绑定手机号

  • url: http://localhost:8000/modify_email/

  • method: post

  • front data

    {
        "old_phone": "15381145750",
        "new_phone": "123456",
        "email": "[email protected]"
    }
    
  • back data

    {
        "code": 1,
        "message": "修改成功"
    }
    
    code 说明
    0 旧手机号错误
    1 修改成功
    2 修改失败

2. 设备管理与配置模块

2.1 获取用户设备种类及数量

  • url: http://localhost:8000/user/index/

  • method: get

  • front data

    {
        "email": "[email protected]"
    }
    
  • back data

    {
        "code": 1,
        "message": "succeed",
        "device_list": [{
            "device_id": "device0001",
            "device_class": 1,
            "device_type": "1-1",
            "create_time": "2021-05-05 16:32:15",
            "device_name": "test"
        }, {}, ..., {}]
    }
    
    code 说明
    0 获取失败
    1 获取成功

2.2 查询设备是否存在

  • url: http://localhost:8000/device/search/

  • method: post

  • front data

    {
        "device_id": "device0101"
    }
    
  • back data

    {
        "code": 1,
        "message": "exists",
        "device_class": 4,
        "device_type": "4-4",
        "create_time": "2021-05-05 16:32:15"
    }
    
    code 说明
    0 设备不存在
    1 设备存在
    2 设备已经被占用
    3 查询失败

2.3 添加设备

  • url: http://localhost:8000/device/

  • method: post

  • front data

    {
        "email": "[email protected]",
        "device_id": "device0101",
        "device_name": "沈乐明的北斗导航卫星"
    }
    
  • back data

    {
        "code": 1,
        "message": "success"
    }
    
    code 说明
    0 添加失败
    1 添加成功
    2 设备已经被占用

2.4 移除设备

  • url: http://localhost:8000/device/delete/

  • method: post

  • front data

    {
        "email": "[email protected]",
        "password": "123456",
        "device_id": "device0001"
    }
    
  • back data

    {
        "code": 1,
        "message": "remove succeed"
    }
    
    code 说明
    0 移除失败
    1 移除成功
    2 身份认证失败

2.5 获取某设备基本信息

  • url: http://localhost:8000/device//index/

  • method: get

  • front data

    {
        "device_id": "device0001"
    }
    
  • back data

    {
        "code": 1,
        "message": "acquire succeed",
        "device_class": 1,
        "device_type": "1-1",
        "create_time": "2021-05-05 16:32:15",
        "device_name": "slm's device",
        "device_description": "# slm's device",
        "average_value": 100,
        "accumulated_message_size": "100 KB"
    }
    
    code 说明
    0 设备不存在
    1 查询成功
    2 其他错误

2.6 修改设备基本信息

  • url: http://localhost:8000/device//index/

  • method: post

  • front data

    {
        "device_id": "device0001",
        "device_name": "沈乐明的ECS主机",
        "device_description": "# 于2021年5月1日购买"
    }
    
  • back data

    {
        "code": 1,
        "message": "succeed"
    }
    
    code 说明
    0 修改失败
    1 修改成功

2.7 获取某设备累计数据信息列表

  • url: http://localhost:8000/device//value/

  • method: get

  • front data

    {}
    
  • back data

    {
        "code": 1,
        "message": "get value succeed",
        "value_list": [1, 2, 3, 4, 5, 6, 7, 8, 9] /* stands for 0~10, 10~20, 20~30, 30~40, 40~50, 50~60, 60~70, 70~80, 80~100 */
    }
    
    code 说明
    0 获取失败
    1 获取成功

2.8 获取设备历史位置信息列表

  • url: http://localhost:8000/device//history/

  • method: get

  • front data

    {
        "device_id": "device0001"
    }
    
  • back data

    {
        "code": 1,
        "message": "get device history succeed",
        "history_trajectory_marker_list": [{
            "text": "2021-05-11 09:32:27",
            "location": "120.315,30.2989"
        }, {}, ..., {}],
    	"history_trajectory_path_list": [{
            "lng": 120.315,
            "lat": 30.2989
        }, {}, ..., {}]
    }
    
    code 说明
    0 获取失败
    1 获取成功

3. 设备数据可视化模块

3.1 获取个人所有设备id列表

  • url: http://localhost:8000/statistics/map/

  • method: get

  • front data

    {
        "email": "[email protected]"
    }
    
  • back data

{
	"code": 1,
    "message": "get list succeed",
    "list": ["device0001", "device0002", ..., "device0101"]
}
code 说明
0 获取失败
1 获取成功

3.2 获取网站统计信息

  • url: http://localhost:8000/statistics/index/

  • method: get

  • front data

    {
        "email": "[email protected]"
    }
    
  • back data

    {
        "code": 1,
        "message": "get information succeed",
        "user_number": 2,
        "device_number": 500,
        "user_device_number": 101,
        "total_message_size": "100 KB"
    }
    
    code 说明
    0 获取信息失败
    1 获取信息成功

4. 帮助模块

4.1 用户进行反馈

  • url: http://localhost:8000/help/

  • method: post

  • front data

    {
        "subject": "xxxxxx",
        "content": "xxxxxxxxxxxxx"
    }
    
  • back data

    {
        "code": 1,
        "message": "反馈成功"
    }
    
    code 说明
    0 反馈失败
    1 反馈成功

你可能感兴趣的:(软件工程,软件需求,web开发,硬件工程,软件架构,web开发,接口设计)