HTTP
全局規(guī)范
URL
URL的組成:基本的網(wǎng)絡(luò)地址 + 分支節(jié)點(diǎn)
http://172.19.201.155:8443/datasyn 為 基本的網(wǎng)絡(luò)地址
/login 為 分支節(jié)點(diǎn)
http://172.19.201.155:8443/datasyn/login 組成完整的 URL
當(dāng)前統(tǒng)一的基本網(wǎng)絡(luò)地址為 http://172.19.201.155:8443/datasyn
請(qǐng)求方式
|POST
|GET
請(qǐng)求消息頭
請(qǐng)求參數(shù)
鍵值對(duì)(key value形式)
默認(rèn)都是必選參數(shù)
請(qǐng)求參數(shù)
鍵值對(duì)(key value形式)
響應(yīng)的狀態(tài)碼
統(tǒng)一的返回碼為: 200 (注:只要訪問服務(wù)器成功,一律返回200)
響應(yīng)的格式
Json
響應(yīng)的JSON規(guī)范
成功
{
"meta": {
"status": 1,
"message": "success"
},
"data": ....
}
成功的標(biāo)記為 status為 1
根據(jù)具體的請(qǐng)求嫉入,如果需要返回值 data節(jié)點(diǎn) 包含的是 返回結(jié)果
不需要需要返回值 熄诡,則沒有data節(jié)點(diǎn)
{
"meta": {
"status": 錯(cuò)誤編碼,
"message": "錯(cuò)誤原因"
},
"data": null
}
失敗的標(biāo)記為 status為 除1以外的其它編碼
status不為1時(shí)至非,message為錯(cuò)誤原因
- 同步數(shù)據(jù)表:
user抽减、Usercard、Userlearningstyle速种、usertestcounnt根灯、userresource、userword中符、usertest姜胖,這幾個(gè)表在json中作為key值時(shí)區(qū)分大小寫。必須按照這個(gè)格式寫
- 軌跡數(shù)據(jù)表:
usertest淀散、userlogin右莱,這幾個(gè)表在json中作為key值時(shí)區(qū)分大小寫蚜锨。必須按照這個(gè)格式寫
- 日期格式:json中傳輸?shù)娜掌诟袷?
yyyy-MM-dd HH:mm:ss
- 注:元數(shù)據(jù)表中的lastModTime為long類型,所以前端應(yīng)該傳輸數(shù)值型值慢蜓。
1.注冊(cè)接口
- 分支節(jié)點(diǎn) :
/user/register
- 請(qǐng)求方式 :
POST
- 請(qǐng)求參數(shù)
key |
類型 |
說明 |
loginName |
String |
|
password |
String |
|
realName |
String |
|
sex |
int |
1:代表男亚再,0:代表女 |
school |
String |
學(xué)校 |
grade |
String |
班級(jí) |
classNum |
int |
年級(jí),值1到6 |
englishscore |
int |
英語分?jǐn)?shù)晨抡,值1到200 |
{
"meta": {
"status": 1,
"message": "success"
},
"data": {
"userId": 22
}
}
status |
message |
3 |
參數(shù)有誤! |
2000 |
用戶已存在 |
2.登錄接口
- 分支節(jié)點(diǎn) :
/user/login
- 請(qǐng)求方式 :
POST
- 請(qǐng)求參數(shù)
key |
類型 |
說明 |
loginName |
String |
|
password |
String |
|
synDevice |
String |
設(shè)備標(biāo)識(shí) |
{
"meta": {
"status": 1,
"message": "success"
},
"data": {
"token": "21:1489385636029",
"synFlage": 4,
"message": "有可能有數(shù)據(jù)遺留在當(dāng)前的設(shè)備上"
}
}
synFlage |
message |
1 |
同步成功 |
2 |
有可能有數(shù)據(jù)遺留在上次操作的設(shè)備上 |
3 |
在上次登錄操作的設(shè)備上數(shù)據(jù)同步失敗 |
4 |
有可能有數(shù)據(jù)遺留在當(dāng)前的設(shè)備上 |
5 |
上次在當(dāng)前設(shè)備上數(shù)據(jù)同步失敗 |
status |
message |
2001 |
參數(shù)有誤! |
3.忽略同步提示接口
- 分支節(jié)點(diǎn) :
/syn/ignore
- 請(qǐng)求方式 :
POST
- 請(qǐng)求參數(shù)
key |
類型 |
說明 |
token |
String |
|
synDevice |
String |
設(shè)備標(biāo)識(shí) |
{
"meta": {
"status": 1,
"message": "success"
},
"data": null
}
status |
message |
4 |
token值無效 |
4.獲取同步元數(shù)據(jù)接口
- 分支節(jié)點(diǎn) :
/syn/synmetas
- 請(qǐng)求方式 :
POST
- 請(qǐng)求參數(shù)
key |
類型 |
說明 |
token |
String |
|
json |
String |
json格式數(shù)據(jù) |
- json格式數(shù)據(jù)格式
- 其中synTable的值不區(qū)分大小寫氛悬。且synId、userId字段屬于無關(guān)字段(即不會(huì)起任何作用)
{
"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 |
參數(shù)有誤 |
4 |
token值無效 |
5 |
json數(shù)據(jù)格式或者數(shù)據(jù)類型有誤! |
5.數(shù)據(jù)同步接口
- 分支節(jié)點(diǎn) :
/syn/syntabledata
- 請(qǐng)求方式 :
POST
- 請(qǐng)求參數(shù)
key |
類型 |
說明 |
token |
String |
|
json |
String |
json格式數(shù)據(jù) |
- json格式數(shù)據(jù)格式
- 其中synTable的值不區(qū)分大小寫耘柱。tableData中的user等key值不區(qū)分大小寫如捅。
{
"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 |
參數(shù)有誤 |
4 |
token值無效 |
5 |
json數(shù)據(jù)格式或者數(shù)據(jù)類型有誤! |
3000 |
數(shù)據(jù)同步失敗, token值有誤 |
6.軌跡數(shù)據(jù)回收接口
- 分支節(jié)點(diǎn) :
/syn/trackdatas
- 請(qǐng)求方式 :
POST
- 請(qǐng)求參數(shù)
key |
類型 |
說明 |
token |
String |
|
json |
String |
json格式數(shù)據(jù) |
- json格式數(shù)據(jù)格式
- 其中userBehaviour调煎、userLogin不區(qū)分大小寫
{
"trackData":{
"userBehaviour":[
{"userBehaviourId":1,"userId":24,"dowhat":"打豆豆","dowhen":"2017-03-25 02:36:23","dowhere":5},
{"userBehaviourId":2,"userId":24,"dowhat":"練習(xí)","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 |
參數(shù)有誤 |
4 |
token值無效 |
5 |
json數(shù)據(jù)格式或者數(shù)據(jù)類型有誤! |