The Paozhu framework has built-in SAAS mode support, which can currently be ID multi tenant mode and domain isolation mode. There is a simple management multi tenant management page in the background, and it can also be multi virtual host mode, which is domain isolation. This pattern can be presented in other ways, such as similar to microservice patterns, where controller/src
creates a directory. If it is similar to a domain name, with a dot in the middle, then this directory is independently annotated as a function.
For example, we can create two directories in controller/src
aaa.com
bbb.com
, both of which have news annotation functions and different implementation functions
This mode can manage complex large-scale projects, and it is also a monolithic mode. More usage methods may be freely developed after becoming familiar with it.
First, configureconf/server.conf
Assuming cn.aaa.com
domain name configuration SAAS mode
[cn.aaa.com]
wwwpath=/www/user/www/aaa
http2_enable=1
upload_max_size=16777216
siteid=9
groupid=0
alias_domain=aaa.com
themes=cn
wwwpath is the root directory of the domain name cn.aaa.com
, This can be manually created or created via the super admin backend. For details, Please refer to the superadmin
table in the cppcms database, where the basesitepath
field indicates the base directory for multi-tenancy under this super administrator's account
http2_enable=1 means to enable http/2
upload_max_size=16777216 The maximum size for uploading files is 16M
siteid=9 It is an ID created by a super administrator, as detailed in the cppcms database siteinfo
table, where the userid
field is located
groupid=0 It is a backup, used for preset grouping
alias_domain=aaa.com By default, there is no need to set it, which means that the annotation functions in the controller/src
directory aaa.com
will be used. If there are no annotation functions that the framework comes with by default, other domains can also use the annotation functions in this directory, as long as the alias_domain=aaa.com
setting is the same
themes=cn Indicate the use of the cn directory under the view directory
themes_url= Indicate the URL for accessing resources such as themes, images, etc
The usage method is defined inhttppeer.h
std::string get_sitepath();
unsigned long long get_siteid();
unsigned long long get_groupid();
std::string get_theme();
std::string get_themeurl();
void theme_view(const std::string &a);
Example of usage, using in annotated functions
//@urlpath(null,articles)
std::string front_article(std::shared_ptr<httppeer> peer)
{
unsigned int userid=peer->get_siteid();
peer->theme_view("front/articlelist");
}
peer->theme_view("front/articlelist");
We set it up earlier themes=cn
theme_view Use the view/cn/front/articlelist.html
view file
Main feature 1:controller/src
Create the aaa.com
directory, which cannot be used without the alias_domain=aaa.com
setting, to facilitate the use of large projects
Main feature 2:peer->theme_view("front/articlelist");
Automatically set the view, making it convenient for administrators to set themes=cn
in the background to dynamically change themes