4. User Module Design
For the underlying database, call mysql's c api function to modify the database and save it internally.
Certain status variables (for example, user name, or left to the previous layer for completion ?), The upper layer provides
User management interface.
Class UserManage {
Private:
Char myuserid [20]; // user id, empty before login
Time logintime; // user logon time, used to calculate the stay time
Char loginhost [20]; // The Origin Site.
Public:
Int NewUser (char * userid, char * passwd );
Create a new user and check whether there is any other information,
Set the default value for firstlogintime and permissions.
Int UserLogin (char * userid, char * passwd );
User Login, password verification,
Int ChangePasswd (char * oldpasswd, char * newpasswd );
Change the password. The original password must be consistent.
Int ChangePriData (char * newname, char * newemail,
Char * newaddr );
Change basic data, nickname, email, address ....
Int ModifyNumData (int addlogin, int addpost );
Modify the number of articles, the number of previous posts, and other data .... Pay attention to the call object.
Int UserLogout ();
The user exits and modifies lastlogin, staytime, and loginhost.
// Common query command
Int QueryCommonData (const char * userid, int & loginnum,
Char * username, int & postnum,
Time & lastlogin, char * lasthost );
Query basic user information.
// Privileged command. The function determines the permission before completing the function.
Int QueryPriData (const char * userid, char * email,
Char * addr );
Query basic information. Ordinary people can only query themselves. They have the privilege to query other people.
Int ModifyUserLevel (BOOL isAdd, unsigned long level );
Modify user permissions,
Int ModifyUserId (char * oldid, char * newid );
Char * newemail, char * newaddr );
Modify basic user data.
Int ModifyUserNumdata (char * userid, int addlogin, int addpost );
Modify the number of articles and other data.
Int ModifyUserPasswd (char * userid, char * newpasswd );
Modify the user password.
}
The preceding functions are not difficult. They execute corresponding SQL statements to access the mysql database,
Do you want to include general commands in privileged commands? Is the permission check on this layer or the previous layer?
It is more important to check whether the program is clear or the code is concise.
Check the code. After all, check the access traffic and whether the upper-layer service layer should also consider the permission check.
What's the problem?