If you are not logged in, return directly to sessionerr and jump to the login interface
After entering the function, first get the user_id in the g object
Get parameter image_file
If the parameter is None (that is, the picture is not transmitted), an error is returned
Read file
save Picture
There are several ways to save pictures
Database server: high requirements for server nature, resources, and data software
Server directory: to prevent duplicate file names, resources, performance requirements, etc.,
Third-party platform: such as Qiniu cloud platform (recommended by personal system)
Build your own file storage server: such as FastDFS fast distributed file storage system, mainly used for e-commerce companies, mainly pictures; HDFS Hadoop distributed file system (any file will do)
Save image path
Save the picture address in the database, just save the file name, the first half of the domain name of the picture address is saved in the constant file
Fourth, obtain personal information (refresh the user information page)
1. Modify the user name interface design
1.1 Request method
Options
Program
Request method
GET
Request address
/user
1.2 Request parameters: none
1.3 Response results
first name
Types of
Do you have to
Description
errno
String
no
error code
errmsg
String
no
Error content
data
dictionary
no
Personal information dictionary
2. Modify the user name interface definition
First apply the login decorator
If you are not logged in, return directly to sessionerr and jump to the login interface
After entering the function, first get the user_id in the g object
Obtain user information according to user_id
If the user information does not exist or the data is reported incorrectly, return the error information according to the personal information dictionary (define the dictionary method to return personal information in the User class)
It needs to be connected to the public security system and can be developed according to the interface document. Individuals cannot complete data verification.
This project does not judge the real-name authentication information for the time being, and save it directly to the database
1. Real-name authentication interface design
1.1 Request method
Options
Program
Request method
POST
Request address
/users/auth
1.2 Request parameters: form parameters
parameter name
Types of
Must pass
Description
id_card
string
Yes
identity number
real_name
string
Yes
actual name
1.3 Response results
first name
Types of
Do you have to
Description
errno
String
no
error code
errmsg
String
no
Error content
data
dictionary
no
{“id_card”:“xxx”,“real_name”:“XXXXX”}
2. Real-name authentication interface definition
First apply the login decorator
If you are not logged in, return directly to sessionerr and jump to the login interface
After entering the function, first get the user_id in the g object
Get parameters and judge validity
Whether both parameters exist
Whether the two energy numbers meet the specification
Call the public security interface (this function is temporarily unavailable), the default verification is successful
Update the user's real name and ID according to user_id
3. Optimize the definition of real-name authentication interface
After the user’s real-name authentication, the real-name authentication should not be performed again and cannot be modified
After entering the function, it is directly judged whether the user has registered with the real name, if it has been registered, it will report an error and return
Get user information through user_id
Through all[user.real_name,user_id_card], it is judged that the real name has been registered
try:
user=User.query.get(user_id)except Exception as e:
logging.error(e)return jsonify(errno=RET.DBERR,errmsg="用户信息查询失败")ifall([user.real_name,user.id_card]):return jsonify(errno=RET.DATAEXIST,errmsg="用户已实名认证过,不能再修改")
Seven, obtain real-name authentication information
It needs to be connected to the public security system and can be developed according to the interface document. Individuals cannot complete data verification.
This project does not judge the real-name authentication information for the time being, and save it directly to the database
1. Interface design for obtaining real-name authentication information
1.1 Request method
Options
Program
Request method
POST
Request address
/users/auth
1.2 Request parameters: none
1.3 Response results
first name
Types of
Do you have to
Description
errno
String
no
error code
errmsg
String
no
Error content
data
dictionary
no
{“id_card”:“xxx”,“real_name”:“XXXXX”}
2. Obtain the real-name authentication interface definition
First apply the login decorator
If you are not logged in, return directly to sessionerr and jump to the login interface
After entering the function, first get the user_id in the g object
Update the user's real name and ID according to user_id