Idealisan

《生蚝单词》项目文档

《生蚝单词》项目文档

项目信息

名称:生蚝单词

相关链接

实践课程

2020年寒假研发实习流程

项目开发

Gitee仓库

原型地址

UI地址

pxCookie地址

前端Github仓库

后端Github仓库

生蚝单词-Online

人员分工

前端 ADC(5)

郑文伟

林雪

潘俊颐

潘喜睿

吴子涵

后端 APC(5)

孙煜晗

顾晓健

宋诚

肖俊杰

方世耀

辅助 SUP(10)

谭泽凡

王雨江

麦韵淇

陈靖明

王青青

夏乐坤

王杰

刘澳

郭雅梅

汪越

测试 T(20)

@全体成员

页面列表

页面
首页
登陆
注册
个人信息
好友对战-创建房间
好友对战-房间界面
好友对战-邀请好友
好友对战-邀请好友-等待超时
好友对战-邀请好友-好友接受链接
好友对战-邀请好友-正常加入
被邀请人加入房间
答题页面-题目页面
答题页面-用户答题
答题页面-答题结果
排行榜

接口文档

登录

url:http://39.107.84.0:8600/login

method:post

body

{“username”:”test5″,”password”:”123456″}

没有该用户名返回:

{

    "msg": "无此用户",

    "respCode": 2

}

密码错误返回:

{

“msg”: “密码错误”,

“respCode”: 2

}

正确登录返回:

{

    "msg": "登录成功",

    "data": {

        "score": 1,

        "password": "111111",

        "faceId": 12,

        "userId": 1,

        "username": "test"

    },

    "respCode": 1

}

注册

url:http://39.107.84.0:8600/register

method:post

body

{

    "username":"test1",

    "password":"123456",

"faceId":11//这个字段可以没有,没有就是随机一个头像

}

若已存在用户名返回:

{

    "msg": "该用户名已存在",

    "respCode": 2

}

注册成功返回:

{

    "msg": "注册成功",

    "respCode": 1

}

创建房间

url:http://39.107.84.0:8600/createRoom?hostId=1 //只有hostId一个参数,前端自己的userId

method:get

一定会成功创建并返回:

{

    "respCode": 1,

    "roomId": 2

}

获取排名

url:http://39.107.84.0:8600/getRank?userId=1

方法:get

获取排名:

{

    "yourRank": {

        "data": {

            "score": 10,

            "winCnt": 0,

            "anonymous": false,

            "faceId": 4,

            "userId": 1,

            "username": "test"

        },

        "rank": 10

    },

    "allRank": [

        {

            "score": 110,

            "winCnt": 0,

            "faceId": 7,

            "userId": 11,

            "username": "123"

        },

        {

            "score": 100,

            "winCnt": 0,

            "faceId": 2,

            "userId": 10,

            "username": "wuzihan"

        },

        {

            "score": 90,

            "winCnt": 0,

            "faceId": 15,

            "userId": 9,

            "username": "LOMO"

        },

        {

            "score": 80,

            "winCnt": 0,

            "faceId": 14,

            "userId": 8,

            "username": "test2020"

        },

        {

            "score": 70,

            "winCnt": 0,

            "faceId": 1,

            "userId": 7,

            "username": "test1321"

        },

        {

            "score": 60,

            "winCnt": 0,

            "faceId": 1,

            "userId": 6,

            "username": "testdemouser001"

        },

        {

            "score": 50,

            "winCnt": 3,

            "faceId": 1,

            "userId": 5,

            "username": "test1121"

        },

        {

            "score": 40,

            "winCnt": 0,

            "faceId": 1,

            "userId": 4,

            "username": "test8"

        },

        {

            "score": 30,

            "winCnt": 0,

            "faceId": 1,

            "userId": 3,

            "username": "test5"

        },

        {

            "score": 20,

            "winCnt": 0,

            "faceId": 1,

            "userId": 2,

            "username": "xialekun"

        }

    ]

}

访客进入房间

url:http://39.107.84.0:8600/enterRoom?guestId=5&roomId=7

房间号失效返回:(当房主退出房间,或游戏结束,房间失效)

{

    "msg": "该房间已失效",

    "respCode": 2

}

没有房间号返回:

成功返回:

{

    "msg": "进入房间成功",

    "respCode": 1

}

退出房间

url:http://39.107.84.0:8600/quitRoom?roomId=7

返回:

{

    "msg": "退出房间成功",

    "respCode": 1

}

查询房间

url:http://39.107.84.0:8600/queryRoom?roomId=7

双方都已进入房间,返回:

{

    "data": {

        "roomStatus": 0,

        "guestScore": 690,

        "hostScore": 680,

        "hostStatus": 1,

        "hostInfo": {

            "score": 110,

            "winCnt": 0,

            "anonymous": false,

            "faceId": 7,

            "userId": 11,

            "username": "123"

        },

        "hostId": 11,

        "guestIndex": 4,

        "guestStatus": 1,

        "hostIndex": 4,

        "guestInfo": {

            "score": 0,

            "winCnt": 0,

            "anonymous": false,

            "faceId": 11,

            "userId": 17,

            "username": "Guest"

        },

        "guestId": 17,

        "roomId": 62

    },

    "respCode": 1

}

未进入房间的用户,其信息将返回null,注意检查:

{

    "data": {

        "roomStatus": 0,

        "guestScore": 2,

        "hostScore": 45,

        "hostStatus": 1,

       "hostInfo": {

            "score": 110,

            "winCnt": 0,

            "anonymous": false,

            "faceId": 7,

            "userId": 11,

            "username": "123"

        },

        "hostId": 123,

        "guestIndex": 1,

        "guestStatus": 1,

        "hostIndex": 1,

        "guestInfo": null,

        "guestId": 665,

        "roomId": 54

    },

    "respCode": 1

}

更新自己的分数:

url:http://39.107.84.0:8600/updateScore?roomId=6&userId=2&curScore=10

若游戏未结束,返回:

{

    "msg": "更新分数成功",

    "respCode": 1

}

游戏结束,返回:

{

    "msg": "游戏已结束",

    "respCode": 2

}

根据房间获取题目

url:http://39.107.84.0:8600/getQuestions?roomId=7

返回:

{

    "data": [

        {

            "desp": "bre_st",

            "chinese": null,

            "answer": "A",

            "action": "fill",

            "choices": [

                "a",

                "b",

                "c",

                "d"

            ],

            "qid": 32

        },

        {

            "desp": "rumble",

            "chinese": null,

            "answer": "C",

            "action": "tr",

            "choices": [

                "弄皱",

                "发牢骚",

                "隆隆作响",

                "没有正确答案"

            ],

            "qid": 12

        },

        {

            "desp": "b_nana",

            "chinese": null,

            "answer": "A",

            "action": "fill",

            "choices": [

                "a",

                "b",

                "c",

                "d"

            ],

            "qid": 61

        },

        {

            "desp": "t_ial ",

            "chinese": null,

            "answer": "B",

            "action": "fill",

            "choices": [

                "a",

                "r",

                "c",

                "d"

            ],

            "qid": 82

        },

        {

            "desp": "l_g ",

            "chinese": null,

            "answer": "B",

            "action": "fill",

            "choices": [

                "a",

                "e",

                "c",

                "d"

            ],

            "qid": 64

        },

        {

            "desp": "_pple",

            "chinese": null,

            "answer": "A",

            "action": "fill",

            "choices": [

                "a",

                "b",

                "c",

                "d"

            ],

            "qid": 52

        },

        {

            "desp": "br_",

            "chinese": null,

            "answer": "A",

            "action": "fill",

            "choices": [

                "a",

                "b",

                "c",

                "d"

            ],

            "qid": 47

        },

        {

            "desp": "bet_er",

            "chinese": null,

            "answer": "D",

            "action": "fill",

            "choices": [

                "a",

                "b",

                "c",

                "t"

            ],

            "qid": 45

        },

        {

            "desp": "mixture",

            "chinese": null,

            "answer": "B",

            "action": "tr",

            "choices": [

                "混合",

                "呻吟声",

                "模型",

                "方式"

            ],

            "qid": 99

        },

        {

            "desp": "sc_ence ",

            "chinese": null,

            "answer": "B",

            "action": "fill",

            "choices": [

                "a",

                "i",

                "c",

                "d"

            ],

            "qid": 75

        }

    ],

    "respCode": 1

}


游戏结束

url:http://39.107.84.0:8600/endGame?roomId=1

返回:

{

“msg”: “游戏结束”,

“respCode”: 1

}

修改密码

url:http://39.107.84.0:8600/resetPassword

RequestBody:

{

“password”:”123456″,

“username”:”test”,

“newPassword”:”111111″

}

修改头像

url:http://39.107.84.0:8600/changeFace?userId=1&faceId=12

返回:

{

    "msg": "更换头像成功",

    "respCode": 1

}

若faceId大于20返回:

{

    "msg": "头像ID不合法,超出20",

    "respCode": 2

}

修改用户名

url:http://39.107.84.0:8600/changeUsername?userId=2&username=xialekun

若用户名被使用,返回:

{

    "msg": "用户名已存在",

    "respCode": 2

}

若用户名未被使用,返回:

{

    "msg": "更改用户名成功",

    "respCode": 1

}

用户管理

1.根据用户id获得用户的所有字段

url http://39.107.84.0:8600/getAllMyInfo?userId=1

成功返回

{

    "userInfo": {

        "score": 10,

        "password": "111111",

        "winCnt": 0,

        "faceId": 12,

        "userId": 1,

        "username": "test"

    },

    "respCode": 1

}

暂未定义错误返回

对战接口

1.创建房间

路径:/battle/new?id=1

成功返回:房间信息,其中guestId若为-1则意味着受邀用户暂未进入房间

{

    "id": 1204816586,

    "creatorId": 1,

    "guestId": -1,

    "creatorCredits": 0,

    "guestCredits": 0,

    "creatorQuestionIndex": 0,

    "guestQuestionIndex": 0

}

受邀进入房间

路径:/battle/step_in?id=2&battleId=1204816586

路径中id是受邀用户的id,可以是已登录用户的id,也可以是未登录自动分配的id

成功返回:

{

    "id": 1204816586,

    "creatorId": 1,

    "guestId": 2,

    "creatorCredits": 0,

    "guestCredits": 0,

    "creatorQuestionIndex": 0,

    "guestQuestionIndex": 0

}

轮询接口,查询房间最新信息

路径:/battle/refresh?id=1204816586

成功返回:

{

    "id": 54,

    "creatorId": 123,

    "guestId": 665,

    "creatorCredits": 45,

    "guestCredits": 500,

    "creatorQuestionIndex": 4,

    "guestQuestionIndex": 2,

    "roomStatus": -1 //-3:房间已结束游戏;-1 异常中断退出;

}

问题列表接口

Demo中的接口的路径、参数和返回信息与此处不同,不应使用Demo中的接口。

路径:/getQuestions?roomId=54

成功返回:

  {

    "data": [

        {

            "desp": "b_nana",

            "chinese": "香蕉",

            "answer": "A",

            "choices": [

                "a",

                "b",

                "c",

                "d"

            ],

            "qid": 1

        },

        {

            "desp": "b_nana",

            "chinese": "香蕉",

            "answer": "A",

            "choices": [

                "a",

                "b",

                "c",

                "d"

            ],

            "qid": 3

        },

        {

            "desp": "b_nana",

            "chinese": "香蕉",

            "answer": "A",

            "choices": [

                "a",

                "b",

                "c",

                "d"

            ],

            "qid": 4

        },

        {

            "desp": "b_nana",

            "chinese": "香蕉",

            "answer": "A",

            "choices": [

                "a",

                "b",

                "c",

                "d"

            ],

            "qid": 7

        },

        {

            "desp": "b_nana",

            "chinese": "香蕉",

            "answer": "A",

            "choices": [

                "a",

                "b",

                "c",

                "d"

            ],

            "qid": 9

        }

    ],

    "respCode": 1

}


5.更新分数

路径:/battle/update/credit?user=1&battle=1204816586&total=67

暂无错误返回,如果出错那就是http错误。

成功返回:

{

“msg”:”success”,

“respCode”:1

}

6.结束对战,保存历史分数

成功访问后,房间状态会变为-1

路径:/battle/saveScore?id=1&battleId=1234123

成功返回:用户的所有字段

{

    "userInfo": {

        "score": 90,//最新分数

        "winCnt": 0,

        "anonymous": false,

        "faceId": 15,

        "userId": 9,

        "username": "LOMO"

    },

    "respCode": 1

}

7.获得一个用户id

路径:/getAnonymousId

无需任何参数

成功返回:

{

    "msg": "成功",

    "userInfo": {

        "score": 0,

        "password": "Guest",

        "winCnt": 0,

        "faceId": 9,

        "userId": 15,

        "username": "Guest"

    },

    "userId": 15,

    "respCode": 1

}





分类

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注