Fastapi (63) develop “online course learning system” and sort out the interface required by the system

Time:2022-7-30

For the previous articleFastapi (62) actual development of online course learning system needs analysisAccording to the function of the requirements, we sort out the required interfaces, roughly plan the existing interfaces, and publish them as the design of our first edition of interfaces, and then we design the interfaces according to the design.

  

2.1 user registration interface

Path: /user/register

Request method: Post

Request format: JSON

Depend on login: no

Parameters:

Parameter name Parameter meaning Whether the parameter is required Parameter type
username User name 8-16 bits yes str
password Password, 8-16 bits in length, MD5 encryption yes str
role Type, student or teacher, default: Student yes str
jobnum Job number, 8 digits no int
studentnum Student status number, 16 digits no int
sex Gender, male and female. yes str
age Age, must be greater than 18 and less than 65 yes int

 

Interface return: JSON

{
 "code":200,
"Data": 'success',
"Message": "success"
}

Return code description

code meaning
200 login was successful
100101 login has failed
100102 Identity and corresponding number do not match
100103 Age does not match
100104 repeat of user name
100105 Password encryption failed
100106 User name length does not match

 

2.2 login interface

Path: /user/login

Request method: Post

Request format: JSON

Depend on login: no

Request parameters

field meaning Whether it is necessary type
username user name yes str
password password yes str

Return to example

{
 "code":200,
 "data":{
   "token":""
},
"Message": "success"
}

Return status code description

 

code meaning
200 success
100201 Login failed
100202 Repeat login
100203 Failed to generate token
100204 The number of incorrect password entries is too many, and the account is temporarily locked. Please login again in 30min
100205 user does not exist
100206 Password error

 

2.3 personal information

Path: /user/info

Request method: Post

Request format: JSON

Request parameters: None

Depend on login: Yes

Return format: JSON

{
 "code":200,
 "data":{
   
},
"Message": "success"
}

Return status code description

code meaning
200 success
2.4 change password

Path: /user/changepassword

Request method: Post

Request format: JSON

Return format: JSON

Depend on login: Yes

parameter explain Whether it is necessary type
oldpassword Original password yes str
newspassword New password yes str

Return to example

{
 "code":200,
"Data": 'success',
"Message": "success"
}

Return status code description

Status code meaning
200 success
100301 Original password verification failed
100302 Failed to save password
100303 New password length mismatch
100304 Old and new passwords cannot be the same
2.5 message

Path: /user/addmessage

Request method: Post

Request format: JSON

Depend on login: Yes

Request parameters:

parameter meaning Whether it is necessary type
id User ID yes int
message content yes str

Return format: JSON

{
 "code":200,
 "data":{
   
},
"Message": "success"
}

Return status code description

Status code meaning
200 success
100501 I can’t leave messages for myself
100502 The length of the message is 5-500 characters
100503 Message user does not exist

 

2.6 check the message

Path: /user/viewmessage

Request method: get

Request format: JSON

Depend on login: Yes

Request parameters: None

Return format: JSON

{
 "code":200,
 "data":{
   
},
"Message": "success"
}

Return status code description

Status code meaning
200 success
2.7 message list

Path: /user/messagelist

Request method: get

Request format: JSON

Depend on login: Yes

Request parameters: None

Return format: JSON

{
 "code":200,
 "data":[
   
],
"Message": "success"
}

Return status code description

Status code meaning
200 success
2.8 reply to the message

Path: /user/rebackmessage/

Request method: Post

Request format: JSON

Depend on login: Yes

Request parameters

parameter meaning Whether it is necessary type
id ID of the message yes int
message content yes str

Return format: JSON

{
 "code":200,
 "data":{},
"Message": "success"
}

Return status code description

Status code meaning
200 success
100801 Failed to reply to the message
100802 Reply message content cannot be empty
100803 The reply should be 5-500 words
100804 Reply message ID does not exist
2.9 delete message

Path: /user/deletemessage/{id}

Request method: get

Request format: JSON

Depend on login: Yes

Request parameters:

parameter meaning Whether it is necessary type
id ID of the message yes int

Return format: JSON

{
 "code":200,
 "data":"ok",
"Message": "success"
}

Return status code description

Status code meaning
200 success
100901 Delete message does not exist
100902 Insufficient permissions
2.10 creating courses

Path: /course/create

Request method: Post

Request format: JSON

Depend on login: Yes

Request parameters:

parameter meaning Whether it is necessary type
name Course name (length 2-50) yes str
icon Icon of the course no str
desc describe no text
catalog catalogue no json
onshelf Whether to put on the shelf (0 on the shelf, 1 off the shelf) yes int

Return format: JSON

{
 "code":200,
 "data":"ok",
"Message": "success"
}

Status code description

Status code meaning
200 success
101002 Course name cannot be duplicate
101003 Course creation failed
2.11 course details

Path: /course/detail/{id}

Request method: get

Request format: JSON

Depend on login: Yes

Request parameters

parameter meaning Whether it is necessary type
id Course ID yes int

Return format: JSON

{
 "code":200,
 "data":"ok",
"Message": "success"
}

Status code description

Status code meaning
200 success
101101 Course does not exist
2.12 course editing

Path: /course/edit

Request method: put

Request format: JSON

Depend on login: Yes

Request parameters

parameter meaning Whether it is necessary type
name Course name (length 2-50) yes str
id Course ID yes int
icon Course Icon no str
desc Course description no str
catalog Course catalogue no json
onshelf Whether to put on the shelf (0 on the shelf, 1 off the shelf) yes int

Return format: JSON

{
 "code":200,
 "data":"ok",
"Message": "success"
}

Status code description

Status code meaning
200 success
101201 Course ID does not exist
101202 Insufficient permissions
101203 Course name cannot be duplicate
2.13 view comments

Path: /course/viewcomponents/{id}

Request method: get

Request format: None

Depend on login: Yes

Request parameters

parameter meaning Whether it is necessary type
id Course ID yes int

Return format: JSON

{
 "code":200,
 "data":"ok",
"Message": "success"
}

Status code description

Status code meaning
200 success
101301 Course ID does not exist
2.14 comments

Path: /course/comments

Request method: Post

Request format: JSON

Depend on login: Yes

Request parameters

parameter meaning Whether it is necessary type
id Course ID yes int
content Comment content yes str

Return format: JSON

{
 "code":200,
 "data":"ok",
"Message": "success"
}

Status code description

Status code meaning
200 success
101401 Course ID does not exist
101402 Comment content cannot be empty
101403 Comment failed
101404 I can’t comment on my courses
2.15 joining the course

Path: /course/add/{id}

Request method: Post

Request format: JSON

Depend on login: Yes

Request parameters

parameter meaning Whether it is necessary type
id Course ID yes int

Return format: JSON

{
 "code":200,
 "data":"ok",
"Message": "success"
}

Status code description

Status code meaning
200 success
101501 Course ID does not exist
101502 Courses cannot be added repeatedly
101503 You can’t join your own course
2.16 withdrawal from the course

Path: /course/quit/{id}

Request method: Post

Request format: JSON

Depend on login: Yes

Request parameters

parameter meaning Whether it is necessary type
id Course ID yes int

Return format: JSON

{
 "code":200,
 "data":"ok",
"Message": "success"
}

Status code description

Status code meaning
200 success
101601 Course ID does not exist
101602 Course is not in your list
2.17 course list

Path: /course/list

Request method: get

Request format: JSON

Depend on login: Yes

Request parameters: None

Return format: JSON

{
 "code":200,
 "data":"ok",
"Message": "success"
}

Status code description

Status code meaning
200 success
2.18 course list (courses of current user)

Path: /course/courselist

Request method: get

Request format: JSON

Depend on login: Yes

Request parameters:

nothing

Return format: JSON

{
 "code":200,
 "data":"ok",
"Message": "success"
}

Status code description

Status code meaning
200 success
2.19 list of recommended courses

Path: /course/recommend

Request method: get

Request format: JSON

Depend on login: Yes

Request parameters: None

Return format: JSON

{
 "code":200,
 "data":"ok",
"Message": "success"
}

Status code description

Status code meaning
200 success
2.20 course likes

Path: /course/like/{id}

Request method: get

Request format: JSON

Depend on login: Yes

Request parameters

parameter meaning Whether it is necessary type
id Course ID yes int

Return format: JSON

{
 "code":200,
 "data":"ok",
"Message": "success"
}
2.21 course launch

Path: /course/onshelf/{id}

Request method: get

Request format: JSON

Depend on login: Yes

Request parameters

parameter meaning Whether it is necessary type
id Course ID yes int

Return format: JSON

{
 "code":200,
 "data":"ok",
"Message": "success"
}

Status code description

Status code meaning
200 success
102101 Course does not exist
102102 The course has been put on the shelves
102103 I can only put my own courses on the shelves
102104 Insufficient permissions
2.22 course off the shelf

Path: /course/offshelf/{id}

Request method: get

Request format: JSON

Depend on login: Yes

Request parameters

parameter meaning Whether it is necessary type
id Course ID yes int

Return format: JSON

{
 "code":200,
 "data":"ok",
"Message": "success"
}

Status code description

Status code meaning
200 success
102201 Course does not exist
102202 The course has been taken off the shelves
102203 You can only take your own courses off the shelf
102204 Insufficient permissions

The first version of the corresponding interface has been sorted out. Next time, we will share the design of the required database.

Postscript

 

The article is first published on official account. Welcome to pay attention.

 

 

        

Recommended Today

JS generate guid method

JS generate guid method https://blog.csdn.net/Alive_tree/article/details/87942348 Globally unique identification(GUID) is an algorithm generatedBinaryCount Reg128 bitsNumber ofidentifier , GUID is mainly used in networks or systems with multiple nodes and computers. Ideally, any computational geometry computer cluster will not generate two identical guids, and the total number of guids is2^128In theory, it is difficult to make two […]