赞
踩
GET API_URL?params
POST API_URL
{
body
}
PUT API_URL
{
body
}
DELETE API_URL?params
Content-Type: application/json;charset=UTF-8
{
code: xxx,
message: xxx,
data: {...}
}
code为错误码, message为错误信息
前后端采用token验证身份, 权限鉴定过程如下:
POST /login
{
"username": "user123",
"password": "user123"
}
登陆成功后, 后端返回以下信息:
{ "code": 0, "data": { "userInfo": { "username": "user123", "gender":1, "birthday":"2020.11.15", "height":170, "weight":65, "diabetes":1, "diagnosis_time":"2020.11.15", "diabetes_type":1, "complication":"糖尿病肾病" }, "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0aGlzIGlzIGxpdGVtYWxsIHRva2VuIiwiYXVkIjoiTUlOSUFQUCIsImlzcyI6IkxJVEVNQUxMIiwiZXhwIjoxNTU3MzI2ODUwLCJ1c2VySWQiOjEsImlhdCI6MTU1NzMxOTY1MH0.XP0TuhupV_ttQsCr1KTaPZVlTbVzVOcnq_K0kXdbri0" }, "message": "成功" }
ACCESS_TOKEN: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0aGlzIGlzIGxpdGVtYWxsIHRva2VuIiwiYXVkIjoiTUlOSUFQUCIsImlzcyI6IkxJVEVNQUxMIiwiZXhwIjoxNTU3MzI2ODUwLCJ1c2VySWQiOjEsImlhdCI6MTU1NzMxOTY1MH0.XP0TuhupV_ttQsCr1KTaPZVlTbVzVOcnq_K0kXdbri0
POST /logout
需在headers中携带token
POST /data
{
"data": 光强值
}
参数名 | 类型 | 说明 |
---|---|---|
blood_data | float | 计算得血糖值 |
data_change | float | 血糖值与上次测量结果变化 |
healthy_condition | string | 健康状况 |
healthy_advice | string | 建议 |
{
"code" : 200,
"message" : "操作成功",
"data" : {
"blood_data": 5.0,
"data_change":0.5,
"healthy_condition ":"健康",
"healthy_advice" : "建议增加运动"
}
}
GET /data?mode="..."
参数名 | 类型 | 说明 |
---|---|---|
mode | string | 请求方式, mouth, week或quarter |
参数名 | 类型 | 说明 |
---|---|---|
blood_data | list<float> | 一定时间内内血糖值 |
valid_num | int | 一定时间内内测量数据有效天数 |
healthy_condition | string | 健康状况 |
healthy_advice | string | 建议 |
{
"code" : 200,
"message" : "操作成功",
"data" : {
"blood_data": [5.0,5.0,...],
"valid_num": 13,
"healthy_condition ":"健康",
"healthy_advice" : "建议增加运动"
}
}
GET /tips
PUT /users
{
"username": "newusername",
"gender":1,
"birthday":"2020.11.15",
"height":170,
"weight":65,
"diabetes":1,
"diagnosis_time":"2020.11.15",
"diabetes_type":1,
"complication":"糖尿病肾病"
}
{ "code": 0, "data": { "userInfo": { "username": "newusername", "gender":1, "birthday":"2020.11.15", "height":170, "weight":65, "diabetes":1, "diagnosis_time":"2020.11.15", "diabetes_type":1, "complication":"糖尿病肾病" }, "message": "成功" }
用户注册后自动登录, 后端一并返回token
POST /users
{
"username": "username",
"password": "12345"
}
{
"code": 0,
"message": "注册成功",
"data": {
"token": "..."
}
}
POST /sendsms
参数名 | 类型 | 说明 |
---|---|---|
mobile | string | 手机号 |
{
"code": 200,
"message": "发送成功",
}
POST /verifysms
参数名 | 类型 | 说明 |
---|---|---|
code | string | 用户填写的验证码 |
{
"code": 200,
"message": "发送成功",
"token":...
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。