The Base branch is added. The Base branch only includes the back end. It has rewritten it on the basis of the Master branch. It has more comprehensive permissions control, workflow engine, operation and maintenance management, WebSocket support and providing multiple common functions. Integrated into Utils.
The later functional changes will be mainly based on the BASE branch.
Based on the basic development platform of small and medium-sized applications controlled by RBAC model permissions, the front and back end are separated. The back end uses Django+Django-Rest-Framework. The front end uses Vue+Elementui, and the mobile terminal uses UNIAPP+UView (available H5 and applet).
JWT authentication, you can use Simple_history to achieve audit function, support SWAGGER
The built -in modules include organizational users characters post data dictionary file library timing task workflow (most of the code has been uploaded, the back -end code is located in APPS/WF)
Use the workflow to recommend the database to use postgresql. The preview environment below is not supported by some JSON query because it uses SQLITE. The use method can refer to the LOONFlow document.
Support function permissions (control to each interface) and simple data permissions (all, this level and below, the same level, below, I, etc.)
Welcome to mention issues
Runserver, account admin, password admin directly used by preview address. Please operate carefully, do not modify the password http://49.232.29.236:2222/
Position to the server folder
Establish a virtual environment python -m venv venv
Activate the virtual environment .venvscriptsactivate
Install the dependent package pip install -r requirements.txt
C copy
Synchronous database python manage.py migrate
It can be imported by the initial data python manage.py loaddata db.json
or directly use the SQLite database (the password of the super pipeline account is Admin, and the database will be reset every other time)
Create a super administrator python manage.py createsuperuser
Run service python manage.py runserver 8000
Position to the client folder
Install node.js
Install the dependent package npm install --registry=https://registry.npmmirror.com
Running service npm run dev
Modify nginx.conf when running locally to display resource files
listen 8012
location /media {
proxy_pass http://localhost:8000;
}
location / {
proxy_pass http://localhost:9528;
}
Run nginx.exe
Open LocalHost: 8012 to access
Interface document LocalHost: 8000/API/SWAGGER/
LocalHost: 8000/django/admin//
Pay attention to modify the conf.py when deploying
Can be deployed separately in front and back, nginx proxy. You can also replace the front -end distribution of the server/distal, and then execute the CollectStatic
Start with gunicorn: Enter the virtual environment to execute the gunicorn -w 5 -b 0.0.0.0:2251 server.wsgi
If webscoket is needed, you need to configure DAPHNE startup, you can use SuperVisor to monitor
Nginx configuration can be referred to as follows:
server {
listen 2250;
client_max_body_size 1024m;
location /media/ {
alias /home/lighthouse/xx/media/;
limit_rate 800k;
}
location / {
alias /home/lighthouse/xx/dist/;
index index.html;
}
location ~ ^/(api|django)/ {
set $CSRFTOKEN "";
if ($http_cookie ~* "CSRFTOKEN=(.+?)(?=;|$)") {
set $CSRFTOKEN "$1";
}
proxy_set_header X-CSRFToken $CSRFTOKEN;
proxy_pass http://localhost:2251;
proxy_pass_header Authorization;
proxy_pass_header WWW-Authenticate;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /ws/ {
proxy_pass http://localhost:2252;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}
The front ./client
and the back end ./server
are dockerfile. If you need to build a mirror separately, you can build it yourself.
Here is the main saying that Docker-compose starts this method.
Modify the docker-compose.yml file according to the annotation. There are two main services in it, one is the back end backend
, and the other is the front end frontend
.
The default is the back end and front end of the development mode. If you need to deploy a single machine and want to use Docker-Compose, it will be better to change the production mode.
start up
cd <path-to-your-project>
docker-compose up -d
After the start is successful, the access port is the same as the front, the interface 8000 port, and the front end 8012 port. If you need to change, change the docker-compose.yml yourself
If you want to execute the command?
Raise a chestnut:
If I want to execute the back -end generating data change command. python manage.py makemigrations
Use the following statement
docker-compose exec backend python manage.py makemigrations
First of all, you must use Django-Rest-Framework to understand Vue-Element-Admin front-end solution
This project uses front -end routing, and the back -end is returned to the front end according to the user's role read the user permissions code, loaded from the front end (the core code is the PERMS attribute in the routing table and the CheckPermission method)
The core code of the back -end function permissions is retracted by the Has_permission method under the server/APPS/System/Permission.py, and define the perMS permissions code in APIView and ViewSet.
Because the data permissions are related to the specific business, several rules are simply defined, and the Has_Object_permission method is rewritten; just use it as needed
Because the actual situation is complicated, it is recommended to write the Permission_Class of the DRF according to different situations.
Use Clery and django_celery_beat package to achieve
Need to install Redis and start on the default port, and start worker and beat
Enter the virtual environment and start the worker: celery -A server worker -l info -P eventlet
, the Linux system does not need to add -P eventlet
Enter the virtual environment and start Beat: celery -A server beat -l info
Refer to the implementation of LOONFLOW in the workflow module.
If you are willing to communicate, you can add QQ group 235665873 to add WeChat group