@cfygaoyang
2018-12-06T06:41:55.000000Z
字数 12485
阅读 802
错误码 | 信息 | 描述 |
---|---|---|
10000 | 通用错误码 | |
10001 | invalid account format | 账号格式错误 |
10002 | invalid account | 账号错误 |
10003 | invalid password | 密码错误 |
10004 | invalid token | token错误 |
10005 | invalid code | 验证码错误 |
10006 | sms server error | 短信服务错误 |
10007 | email server error | 邮件服务错误 |
10008 | invalid refresh token | 刷新token失败 |
10009 | code expired | 验证码过期 |
POST /api/auth/send_code
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
account | 字符串 | 是 | 手机或邮箱 |
{
"code": 0,
"message": "success",
"data": {}
}
POST /api/auth/check_code
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
account | 字符串 | 是 | 手机或邮箱 |
code | 字符串 | 是 | 验证码 |
{
"code": 0,
"message": "success",
"data": {
"access_token": "4kbv6KFHyIJ4JECtFuRLZreHRwDz3Yo6f19fgpu5VYgnSIegN1",
"refresh_token": "pdgSDcfbZsEijvB1yH6RVGXutQWM4fF5qcCxz033AhaokshiwU",
"expires_at": "2018-08-23 10:47:16",
"expires_in": 68400
}
}
POST /api/auth/check_account
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
account | 字符串 | 是 | 手机或邮箱 |
{
"code": 0,
"message": "success",
"data": {
"status": 0
}
}
参数 | 类型 | 说明 |
---|---|---|
status | 整型 | 1:已注册, 0:未注册 |
POST /api/auth/access_token
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
account | 字符串 | 是 | 手机或邮箱 |
password | 字符串 | 是 | 密码 |
{
"code": 0,
"message": "success",
"data": {
"access_token": "4kbv6KFHyIJ4JECtFuRLZreHRwDz3Yo6f19fgpu5VYgnSIegN1",
"refresh_token": "pdgSDcfbZsEijvB1yH6RVGXutQWM4fF5qcCxz033AhaokshiwU",
"expires_at": "2018-08-23 10:47:16",
"expires_in": 68400
}
}
POST /api/auth/refresh_token
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
refresh_token | 字符串 | 是 | 刷新token |
{
"code": 0,
"message": "success",
"data": {
"access_token": "4kbv6KFHyIJ4JECtFuRLZreHRwDz3Yo6f19fgpu5VYgnSIegN1",
"refresh_token": "pdgSDcfbZsEijvB1yH6RVGXutQWM4fF5qcCxz033AhaokshiwU",
"expires_at": "2018-08-23 10:47:16",
"expires_in": 68400
}
}
POST /api/auth/destroy_token
{
"Authorization": "Token 1234567890"
}
{
"code": 0,
"message": "success",
"data": {}
}
POST /api/auth/reset_password
{
"Authorization": "Token 1234567890"
}
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
password | 字符串 | 是 | 密码 |
{
"code": 0,
"message": "success",
"data": {}
}
POST /api/auth/reset_username
{
"Authorization": "Token 1234567890"
}
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
username | 字符串 | 是 | 用户名 |
{
"code": 0,
"message": "success",
"data": {}
}
GET /api/user
{
"Authorization": "Token 1234567890"
}
{
"code": 0,
"message": "success",
"data": {
"id": 1,
"app_id": null,
"created_at": "2018-08-22 16:06:00",
"updated_at": "2018-08-22 16:06:00",
"avatar": null,
"birthday": null,
"sex": 2,
"city": null,
"address": null,
"company": null,
"job": null,
"name": null,
"age": 0,
"user_id": 4,
"username": "jerry",
"phone": "18656660930",
"email": null
}
}
PUT /api/user
{
"Authorization": "Token 1234567890"
}
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
avatar | 字符串 | 可选 | 头像 |
birthday | 字符串 | 可选 | 生日 |
sex | 整型 | 可选 | 性别:0女1男2保密 |
city | 字符串 | 可选 | 城市 |
address | 字符串 | 可选 | 地址 |
company | 字符串 | 可选 | 公司 |
job | 字符串 | 可选 | 职称 |
name | 字符串 | 可选 | 姓名 |
age | 字符串 | 可选 | 年龄 |
{
"code": 0,
"message": "success",
"data": {
"id": 1,
"app_id": null,
"created_at": "2018-08-22 16:06:00",
"updated_at": "2018-08-22 16:06:00",
"avatar": null,
"birthday": null,
"sex": 2,
"city": null,
"address": null,
"company": null,
"job": null,
"name": null,
"age": 0,
"user_id": 4,
"username": "jerry",
"phone": "18656660930",
"email": null
}
}
GET /api/user/{id}
{
"code": 0,
"message": "success",
"data": {
"id": 2,
"app_id": null,
"created_at": "2018-08-22 16:19:29",
"updated_at": "2018-08-22 16:19:29",
"avatar": null,
"birthday": null,
"sex": 2,
"city": null,
"address": null,
"company": null,
"job": null,
"name": null,
"age": 0,
"user_id": 3,
"username": "admin"
}
}
GET /api/topic
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
parent_id | 整型 | 可选 | 所属父级主题id |
page | 整型 | 可选 | 页数 |
* 请求回调
{
"code": 0,
"message": "success",
"data": {
"total": 2,
"pages": 1,
"current_page": 1,
"page_size": 20,
"data": [
{
"id": 2,
"app_id": "",
"created_at": "2018-08-21 16:08:25",
"updated_at": "2018-08-21 16:08:25",
"name": "mulu2",
"index": 1,
"status": true,
"parent_id": 0
},
{
"id": 1,
"app_id": "",
"created_at": "2018-08-20 13:54:55",
"updated_at": "2018-08-21 16:08:25",
"name": "人工智能",
"index": 2,
"status": true,
"parent_id": 0
}
]
}
}
GET /api/topic/{id}
{
"code": 0,
"message": "success",
"data": {
"id": 1,
"app_id": "",
"created_at": "2018-08-20 13:54:55",
"updated_at": "2018-08-21 16:08:25",
"name": "人工智能",
"index": 2,
"status": true,
"parent_id": 0
}
}
GET /api/article
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
topic_id | 整型 | 可选 | 所属主题id |
page | 整型 | 可选 | 页数 |
user_id | 整型 | 可选 | 用户id |
{
"code": 0,
"message": "success",
"data": {
"total": 1,
"pages": 1,
"current_page": 1,
"page_size": 20,
"data": [
{
"id": 1,
"app_id": "",
"created_at": "2018-08-20 16:28:26",
"updated_at": "2018-08-20 16:28:26",
"title": "标题",
"content": "内容",
"user_id": 0,
"topic_id": 1,
"username": null,
"name": "人工智能"
}
]
}
}
POST /api/article
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
title | 字符串 | 是 | 标题 |
content | 字符串 | 是 | 内容 |
topic_id | 整型 | 可选 | 所属话题id |
{
"code": 0,
"message": "success",
"data": {
"id": 2,
"app_id": null,
"created_at": "2018-08-22 18:13:47",
"updated_at": "2018-08-22 18:13:47",
"title": "标题",
"content": "内容",
"user_id": 0,
"topic_id": 1
}
}
GET /api/article/{id}
{
"code": 0,
"message": "success",
"data": {
"id": 2,
"app_id": null,
"created_at": "2018-08-22 18:13:47",
"updated_at": "2018-08-22 18:13:47",
"title": "标题",
"content": "内容",
"user_id": 0,
"topic_id": 1
}
}
PUT /api/article/{id}
{
"Authorization": "Token 1234567890"
}
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
title | 字符串 | 是 | 标题 |
content | 字符串 | 是 | 内容 |
topic_id | 整型 | 可选 | 所属话题id |
{
"code": 0,
"message": "success",
"data": {
"id": 2,
"app_id": null,
"created_at": "2018-08-22 18:13:47",
"updated_at": "2018-08-22 18:13:47",
"title": "标题",
"content": "内容",
"user_id": 0,
"topic_id": 1
}
}
DELETE /api/article/{id}
{
"Authorization": "Token 1234567890"
}
{
"code": 0,
"message": "success",
"data": {}
}
POST /api/user_device
{
"Authorization": "Token 1234567890"
}
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
product_key | 字符串 | 是 | 产品标识 |
iot_id | 字符串 | 是 | 设备唯一标识 |
is_superuser | 布尔型 | 是 | 是否管理员 |
{
"code": 0,
"message": "success",
"data": {
"user_id": 1,
"iot_id": "xxxxxx",
"is_superuser": true,
"_id": 2,
"date_time": "2018-11-13 15:48:06"
}
}
DELETE /api/user_device/{iot_id}
{
"Authorization": "Token 1234567890"
}
{
"code": 0,
"message": "success",
"data": {}
}
GET /api/user_device/{iot_id}
{
"Authorization": "Token 1234567890"
}
{
"code": 0,
"message": "success",
"data": {
"active_time": "2018-11-27 14:34:33"
}
}
GET /api/feedback_category
{
"code": 0,
"message": "success",
"data": {
"total": 1,
"pages": 1,
"current_page": 1,
"page_size": 20,
"data": [
{
"id": 1,
"app_id": null,
"created_at": "2018-11-13 00:00:00",
"updated_at": "2018-11-13 00:00:00",
"feedback_category_name": "其他",
"feedback_category_description": null
}
]
}
}
GET /api/feedback_category/{id}
{
"code": 0,
"message": "success",
"data": {
"id": 1,
"app_id": null,
"created_at": "2018-11-13 00:00:00",
"updated_at": "2018-11-13 00:00:00",
"feedback_category_name": "其他",
"feedback_category_description": null
}
}
GET /api/feedback
{
"Authorization": "Token 1234567890"
}
{
"code": 0,
"message": "success",
"data": {
"total": 3,
"pages": 1,
"current_page": 1,
"page_size": 20,
"data": [
{
"id": 1,
"app_id": null,
"created_at": "2018-11-13 13:46:51",
"updated_at": "2018-11-13 13:46:51",
"feedback_content": "反馈内容",
"feedback_status": 0,
"feedback_category_id": 0,
"contact_phone": null,
"user_id": 1
},
{
"id": 3,
"app_id": null,
"created_at": "2018-11-13 13:50:24",
"updated_at": "2018-11-13 13:50:24",
"feedback_content": "编辑后的内容",
"feedback_status": 0,
"feedback_category_id": 0,
"contact_phone": null,
"user_id": 1
},
{
"id": 4,
"app_id": null,
"created_at": "2018-11-13 13:50:57",
"updated_at": "2018-11-13 13:50:57",
"feedback_content": "编辑后的内容",
"feedback_status": 0,
"feedback_category_id": 0,
"contact_phone": null,
"user_id": 1
}
]
}
}
POST /api/feedback
{
"Authorization": "Token 1234567890"
}
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
feedback_content | 字符串 | 必选 | 反馈内容 |
feedback_category_id | 整型 | 可选 | 反馈类型主键 |
contact_phone | 字符串 | 可选 | 联系方式 |
{
"code": 0,
"message": "success",
"data": {
"id": 2,
"app_id": null,
"created_at": "2018-11-13 13:47:32",
"updated_at": "2018-11-13 13:47:32",
"feedback_content": "反馈内容",
"feedback_status": 0,
"feedback_category_id": 0,
"contact_phone": null,
"user_id": 1
}
}
GET /api/feedback/{id}
{
"Authorization": "Token 1234567890"
}
{
"code": 0,
"message": "success",
"data": {
"id": 1,
"app_id": null,
"created_at": "2018-11-13 13:46:51",
"updated_at": "2018-11-13 13:46:51",
"feedback_content": "反馈内容",
"feedback_status": 0,
"feedback_category_id": 0,
"contact_phone": null,
"user_id": 1
}
}
PUT /api/feedback/{id}
{
"Authorization": "Token 1234567890"
}
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
feedback_content | 字符串 | 必选 | 反馈内容 |
feedback_category_id | 整型 | 可选 | 反馈类型主键 |
contact_phone | 字符串 | 可选 | 联系方式 |
{
"code": 0,
"message": "success",
"data": {
"id": 4,
"app_id": null,
"created_at": "2018-11-13 13:50:57",
"updated_at": "2018-11-13 13:50:57",
"feedback_content": "编辑后的内容",
"feedback_status": 0,
"feedback_category_id": 0,
"contact_phone": null,
"user_id": 1
}
}
DELETE /api/feedback/{id}
{
"Authorization": "Token 1234567890"
}
{
"code": 0,
"message": "success",
"data": {}
}
GET /api/feedback_reply
{
"Authorization": "Token 1234567890"
}
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
page | 整型 | 可选 | 分页页数 |
* 请求回调
{
"code": 0,
"message": "success",
"data": {
"total": 1,
"pages": 1,
"current_page": 1,
"page_size": 20,
"data": [
{
"created_at": "2018-11-15 00:00:00",
"feedback_reply_content": "回复的内容",
"feedback_id": 1,
"feedback_content": "反馈内容",
"feedback_status": 0,
"feedback_category_id": 0,
"contact_phone": null
}
]
}
}
GET /api/faq
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
page | 整型 | 可选 | 分页页数 |
{
"code": 0,
"message": "success",
"data": [
{
"id": 2,
"app_id": null,
"created_at": "2018-11-19 10:34:04",
"updated_at": "2018-11-19 10:34:04",
"faq_title": "标题",
"faq_content": "内容",
"use_external_link": false,
"external_link": null
}
]
}
GET /api/faq/{id}
{
"code": 0,
"message": "success",
"data": {
"id": 11,
"app_id": null,
"created_at": "2018-11-28 14:34:42",
"updated_at": "2018-11-28 14:34:42",
"product_key": "a1eACCIjxA1",
"faq_title": "faq5",
"faq_content": "<p>shjhjfd</p>",
"use_external_link": false,
"external_link": null
}
}
GET /api/faq_url
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
product_key | 字符串 | 可选 | 产品标识 |
{
"code": 0,
"message": "success",
"data": {
"url": "http://115.28.161.90/?id=11"
}
}
POST /api/upload
{
"Authorization": "Token 1234567890"
}
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
batch | file | 是 | form-data文件上传对应的key |
{
"code": 0,
"message": "success",
"data": {
"path": "/public/upload/20181119153915687668.csv"
}
}
GET /api/message
{
"Authorization": "Token 1234567890"
}
{
"code": 0,
"message": "success",
"data": {
"action_message": {
"data": {
"id": 3,
"app_id": null,
"created_at": "2018-11-21 15:16:50",
"updated_at": "2018-11-21 15:16:50",
"title": "标题",
"content": "内容",
"category": 0,
"pic_1": "http://xxx.com/xxx.jpg",
"pic_2": "http://xxx.com/xxx.jpg",
"use_external_link": false,
"external_link": null,
"status": 0,
"timing_at": null,
"read_count": 0
},
"not_read_count": 2
},
"feedback_reply": {
"data": {
"id": 12,
"app_id": null,
"created_at": "2018-11-20 16:43:57",
"updated_at": "2018-11-20 16:43:57",
"feedback_reply_content": "说几句",
"feedback_id": 4,
"user_id": 4
},
"not_read_count": 19
}
}
}
GET /api/action_message
{
"Authorization": "Token 1234567890"
}
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
page | 整型 | 可选 | 分页页数 |
category | 整型 | 可选 | 消息类型(0:活动列表消息,1:主页弹窗消息) |
{
"code": 0,
"message": "success",
"data": {
"total": 1,
"pages": 1,
"current_page": 1,
"page_size": 20,
"data": [
{
"id": 1,
"app_id": null,
"created_at": "2018-11-19 17:59:42",
"updated_at": "2018-11-19 17:59:42",
"title": "标题",
"content": "内容",
"category": 0,
"pic_1": "http://xxx.com/xxx.jpg",
"pic_2": "http://xxx.com/xxx.jpg",
"use_external_link": false,
"external_link": null,
"status": 0,
"timing_at": null,
"read_count": 0
}
]
}
}
GET /api/action_message/{id}
{
"code": 0,
"message": "success",
"data": {
"id": 3,
"app_id": null,
"created_at": "2018-11-21 15:16:50",
"updated_at": "2018-11-21 15:16:50",
"title": "标题",
"content": "内容",
"category": 0,
"pic_1": "",
"pic_2": "",
"use_external_link": false,
"external_link": "http://127.0.0.1/?id=3",
"status": 0,
"timing_at": null,
"read_count": 1
}
}
POST /api/device_address
{
"Authorization": "Token 1234567890"
}
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
iot_id | 字符串 | 是 | 设备唯一标识 |
longitude | 浮点型 | 是 | 经度 |
latitude | 浮点型 | 是 | 纬度 |
country | 字符串 | 可选 | 国家 |
province | 字符串 | 可选 | 省份/直辖市 |
city | 字符串 | 可选 | 城市 |
county | 字符串 | 可选 | 县/行政区 |
detail | 字符串 | 可选 | 详细位置 |
{
"code": 0,
"message": "success",
"data": {
"iot_id": "xxx",
"longitude": 123,
"latitude": 123,
"country": "",
"province": "",
"city": "",
"county": "",
"detail": "",
"_id": 1
}
}
GET /api/device_address
{
"Authorization": "Token 1234567890"
}
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
iot_id | 字符串 | 是 | 设备唯一标识 |
{
"code": 0,
"message": "success",
"data": {
"_id": 1,
"iot_id": "xxx",
"longitude": 123,
"latitude": 123,
"date_time": "2018-11-22 11:43:35",
"city": "",
"country": "",
"county": "",
"detail": "",
"province": ""
}
}
GET /api/user_habit
{
"Authorization": "Token 1234567890"
}
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
province | 字符串 | 可选 | 省/市 (如:上海市) |
{
"code": 0,
"message": "success",
"data": {
"device_count": 2,
"data": [
{
"percent": "40%",
"value": {
"WarmingTime": 300,
"HeatingTime": 60,
"SleepingTime": 300
}
},
{
"percent": "20%",
"value": {
"WarmingTime": 300,
"HeatingTime": 0,
"SleepingTime": 300
}
},
{
"percent": "20%",
"value": {
"WarmingTime": 90,
"HeatingTime": 0,
"SleepingTime": 90
}
}
]
}
}
POST /api/weather
{
"Authorization": "Token 1234567890"
}
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
lon | 浮点型 | 是 | 经度 |
lat | 浮点型 | 是 | 纬度 |
{
"code": 0,
"message": "success",
"data": {
"city": {
"cityId": 284826,
"counname": "中国",
"name": "黄浦区",
"pname": "上海市",
"timezone": "8"
},
"condition": {
"condition": "多云",
"conditionId": "8",
"humidity": "73",
"icon": "31",
"pressure": "1022",
"realFeel": "14",
"sunRise": "2018-11-28 06:32:00",
"sunSet": "2018-11-28 16:52:00",
"temp": "14",
"tips": "略微偏凉,还是蛮舒适的。",
"updatetime": "2018-11-28 17:55:08",
"uvi": "1",
"windDir": "微风",
"windLevel": "0",
"windSpeed": "0.0"
}
}
}