HTTP
全局规范
URL
URL的组成:基本的网络地址 + 分支节点
http://172.19.201.155:8443/datasyn 为 基本的网络地址
/login 为 分支节点
http://172.19.201.155:8443/datasyn/login 组成完整的 URL
当前统一的基本网络地址为 http://172.19.201.155:8443/datasyn
请求方式
|POST
|GET
请求消息头
请求参数
键值对(key value形式)
默认都是必选参数
请求参数
键值对(key value形式)
响应的状态码
统一的返回码为: 200 (注:只要访问服务器成功,一律返回200)
响应的格式
Json
响应的JSON规范
成功
{
"meta": {
"status": 1,
"message": "success"
},
"data": ....
}
成功的标记为 status为 1
根据具体的请求,如果需要返回值 data节点 包含的是 返回结果
不需要需要返回值 ,则没有data节点
{
"meta": {
"status": 错误编码,
"message": "错误原因"
},
"data": null
}
失败的标记为 status为 除1以外的其它编码
status不为1时,message为错误原因
- 同步数据表:
user、Usercard、Userlearningstyle、usertestcounnt、userresource、userword、usertest,这几个表在json中作为key值时区分大小写。必须按照这个格式写
- 轨迹数据表:
usertest、userlogin,这几个表在json中作为key值时区分大小写。必须按照这个格式写
- 日期格式:json中传输的日期格式
yyyy-MM-dd HH:mm:ss
- 注:元数据表中的lastModTime为long类型,所以前端应该传输数值型值。
1.注册接口
- 分支节点 :
/user/register
- 请求方式 :
POST
- 请求参数
key |
类型 |
说明 |
loginName |
String |
|
password |
String |
|
realName |
String |
|
sex |
int |
1:代表男,0:代表女 |
school |
String |
学校 |
grade |
String |
班级 |
classNum |
int |
年级,值1到6 |
englishscore |
int |
英语分数,值1到200 |
{
"meta": {
"status": 1,
"message": "success"
},
"data": {
"userId": 22
}
}
status |
message |
3 |
参数有误! |
2000 |
用户已存在 |
2.登录接口
- 分支节点 :
/user/login
- 请求方式 :
POST
- 请求参数
key |
类型 |
说明 |
loginName |
String |
|
password |
String |
|
synDevice |
String |
设备标识 |
{
"meta": {
"status": 1,
"message": "success"
},
"data": {
"token": "21:1489385636029",
"synFlage": 4,
"message": "有可能有数据遗留在当前的设备上"
}
}
synFlage |
message |
1 |
同步成功 |
2 |
有可能有数据遗留在上次操作的设备上 |
3 |
在上次登录操作的设备上数据同步失败 |
4 |
有可能有数据遗留在当前的设备上 |
5 |
上次在当前设备上数据同步失败 |
status |
message |
2001 |
参数有误! |
3.忽略同步提示接口
- 分支节点 :
/syn/ignore
- 请求方式 :
POST
- 请求参数
key |
类型 |
说明 |
token |
String |
|
synDevice |
String |
设备标识 |
{
"meta": {
"status": 1,
"message": "success"
},
"data": null
}
status |
message |
4 |
token值无效 |
4.获取同步元数据接口
- 分支节点 :
/syn/synmetas
- 请求方式 :
POST
- 请求参数
key |
类型 |
说明 |
token |
String |
|
json |
String |
json格式数据 |
- json格式数据格式
- 其中synTable的值不区分大小写。且synId、userId字段属于无关字段(即不会起任何作用)
{
"tablemeta":[
{"synId":1,"synTable":"user", "userId": 111, "version":0, "lastModTime":null },
{"synId":1, "synTable":"Usercard", "userId": 111,"version":0, "lastModTime":null},
{"synId":1, "synTable":"Userlearningstyle","userId": 111,"version":0,"lastModTime":null},
{ "synId":1,"synTable":"usertestcount", "userId": 111, "version":0, "lastModTime":null },
{ "synId":1,"synTable":"userresource", "userId": 111, "version":0, "lastModTime":null },
{ "synId":1,"synTable":"usertest", "userId": 111, "version":0, "lastModTime":null },
{ "synId":1,"synTable":"userword", "userId": 111,"version":0, "lastModTime":null }
]
}
{
"meta": {
"status": 1,
"message": "success"
},
"data": {
"synTableCount": 7,
"upsyntable": [],
"downsyntable": [
{
"synTable": "user"
},
{
"synTable": "Usercard"
},
{
"synTable": "Userlearningstyle"
},
{
"synTable": "usertestcount"
},
{
"synTable": "userresource"
},
{
"synTable": "usertest"
},
{
"synTable": "userword"
}
]
}
}
status |
message |
3 |
参数有误 |
4 |
token值无效 |
5 |
json数据格式或者数据类型有误! |
5.数据同步接口
- 分支节点 :
/syn/syntabledata
- 请求方式 :
POST
- 请求参数
key |
类型 |
说明 |
token |
String |
|
json |
String |
json格式数据 |
- json格式数据格式
- 其中synTable的值不区分大小写。tableData中的user等key值不区分大小写。
{
"downSynTable":[
{"synTable":"usertestcount"},
{"synTable":"userresource"}
],
"tableData":{
"Userlearningstyle":[
{"userLearningStyleId":1,"userId":111,"style1":1,"style2":2}
],
"Usercard":[
{"userCardId":1,"cardclick1":1,"cardclick2":1,"cardclick3":2,"cardclick4":2,"userId":111}
],
"usertest":[
{"userTestId":1,"userId":111,"answertimes":3,"righttimes":2,"testinTime":"2017-03-25 15:58:23","testoutTime":"2017-03-25 17:18:07","testtype":1,"wrongtimes":1,"word":"apple"},
{"userTestId":1,"userId":111,"answertimes":4,"righttimes":6,"testinTime":"2017-03-25 15:58:23","testoutTime":"2017-03-25 17:18:07","testtype":1,"wrongtimes":1,"word":"banana"},
{"userTestId":1,"userId":111,"answertimes":5,"righttimes":7,"testinTime":"2017-03-25 15:58:23","testoutTime":"2017-03-25 17:18:07","testtype":1,"wrongtimes":1,"word":"orange"},
{"userTestId":1,"userId":111,"answertimes":6,"righttimes":3,"testinTime":"2017-03-25 15:58:23","testoutTime":"2017-03-25 17:18:07","testtype":1,"wrongtimes":1,"word":"tomato"}
]
}
}
{
"data": {
"tableData": {
"userresource": [
{
"learncount": 12,
"learntimenow": 2,
"learntimes": 2,
"rType": 2,
"resourceId": 2,
"rloginTime": "2017-03-25 15:58:23",
"rlogoutTime": "2017-03-25 17:18:07",
"userId": 111,
"userResourceId": 30,
"word": "rice"
},
{
"learncount": 4,
"learntimenow": 6,
"learntimes": 2,
"rType": 3,
"resourceId": 3,
"rloginTime": "2017-03-25 15:26:27",
"rlogoutTime": "2017-03-25 16:56:12",
"userId": 111,
"userResourceId": 31,
"word": "mike"
},
{
"learncount": 8,
"learntimenow": 3,
"learntimes": 2,
"rType": 4,
"resourceId": 4,
"rloginTime": "2017-03-25 15:35:23",
"rlogoutTime": "2017-03-25 16:39:28",
"userId": 111,
"userResourceId": 32,
"word": "pen"
},
{
"learncount": 6,
"learntimenow": 4,
"learntimes": 2,
"rType": 5,
"resourceId": 5,
"rloginTime": "2017-03-25 15:25:23",
"rlogoutTime": "2017-03-25 16:12:08",
"userId": 111,
"userResourceId": 33,
"word": "coke"
}
],
"usertestcount": [
{
"test1count": 3,
"test1rightcount": 5,
"test2count": 1,
"test2rightcount": 3,
"test3count": 2,
"test3rightcount": 3,
"test4count": 2,
"test4rightcount": 3,
"testcount": 1,
"testrightcount": 3,
"userId": 111,
"usertestcountId": 15
}
]
},
"tableMeta": [
{
"lastModTime": 1489653263431,
"synId": 162,
"synTable": "user",
"userId": 111,
"version": 8
},
{
"lastModTime": 1489655096628,
"synId": 163,
"synTable": "Usercard",
"userId": 111,
"version": 7
},
{
"lastModTime": 1489655096631,
"synId": 164,
"synTable": "Userlearningstyle",
"userId": 111,
"version": 7
},
{
"lastModTime": 1489653263439,
"synId": 165,
"synTable": "usertestcount",
"userId": 111,
"version": 3
},
{
"lastModTime": 1489653263442,
"synId": 166,
"synTable": "userresource",
"userId": 111,
"version": 3
},
{
"lastModTime": 1489655096635,
"synId": 167,
"synTable": "usertest",
"userId": 111,
"version": 7
},
{
"lastModTime": 1489653263479,
"synId": 168,
"synTable": "userword",
"userId": 111,
"version": 3
}
]
},
"meta": {
"message": "success",
"status": 1
}
}
status |
message |
3 |
参数有误 |
4 |
token值无效 |
5 |
json数据格式或者数据类型有误! |
3000 |
数据同步失败, token值有误 |
6.轨迹数据回收接口
- 分支节点 :
/syn/trackdatas
- 请求方式 :
POST
- 请求参数
key |
类型 |
说明 |
token |
String |
|
json |
String |
json格式数据 |
- json格式数据格式
- 其中userBehaviour、userLogin不区分大小写
{
"trackData":{
"userBehaviour":[
{"userBehaviourId":1,"userId":24,"dowhat":"打豆豆","dowhen":"2017-03-25 02:36:23","dowhere":5},
{"userBehaviourId":2,"userId":24,"dowhat":"练习","dowhen":"2017-03-25 11:58:23","dowhere":3},
{"userBehaviourId":3,"userId":24,"dowhat":"看视频","dowhen":"2017-03-25 08:52:23","dowhere":2},
{"userBehaviourId":4,"userId":24,"dowhat":"看图片","dowhen":"2017-03-25 12:01:23","dowhere":4}
],
"userLogin":[
{"userLoginId":1,"userId":24,"loginState":3,"loginTime":"2017-03-25 02:36:23","logoutTime":"2017-03-26 03:32:23"},
{"userLoginId":1,"userId":24,"loginState":3,"loginTime":"2017-03-25 02:36:23","logoutTime":"2017-03-26 03:32:23"},
{"userLoginId":1,"userId":24,"loginState":3,"loginTime":"2017-03-25 02:36:23","logoutTime":"2017-03-26 03:32:23"},
{"userLoginId":1,"userId":24,"loginState":3,"loginTime":"2017-03-25 02:36:23","logoutTime":"2017-03-26 03:32:23"},
{"userLoginId":1,"userId":24,"loginState":3,"loginTime":"2017-03-25 02:36:23","logoutTime":"2017-03-26 03:32:23"}
]
}
}
{
"meta": {
"status": 1,
"message": "success"
},
"data": null
}
status |
message |
3 |
参数有误 |
4 |
token值无效 |
5 |
json数据格式或者数据类型有误! |