-
Notifications
You must be signed in to change notification settings - Fork 1
后端接口文档
本文档主要介绍了项目目前的接口功能,URL,需求,返回值等信息,以帮助前端更好对接及开发者进行测试。
用户登录接口
r'^signIn/$'
POST
username:用户名
mail :邮箱
password:密码
其中username和mail需求一个即可,优先匹配username。
{
'status': 1,
'length': 1,
'body': {
'username': u.username
}
}
用户注册接口
r'^signUp/$'
POST
username:用户名 unique
mail :邮箱 unique
password:密码
Ticket: 腾讯验证码的Ticket
Randstr: 腾讯验证码生成的Randstr
UserIP:用户IP地址
{
'status':1,
'length':1,
'body':{
'message': "新建用户{0}成功".format(username)},errMsg='',
}
}
更新用户个人信息
r'^updateUser/$'
POST,需要检查cookie和session的合法性
用户更新,至少包含username,其他内容为可选项(用来更新旧内容)
username:用户名
role:角色,使用'T', 'S', 'O'这类简写,e.g.[ ROLE_CHOICE = (
('T', 'Teacher'),
('S', 'Student'),
('O', 'Other'),
)]
gender:性别,使用简写,e.g.[ GENDER_CHOICE = (
('M', 'Male'),
('F', 'Female'),
('A', 'Anonymous'),
)]
self_introduction:自我介绍,字数上限256
{
'status':1,
'length':1,
'body':{'message': "用户{0}信息更新成功".format(username)},
errMsg='',
}
用户登出接口
r'^logout/$'
POST,需要检测cookie和session的合法性
登出,至少包含以下键
username
{
'status': 1,
'length': 1,
'body': {
'message': '登出成功'
}
}
获取CSRF令牌
r'^getToken/$'
get
无
{'token': token}
删除用户
r'^deleteUser/$'
POST,需要检验cookie和session的合法性
username=用户名
password=用户密码
{
'status': 1,
'body': '删除成功',
}
搜索教师接口
r'^searchTeacher/***$'
get
搜索教师,至少包含以下键
teacher_name:教师名字(contain)
{
'status': 1,
'length': len(teacher_list),
'body': [{'name': self.name,
'website': self.website,
'title': self.title},...],
errMsg=''
}
搜索课程接口
r'^searchCourse/***$'
get
搜索课程,至少包含以下键
course_name:课程名字(contain)
{
'status': 1,
'length': len(course_list),
'body': [{'name': self.name,
'website': self.website,
'course_ID': self.course_ID,
'description': self.description,
'course_type': self.course_type,
'credit': self.credit},teacher_list...,'department'=],
errMsg=""
}
搜索用户接口
r'^searchUser/***$'
get
搜索用户,至少包含以下键
username:用户名字(contain)
{
'status': 1,
'length': len(user_list),
'body': [{'username': self.username,
'mail': self.mail,
'role': self.role,
'gender': self.gender,
'self_introduction': self.self_introduction},...],
errMsg=""
}
获取用户信息
r'^getUserDetail/***$'
get
搜索用户,至少包含以下键
username:用户名字(唯一匹配)
{
'status': 1,
'length': 1,
'body': {'username': self.username,
'mail': self.mail,
'role': self.role,
'gender': self.gender,
'self_introduction': self.self_introduction},
errMsg=""
}
获取用户头像
r'^getUserProfilePhoto/***$'
get
username:用户名字(唯一匹配)
{
'status': 1,
'length': 1,
'body': {profile_photo: user.profile_photo},
errMsg=""
}
按部门搜索课程
r'^searchCourseByDepartment/$'
GET
department: 完整正确的学院名
course_name: 完整正确的课程名
类似searchCourse,只是将搜索范围限定到某个学院。
获取学院列表
r'^getDepartment/$'
GET
成功:body返回一个list,包括所有学院的信息
获取学院列表
r'^updateUserProfilePhoto/$'
POST,需要检查cookie和session的合法性
至少包含以下键
username :用户名
profile_photo :更新的头像链接
{ 'status': 1, 'length': 1, 'body': { 'message': "成功更新用户{0}的头像".format(user.username) } }
增加关注课程
r'^addselectCourse/$'
POST,需要检验cookie和session的合法性
至少包含以下键
user_id:学生id,
course_list:课程列表,
department_list:课程所属部门列表
成功:{'status':1,'length':1,'body':{'message': "添加课程关注成功".format(username)},errMsg='',}
失败:{'status'=-1}
删除关注课程
r'^delselectCourse/$'
POST,需要检验cookie和session的合法性
至少包含以下键
user_id:学生id,
course_list:课程列表,
department_list:课程所属部门列表
成功:{'status':1,'length':1,'body':{'message': "移除关注成功".format(username)},errMsg='',}
失败:{'status'=-1}
发表评论
r'^makeComment/$'
post,需要检验cookie和session的合法性
课程评论,至少包含以下键
username:用户名,
course_ID:课程id,
teacher_name: 教师名
content:评论内容,字数上限2048
parent_comment:父评论id
其中父评论id为-1表示没有父评论,且不是必选项(缺失默认为-1)
{
'status':1,
'length':1,
'body':{'message': "评论发布成功"},
errMsg='',
}
获取课程评论
r'^getCommentsByCourse/$'
GET
根据课程id获得相应评论,至少包含以下键
course_ID:课程id
在body中返回一个list,每项包含
rdict['username']=i.user.username
rdict['content']=i.comment.content
rdict['editTime']=i.comment.edit_time
rdict['createTime']=i.comment.create_time
rdict['commentID']=i.id
获取课程下某教师的评论
r'^getCommentsByTeacher/$'
GET
根据课程id获得相应评论,至少包含以下键
course_ID:课程id
teacher_ID:教师id
在body中返回一个list,每项包含
rdict['username']=i.user.username
rdict['content']=i.comment.content
rdict['editTime']=i.comment.edit_time
rdict['createTime']=i.comment.create_time
rdict['commentID']=i.id
编辑评论
r'^editComment/$'
POST,需要检验cookie和session的合法性
至少包括以下键
comment_id:评论id
content:评论内容,字数上限2048,teacher_name: 教师名
成功:
{
'status':1,
'length':1,
'body':{'message': "评论更新成功"},
errMsg=''
}
点赞/点踩评论
r'^rateComment/$'
POST,需要检验cookie和session的正确性
课程评分,至少包含以下键
username = 用户名
comment_ID = 评论id
type = agree/disagree
成功:
{
'status':1,
'length':1,
'body':{'message': ...},
errMsg=''
}
获取评论的赞数
r'^getRateComment/$'
get
课程评分,至少包含以下键
comment_ID = 评论id
成功:
{
'status': 1,
'length': 1,
'body': {'rate': comment.rate}
}
获取高赞评论
r'^getHotComment/$'
get
课程评分,至少包含以下键
course_ID = 课程ID
成功:
{
'status': 1,
'length': len(retList),
'body': 高赞评论,
}
对课程打分
r'^makeRank/$'
POST,需要检验cookie和session的正确性
课程评分,至少包含以下键
username:用户名,
course_ID:课程id,
difficulty_score:有趣程度,整形,1-5
funny_score:有趣程度,整形,1-5
gain_score:收获指数,整形,1-5
recommend_score:推荐指数,整形,1-5
成功:
{
'status':1,
'length':1,
'body':{'message': "评分发布成功"},
errMsg=''
}
新评价会覆盖已有评价
获取一门课的评分
r'^getRankByCourse/$'
GET
根据课程id获得相应评论,至少包含以下键
course_ID:课程id
成功:
{
'status': 1,
'length': 评分人数,
'body': {
'difficulty_score',
'funny_score',
'gain_score',
'recommend_score'
}
}
获取排名较高的课程
r'^getRankBySortedCourse/$'
GET
无
成功:
{
'status': 1,
'length': len(body),
'body': [{'course_info','position','people',
'difficulty_score',
'funny_score',
'gain_score',
'recommend_score'
},...]
}
获取排名较高的教师
r'^getRankBySortedTeacher/$'
GET
无
成功:
{
'status': 1,
'length': len(body),
'body': [{'teacher_info','position','people',
'difficulty_score',
'funny_score',
'gain_score',
'recommend_score'
},...]
}
获取所有课程的评分
r'^getAllRank/$'
GET
无
成功:
{
'status': 1,
'length': len(body),
'body': [{'teacher_info','position','people',
'difficulty_score',
'funny_score',
'gain_score',
'recommend_score'
},...]
}
设置密保问题
r'^setQuestion/$'
POST,需要检验cookie和session的正确性
至少包含以下键
username = 用户名
question = 问题
answer = 答案
成功:
{
'status':1,
'length':1,
'body':{'message': "问题设置成功"},
'errMsg':'',
}
重置密码
r'^resetPassword/$'
POST
至少包含以下键
username = 用户名
question = 问题
answer = 答案
npassword = 新密码
成功:
{
'status':1,
'length':1,
'body':{'message': "密码重置成功"},
'errMsg':'',
}