添加初始化数据

This commit is contained in:
zhengxinonly
2022-05-28 23:36:32 +08:00
parent 4748a286db
commit 8835721924
10 changed files with 570 additions and 4 deletions
+3 -4
View File
@@ -24,7 +24,7 @@ SYSTEM_PANEL_LINKS = [
SECRET_KEY = os.getenv('SECRET_KEY', 'dev key')
# mysql 配置
MYSQL_USERNAME = "root"
MYSQL_USERNAME = "windows"
MYSQL_PASSWORD = "123456"
MYSQL_HOST = "127.0.0.1"
MYSQL_PORT = 3306
@@ -35,12 +35,11 @@ REDIS_HOST = "127.0.0.1"
REDIS_PORT = 6379
""" Sqlalchemy 配置 """
SQLALCHEMY_DATABASE_URI = r'sqlite:///pear_admin.db'
# SQLALCHEMY_DATABASE_URI = r'sqlite:///pear_admin.db'
SQLALCHEMY_TRACK_MODIFICATIONS = True
SQLALCHEMY_ECHO = False
SQLALCHEMY_POOL_RECYCLE = 8
# SQLALCHEMY_DATABASE_URI = f"mysql+pymysql://{MYSQL_USERNAME}:{MYSQL_PASSWORD}@\
# {MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DATABASE}"
SQLALCHEMY_DATABASE_URI = f"mysql+pymysql://{MYSQL_USERNAME}:{MYSQL_PASSWORD}@{MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DATABASE}"
LOG_LEVEL = logging.ERROR
+16
View File
@@ -32,6 +32,22 @@ class RightModel(db.Model):
parent = db.relationship("RightModel", remote_side=[id]) # 自关联
"""
id = db.Column(db.Integer, primary_key=True, comment='权限编号')
powerName = db.Column(db.String(255), comment='权限名称')
powerType = db.Column(db.SMALLINT, comment='权限类型')
powerCode = db.Column(db.String(30), comment='权限标识')
powerUrl = db.Column(db.String(255), comment='权限路径')
openType = db.Column(db.String(10), comment='打开方式')
parentId = db.Column(db.Integer, db.ForeignKey("rt_power.id"), comment='父类编号')
icon = db.Column(db.String(128), comment='图标')
sort = db.Column(db.Integer, comment='排序')
enable = db.Column(db.Boolean, comment='是否开启')
checkArr = db.Column(db.String(128), comment='')
parent = db.relationship("RightModel", remote_side=[id]) # 自关联
"""
class RoleModel(db.Model):
__tablename__ = 'rt_role'
+30
View File
@@ -20,6 +20,25 @@ class UserModel(db.Model, UserMixin):
role = db.relationship('RoleModel', secondary="rt_user_role", backref=db.backref('user'), lazy='dynamic')
"""
id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment='用户ID')
username = db.Column(db.String(20), comment='用户名')
password_hash = db.Column(db.String(128), comment='哈希密码')
salt = db.Column(db.String(128))
status = db.Column(db.String(20), default=0, comment='启用')
realName = db.Column(db.String(20), comment='真实名字')
email = db.Column(db.String(50), comment='邮箱')
avatar = db.Column(db.String(255), comment='头像', default="/static/admin/admin/images/avatar.jpg")
sex = db.Column(db.String(3), comment='性别')
phone = db.Column(db.String(11), comment='电话号码')
enable = db.Column(db.String(3), comment='启用')
login = db.Column(db.String(3), comment='登录状态')
# roleIds = db.Column(db.String(255), comment='登录状态')
comment = db.Column(db.String(255), comment='备注')
dept_id = db.Column(db.Integer, comment='部门id')
role = db.relationship('RoleModel', secondary="rt_user_role", backref=db.backref('user'), lazy='dynamic')
"""
def set_password(self, password):
"""设置密码,对密码进行加密存储"""
self.password_hash = generate_password_hash(password)
@@ -46,3 +65,14 @@ class DepartmentModel(db.Model):
sort = db.Column(db.Integer, comment="排序")
create_at = db.Column(db.DateTime, default=datetime.now, comment='创建时间')
"""
id = db.Column(db.Integer, primary_key=True, comment="部门ID")
name = db.Column(db.String(50), comment="部门名称")
userCount = db.Column(db.String(50), comment="部门人数")
address = db.Column(db.String(255), comment="详细地址")
leader = db.Column(db.String(50), comment="负责人")
status = db.Column(db.Boolean, comment='状态(1开启,0关闭)')
parent_id = db.Column(db.Integer, comment="父级编号")
sort = db.Column(db.Integer, comment="排序")
"""
+72
View File
@@ -0,0 +1,72 @@
[
{
"id": 1,
"parent_id": 0,
"dept_name": "总公司",
"sort": 1,
"leader": "就眠仪式",
"phone": "12312345679",
"email": "123qq.com",
"status": 1,
"comment": null,
"address": "这是总公司",
"create_at": null,
"update_at": "2021-06-01 17:23:20"
},
{
"id": 4,
"parent_id": 1,
"dept_name": "济南分公司",
"sort": 2,
"leader": "就眠仪式",
"phone": "12312345678",
"email": "1234qq.com",
"status": 1,
"comment": null,
"address": "这是济南",
"create_at": "2021-06-01 17:24:33",
"update_at": "2021-06-01 17:25:19"
},
{
"id": 5,
"parent_id": 1,
"dept_name": "唐山分公司",
"sort": 4,
"leader": "mkg",
"phone": "12312345678",
"email": "123@qq.com",
"status": 1,
"comment": null,
"address": "这是唐山",
"create_at": "2021-06-01 17:25:15",
"update_at": "2021-06-01 17:25:20"
},
{
"id": 7,
"parent_id": 4,
"dept_name": "济南分公司开发部",
"sort": 5,
"leader": "就眠仪式",
"phone": "12312345678",
"email": "123@qq.com",
"status": 1,
"comment": null,
"address": "测试",
"create_at": "2021-06-01 17:27:39",
"update_at": "2021-06-01 17:27:39"
},
{
"id": 8,
"parent_id": 5,
"dept_name": "唐山测试部",
"sort": 6,
"leader": "mkg",
"phone": "12312345678",
"email": "123@qq.com",
"status": 1,
"comment": null,
"address": "测试部",
"create_at": "2021-06-01 17:28:27",
"update_at": "2021-06-01 17:28:27"
}
]
+38
View File
@@ -0,0 +1,38 @@
[
{
"id": 1,
"username": "admin",
"password_hash": "pbkdf2:sha256:150000$raM7mDSr$58fe069c3eac01531fc8af85e6fc200655dd2588090530084d182e6ec9d52c85",
"create_at": null,
"update_at": "2021-06-01 17:28:55",
"enable": 1,
"realname": "超级管理",
"remark": "要是不能把握时机,就要终身蹭蹬,一事无成!",
"avatar": "http://127.0.0.1:5000/_uploads/photos/1617291580000.jpg",
"dept_id": 1
},
{
"id": 7,
"username": "test",
"password_hash": "pbkdf2:sha256:150000$cRS8bYNh$adb57e64d929863cf159f924f74d0634f1fecc46dba749f1bfaca03da6d2e3ac",
"create_at": "2021-03-22 20:03:42",
"update_at": "2021-06-01 17:29:47",
"enable": 1,
"realname": "超级管理",
"remark": "要是不能把握时机,就要终身蹭蹬,一事无成",
"avatar": "/static/admin/admin/images/avatar.jpg",
"dept_id": 1
},
{
"id": 8,
"username": "wind",
"password_hash": "pbkdf2:sha256:150000$skME1obT$6a2c20cd29f89d7d2f21d9e373a7e3445f70ebce3ef1c3a555e42a7d17170b37",
"create_at": "2021-06-01 17:30:39",
"update_at": "2021-06-01 17:30:52",
"enable": 1,
"realname": "风",
"remark": null,
"avatar": "/static/admin/admin/images/avatar.jpg",
"dept_id": 7
}
]
+18
View File
@@ -0,0 +1,18 @@
[
{
"id": 3,
"name": "6958819_pear-admin_1607443454_1.png",
"href": "http://127.0.0.1:5000/_uploads/photos/6958819_pear-admin_1607443454_1.png",
"mime": "image/png",
"size": "2204",
"create_time": "2021-03-19 18:53:02"
},
{
"id": 17,
"name": "1617291580000.jpg",
"href": "http://127.0.0.1:5000/_uploads/photos/1617291580000.jpg",
"mime": "image/png",
"size": "94211",
"create_time": "2021-04-01 23:39:41"
}
]
+324
View File
@@ -0,0 +1,324 @@
[
{
"id": 1,
"name": "系统管理",
"type": "0",
"code": "",
"url": null,
"open_type": null,
"parent_id": "0",
"icon": "layui-icon layui-icon-set-fill",
"sort": 1,
"create_time": null,
"update_time": null,
"enable": 1
},
{
"id": 3,
"name": "用户管理",
"type": "1",
"code": "admin:user:main",
"url": "/users/",
"open_type": "_iframe",
"parent_id": "1",
"icon": "layui-icon layui-icon layui-icon layui-icon layui-icon-rate",
"sort": 1,
"create_time": null,
"update_time": null,
"enable": 1
},
{
"id": 4,
"name": "权限管理",
"type": "1",
"code": "admin:power:main",
"url": "/rights/",
"open_type": "_iframe",
"parent_id": "1",
"icon": null,
"sort": 2,
"create_time": null,
"update_time": null,
"enable": 1
},
{
"id": 9,
"name": "角色管理",
"type": "1",
"code": "admin:role:main",
"url": "/admin/role",
"open_type": "_iframe",
"parent_id": "1",
"icon": "layui-icon layui-icon-username",
"sort": 2,
"create_time": "2021-03-16 22:24:58",
"update_time": "2021-03-25 19:15:24",
"enable": 1
},
{
"id": 13,
"name": "日志管理",
"type": "1",
"code": "admin:log:main",
"url": "/logs",
"open_type": "_iframe",
"parent_id": "1",
"icon": "layui-icon layui-icon-read",
"sort": 4,
"create_time": "2021-03-18 22:37:10",
"update_time": "2021-06-03 11:06:25",
"enable": 1
},
{
"id": 17,
"name": "文件管理",
"type": "0",
"code": "",
"url": "",
"open_type": "",
"parent_id": "0",
"icon": "layui-icon layui-icon-camera",
"sort": 2,
"create_time": "2021-03-19 18:56:23",
"update_time": "2021-03-25 19:15:08",
"enable": 1
},
{
"id": 18,
"name": "图片上传",
"type": "1",
"code": "admin:file:main",
"url": "/file",
"open_type": "_iframe",
"parent_id": "17",
"icon": "layui-icon layui-icon-camera",
"sort": 5,
"create_time": "2021-03-19 18:57:19",
"update_time": "2021-03-25 19:15:13",
"enable": 1
},
{
"id": 21,
"name": "权限增加",
"type": "2",
"code": "admin:power:add",
"url": "",
"open_type": "",
"parent_id": "4",
"icon": "layui-icon layui-icon-add-circle",
"sort": 1,
"create_time": "2021-03-22 19:43:52",
"update_time": "2021-03-25 19:15:22",
"enable": 1
},
{
"id": 22,
"name": "用户增加",
"type": "2",
"code": "admin:user:add",
"url": "",
"open_type": "",
"parent_id": "3",
"icon": "layui-icon layui-icon-add-circle",
"sort": 1,
"create_time": "2021-03-22 19:45:40",
"update_time": "2021-03-25 19:15:17",
"enable": 1
},
{
"id": 23,
"name": "用户编辑",
"type": "2",
"code": "admin:user:edit",
"url": "",
"open_type": "",
"parent_id": "3",
"icon": "layui-icon layui-icon-rate",
"sort": 2,
"create_time": "2021-03-22 19:46:15",
"update_time": "2021-03-25 19:15:18",
"enable": 1
},
{
"id": 24,
"name": "用户删除",
"type": "2",
"code": "admin:user:remove",
"url": "",
"open_type": "",
"parent_id": "3",
"icon": "layui-icon None",
"sort": 3,
"create_time": "2021-03-22 19:46:51",
"update_time": "2021-03-25 19:15:18",
"enable": 1
},
{
"id": 25,
"name": "权限编辑",
"type": "2",
"code": "admin:power:edit",
"url": "",
"open_type": "",
"parent_id": "4",
"icon": "layui-icon layui-icon-edit",
"sort": 2,
"create_time": "2021-03-22 19:47:36",
"update_time": "2021-03-25 19:15:22",
"enable": 1
},
{
"id": 26,
"name": "用户删除",
"type": "2",
"code": "admin:power:remove",
"url": "",
"open_type": "",
"parent_id": "4",
"icon": "layui-icon layui-icon-delete",
"sort": 3,
"create_time": "2021-03-22 19:48:17",
"update_time": "2021-03-25 19:15:23",
"enable": 1
},
{
"id": 27,
"name": "用户增加",
"type": "2",
"code": "admin:role:add",
"url": "",
"open_type": "",
"parent_id": "9",
"icon": "layui-icon layui-icon-add-circle",
"sort": 1,
"create_time": "2021-03-22 19:49:09",
"update_time": "2021-03-25 19:15:24",
"enable": 1
},
{
"id": 28,
"name": "角色编辑",
"type": "2",
"code": "admin:role:edit",
"url": "",
"open_type": "",
"parent_id": "9",
"icon": "layui-icon layui-icon-edit",
"sort": 2,
"create_time": "2021-03-22 19:49:41",
"update_time": "2021-03-25 19:15:25",
"enable": 1
},
{
"id": 29,
"name": "角色删除",
"type": "2",
"code": "admin:role:remove",
"url": "",
"open_type": "",
"parent_id": "9",
"icon": "layui-icon layui-icon-delete",
"sort": 3,
"create_time": "2021-03-22 19:50:15",
"update_time": "2021-03-25 19:15:26",
"enable": 1
},
{
"id": 30,
"name": "角色授权",
"type": "2",
"code": "admin:role:power",
"url": "",
"open_type": "",
"parent_id": "9",
"icon": "layui-icon layui-icon-component",
"sort": 4,
"create_time": "2021-03-22 19:50:54",
"update_time": "2021-03-25 19:15:26",
"enable": 1
},
{
"id": 31,
"name": "图片增加",
"type": "2",
"code": "admin:file:add",
"url": "",
"open_type": "",
"parent_id": "18",
"icon": "layui-icon layui-icon-add-circle",
"sort": 1,
"create_time": "2021-03-22 19:58:05",
"update_time": "2021-03-25 19:15:28",
"enable": 1
},
{
"id": 32,
"name": "图片删除",
"type": "2",
"code": "admin:file:delete",
"url": "",
"open_type": "",
"parent_id": "18",
"icon": "layui-icon layui-icon-delete",
"sort": 2,
"create_time": "2021-03-22 19:58:45",
"update_time": "2021-03-25 19:15:29",
"enable": 1
},
{
"id": 48,
"name": "部门管理",
"type": "1",
"code": "admin:dept:main",
"url": "/dept",
"open_type": "_iframe",
"parent_id": "1",
"icon": "layui-icon layui-icon-group",
"sort": 3,
"create_time": "2021-06-01 16:22:11",
"update_time": "2021-06-01 16:22:11",
"enable": 1
},
{
"id": 49,
"name": "部门增加",
"type": "2",
"code": "admin:dept:add",
"url": "",
"open_type": "",
"parent_id": "48",
"icon": "layui-icon None",
"sort": 1,
"create_time": "2021-06-01 17:35:52",
"update_time": "2021-06-01 17:36:15",
"enable": 1
},
{
"id": 50,
"name": "部门编辑",
"type": "2",
"code": "admin:dept:edit",
"url": "",
"open_type": "",
"parent_id": "48",
"icon": "layui-icon ",
"sort": 2,
"create_time": "2021-06-01 17:36:41",
"update_time": "2021-06-01 17:36:41",
"enable": 1
},
{
"id": 51,
"name": "部门删除",
"type": "2",
"code": "admin:dept:remove",
"url": "",
"open_type": "",
"parent_id": "48",
"icon": "layui-icon None",
"sort": 3,
"create_time": "2021-06-01 17:37:15",
"update_time": "2021-06-01 17:37:26",
"enable": 1
}
]
+24
View File
@@ -0,0 +1,24 @@
[
{
"id": 1,
"name": "管理员",
"code": "admin",
"remark": null,
"details": "管理员",
"sort": 1,
"create_time": null,
"update_time": null,
"enable": 1
},
{
"id": 2,
"name": "普通用户",
"code": "common",
"remark": null,
"details": "只有查看,没有增删改权限",
"sort": 2,
"create_time": "2021-03-22 20:02:38",
"update_time": "2021-04-01 22:29:56",
"enable": 1
}
]
+40
View File
@@ -0,0 +1,40 @@
[
[237, 1, 1],
[238, 3, 1],
[239, 4, 1],
[240, 9, 1],
[241, 12, 1],
[242, 13, 1],
[243, 17, 1],
[244, 18, 1],
[245, 21, 1],
[246, 22, 1],
[247, 23, 1],
[248, 24, 1],
[249, 25, 1],
[250, 26, 1],
[251, 27, 1],
[252, 28, 1],
[253, 29, 1],
[254, 30, 1],
[255, 31, 1],
[256, 32, 1],
[257, 44, 1],
[258, 45, 1],
[259, 46, 1],
[260, 47, 1],
[261, 48, 1],
[262, 49, 1],
[263, 50, 1],
[264, 51, 1],
[265, 1, 2],
[266, 3, 2],
[267, 4, 2],
[268, 9, 2],
[269, 12, 2],
[270, 13, 2],
[271, 17, 2],
[272, 18, 2],
[273, 44, 2],
[274, 48, 2]
]
+5
View File
@@ -0,0 +1,5 @@
[
[21, 1, 1],
[22, 7, 2],
[24, 8, 2]
]