Skip to content

Commit c5cb1f0

Browse files
committed
初始化
0 parents  commit c5cb1f0

File tree

407 files changed

+46873
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

407 files changed

+46873
-0
lines changed

.gitignore

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Build and Release Folders
2+
bin-debug/
3+
bin-release/
4+
[Oo]bj/
5+
[Bb]in/
6+
7+
# Other files and folders
8+
.settings/
9+
10+
# Executables
11+
*.swf
12+
*.air
13+
*.ipa
14+
*.apk
15+
.idea
16+
# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties`
17+
# should NOT be excluded as they contain compiler settings and other important
18+
# information for Eclipse / Flash Builder.

README.md

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
2+
# PaoDjangoAdmin
3+
4+
## 项目简介
5+
6+
PaoDjangoAdmin 是一个基于 Django + Vue3 的前后端分离的后台管理系统,采用了最新的前后端技术栈,内置了丰富的功能模块,可以帮助开发者快速搭建企业级中后台产品。
7+
8+
## 技术架构
9+
10+
### 后端技术栈
11+
12+
- **核心框架**:Django 4.2.1
13+
- **权限认证**:Django REST framework + JWT + Casbin
14+
- **数据库**:MySQL 8.0+
15+
- **缓存**:Redis
16+
- **任务队列**:Celery
17+
- **WebSocket**:Channels + Redis
18+
- **跨域处理**:django-cors-headers
19+
- **验证码**:django-simple-captcha
20+
- **数据导出**:django-import-export
21+
22+
### 前端技术栈
23+
24+
- **核心框架**:Vue 3.0 (Composition API)
25+
- **开发语言**:TypeScript
26+
- **构建工具**:Vite 3
27+
- **UI 框架**:Element Plus
28+
- **状态管理**:Pinia
29+
- **路由管理**:Vue Router
30+
- **国际化**:vue-i18n
31+
32+
## 功能特点
33+
34+
### 1. 用户权限管理
35+
- 基于 Casbin 的 RBAC 权限模型
36+
- 多维度数据权限控制
37+
- 动态路由和菜单权限
38+
- 按钮级权限控制
39+
40+
### 2. 系统功能
41+
- 用户管理:用户信息管理、状态控制、多角色分配
42+
- 角色管理:角色权限分配、数据权限设置
43+
- 菜单管理:动态菜单配置,支持多级菜单
44+
- 部门管理:部门组织架构维护
45+
- 岗位管理:岗位信息维护
46+
47+
### 3. 系统监控
48+
- 操作日志:系统操作记录
49+
- 任务监控:定时任务执行监控
50+
- 服务监控:服务器性能监控
51+
52+
### 4. 系统工具
53+
- 数据字典:系统中各种枚举数据维护
54+
- 消息管理:系统消息推送和管理
55+
56+
## 部署说明
57+
58+
### 环境要求
59+
- Python 3.9+
60+
- Node.js 16+
61+
- MySQL 8.0+
62+
- Redis
63+
- Docker(可选)
64+
65+
### 部署步骤
66+
67+
#### 1. Docker 部署(推荐)
68+
69+
```bash
70+
# 启动所有服务
71+
docker-compose up -d
72+
73+
# 仅启动后端服务
74+
docker-compose -f django-admin.yml up -d
75+
76+
# 仅启动前端服务
77+
docker-compose -f django-web.yml up -d
78+
```
79+
80+
#### 2. 常规部署
81+
82+
##### 后端部署
83+
```bash
84+
# 安装依赖
85+
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
86+
87+
# 数据库迁移
88+
python manage.py makemigrations
89+
python manage.py migrate
90+
91+
# 初始化数据
92+
python manage.py init
93+
94+
# 启动服务
95+
python manage.py runserver 127.0.0.1:8000
96+
```
97+
98+
##### 前端部署
99+
```bash
100+
# 安装依赖
101+
pnpm install
102+
103+
# 开发环境
104+
pnpm dev
105+
106+
# 生产环境
107+
pnpm build
108+
```
109+
110+
### 初始账号
111+
- 用户名:paopao
112+
- 密码:123456
113+
114+
## 开发指南
115+
116+
### 后端开发
117+
- 遵循 Django 开发规范
118+
- 使用 Django REST framework 开发 API
119+
- 使用 Casbin 进行权限控制
120+
- 使用 Celery 处理异步任务
121+
122+
### 前端开发
123+
- 组件命名采用 PascalCase
124+
- TypeScript 类型定义放在 types 目录
125+
- API 接口按模块组织在 api 目录
126+
- 使用 ESLint + Prettier 进行代码规范
127+
128+
## 贡献指南
129+
130+
欢迎提交 Issue 或 Pull Request 来帮助改进项目。在提交之前,请确保:
131+
132+
1. Issue 没有被重复提交
133+
2. Pull Request 遵循项目代码规范
134+
3. 更新相关文档
135+
4. 编写必要的测试用例
136+
137+
## 许可证
138+
139+
[MIT License](LICENSE)

backend/.env.development

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# ================================================= #
2+
# ************** mysql数据库 配置 ************** #
3+
# ================================================= #
4+
# 数据库地址
5+
DATABASE_ENGINE = "django.db.backends.mysql"
6+
# 数据库地址
7+
DATABASE_HOST = "127.0.0.1"
8+
# 数据库端口
9+
DATABASE_PORT = 3306
10+
# 数据库用户名
11+
DATABASE_USER = "root"
12+
# 数据库密码
13+
DATABASE_PASSWORD = "1998329"
14+
# 数据库名
15+
DATABASE_NAME = "pyroDjangoData"
16+
#数据库编码
17+
DATABASE_CHARSET = "utf8mb4"
18+
# 数据库长连接时间(默认为0,单位秒)即每次请求都重新连接,debug模式下该值应该写为0 ,mysql默认长连接超时时间为8小时
19+
#推荐120(2分钟),使用 None 则是无限的持久连接(不推荐)。
20+
DATABASE_CONN_MAX_AGE = 0
21+
22+
# ================================================= #
23+
# ************** redis 配置 ************** #
24+
# ================================================= #
25+
REDIS_URL = 'redis://:123456@127.0.0.1:6379'
26+
27+
# ================================================= #
28+
# ************** 服务器基本 配置 ************** #
29+
# ================================================= #
30+
DEBUG = True #是否调试模式

backend/.env.production

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# ================================================= #
2+
# ************** mysql数据库 配置 ************** #
3+
# ================================================= #
4+
# 数据库地址
5+
DATABASE_ENGINE = "django.db.backends.mysql"
6+
# 数据库地址
7+
DATABASE_HOST = "127.0.0.1"
8+
# 数据库端口
9+
DATABASE_PORT = 3306
10+
# 数据库用户名
11+
DATABASE_USER = "root"
12+
# 数据库密码
13+
DATABASE_PASSWORD = "1998329"
14+
# 数据库名
15+
DATABASE_NAME = "pyroDjangoData"
16+
#数据库编码
17+
DATABASE_CHARSET = "utf8mb4"
18+
# 数据库长连接时间(默认为0,单位秒)即每次请求都重新连接,debug模式下该值应该写为0 ,mysql默认长连接超时时间为8小时
19+
#推荐120(2分钟),使用 None 则是无限的持久连接(不推荐)。
20+
DATABASE_CONN_MAX_AGE = 0
21+
22+
# ================================================= #
23+
# ************** redis 配置 ************** #
24+
# ================================================= #
25+
REDIS_URL = 'redis://:123456@127.0.0.1:6379'
26+
27+
# ================================================= #
28+
# ************** 服务器基本 配置 ************** #
29+
# ================================================= #
30+
DEBUG = True #是否调试模式

backend/.gitignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Build and Release Folders
2+
bin-debug/
3+
bin-release/
4+
[Oo]bj/
5+
[Bb]in/
6+
7+
# Other files and folders
8+
.settings/
9+
10+
# Executables
11+
*.swf
12+
*.air
13+
*.ipa
14+
*.apk
15+
.idea
16+
logs
17+
# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties`
18+
# should NOT be excluded as they contain compiler settings and other important
19+
# information for Eclipse / Flash Builder.
20+
__pycache__/
21+
*.pyc

backend/app_apis/__init__.py

Whitespace-only changes.

backend/app_apis/admin.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

backend/app_apis/apps.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class AppApisConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'app_apis'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Generated by Django 4.2.1 on 2024-01-13 15:08
2+
3+
from django.db import migrations, models
4+
import utils.models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
initial = True
10+
11+
dependencies = [
12+
]
13+
14+
operations = [
15+
migrations.CreateModel(
16+
name='APIS',
17+
fields=[
18+
('id', utils.models.SnowflakeIDField(primary_key=True, serialize=False)),
19+
('modifier', models.CharField(blank=True, help_text='修改人', max_length=255, null=True, verbose_name='修改人')),
20+
('update_datetime', models.DateTimeField(auto_now=True, null=True, verbose_name='更新时间')),
21+
('create_datetime', models.DateTimeField(auto_now_add=True, null=True, verbose_name='创建时间')),
22+
('path', models.CharField(help_text='路由地址', max_length=64, verbose_name='路由地址')),
23+
('description', models.CharField(blank=True, help_text='api中文描述', max_length=150, null=True, verbose_name='api中文描述')),
24+
('api_group', models.CharField(help_text='api组', max_length=150, verbose_name='api组')),
25+
('method', models.CharField(choices=[('POST', '创建'), ('GET', '查看'), ('PUT', '更新'), ('DELETE', '删除')], default='POST', help_text='创建POST(默认)|查看GET|更新PUT|删除DELETE', max_length=6, verbose_name='创建POST(默认)|查看GET|更新PUT|删除DELETE')),
26+
('enable_datasource', models.CharField(choices=[('0', '需要'), ('1', '不需要')], db_index=True, default='0', help_text='激活数据权限', max_length=1, verbose_name='激活数据权限')),
27+
],
28+
options={
29+
'verbose_name': '系统-API接口表',
30+
'verbose_name_plural': '系统-API接口表',
31+
'db_table': 'sys_apis',
32+
'ordering': ('-create_datetime',),
33+
},
34+
),
35+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Generated by Django 4.2.1 on 2024-01-13 15:08
2+
3+
from django.conf import settings
4+
from django.db import migrations, models
5+
import django.db.models.deletion
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
initial = True
11+
12+
dependencies = [
13+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
14+
('app_apis', '0001_initial'),
15+
]
16+
17+
operations = [
18+
migrations.AddField(
19+
model_name='apis',
20+
name='creator',
21+
field=models.ForeignKey(db_constraint=False, help_text='创建人', null=True, on_delete=django.db.models.deletion.SET_NULL, related_query_name='creator_query', to=settings.AUTH_USER_MODEL, verbose_name='创建人'),
22+
),
23+
migrations.AlterUniqueTogether(
24+
name='apis',
25+
unique_together={('path', 'api_group', 'method')},
26+
),
27+
]

backend/app_apis/migrations/__init__.py

Whitespace-only changes.

backend/app_apis/models.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from django.db import models
2+
3+
# Create your models here.
4+
from utils.models import BaseModel, table_prefix
5+
6+
7+
class APIS(BaseModel):
8+
path = models.CharField(max_length=64, verbose_name="路由地址", help_text="路由地址")
9+
description = models.CharField(max_length=150, null=True, blank=True, verbose_name="api中文描述", help_text="api中文描述")
10+
api_group = models.CharField(max_length=150, verbose_name="api组", help_text="api组")
11+
METHOD_CHOICES = (
12+
(u"POST", u"创建"),
13+
(u"GET", u"查看"),
14+
(u"PUT", u"更新"),
15+
(u"DELETE", u"删除"),
16+
)
17+
method = models.CharField(max_length=6, choices=METHOD_CHOICES, default='POST', verbose_name='创建POST(默认)|查看GET|更新PUT|删除DELETE',
18+
help_text="创建POST(默认)|查看GET|更新PUT|删除DELETE")
19+
IS_STATUS = (
20+
('0', "需要"),
21+
('1', "不需要"),
22+
)
23+
enable_datasource = models.CharField(max_length=1, choices=IS_STATUS, default='0', verbose_name="激活数据权限", help_text="激活数据权限", db_index=True)
24+
25+
class Meta:
26+
unique_together = ["path", "api_group", "method"]
27+
db_table = table_prefix + "apis"
28+
verbose_name = '系统-API接口表'
29+
verbose_name_plural = verbose_name
30+
ordering = ('-create_datetime',)

backend/app_apis/serializers.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""
2+
Time: 2023/8/23 16:37
3+
Author: 公众号【布鲁的Python之旅】,【github】https://github.com/taskPyroer, 【gitee】https://gitee.com/hu_yupeng123/projects
4+
Version: V 0.1
5+
File: serializers
6+
Describe:
7+
"""
8+
9+
from app_apis.models import APIS
10+
from utils.serializers import CustomModelSerializer
11+
12+
13+
class ApiSerializer(CustomModelSerializer):
14+
"""
15+
API管理-序列化器
16+
"""
17+
class Meta:
18+
model = APIS
19+
fields = "__all__"
20+
read_only_fields = ["id"]

backend/app_apis/tests.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

backend/app_apis/urls.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
Time: 2023/8/22 10:40
3+
Author: 公众号【布鲁的Python之旅】,【github】https://github.com/taskPyroer, 【gitee】https://gitee.com/hu_yupeng123/projects
4+
Version: V 0.1
5+
File: urls
6+
Describe:
7+
"""
8+
from django.urls import re_path
9+
from rest_framework import routers
10+
11+
from app_apis.views import ApisViewSet
12+
13+
system_url = routers.SimpleRouter()
14+
system_url.register(r'apis', ApisViewSet)
15+
16+
urlpatterns = [
17+
re_path('apis/get-all-api-group', ApisViewSet.as_view({'get': 'get_all_api_group'}))
18+
]
19+
urlpatterns += system_url.urls

0 commit comments

Comments
 (0)