分解models
This commit is contained in:
@@ -1,119 +0,0 @@
|
|||||||
import datetime
|
|
||||||
from flask_login import UserMixin
|
|
||||||
from werkzeug.security import generate_password_hash, check_password_hash
|
|
||||||
from applications.models import db
|
|
||||||
|
|
||||||
|
|
||||||
class User(db.Model, UserMixin):
|
|
||||||
__tablename__ = 'admin_user'
|
|
||||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment='用户ID')
|
|
||||||
username = db.Column(db.String(20), comment='用户名')
|
|
||||||
realname = db.Column(db.String(20), comment='真实名字')
|
|
||||||
avatar = db.Column(db.String(255), comment='头像', default="/static/admin/admin/images/avatar.jpg")
|
|
||||||
remark = db.Column(db.String(255), comment='备注')
|
|
||||||
password_hash = db.Column(db.String(128), comment='哈希密码')
|
|
||||||
enable = db.Column(db.Integer, default=0, comment='启用')
|
|
||||||
create_at = db.Column(db.DateTime, default=datetime.datetime.now, comment='创建时间')
|
|
||||||
update_at = db.Column(db.DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now, comment='创建时间')
|
|
||||||
role = db.relationship('Role', secondary="admin_user_role", backref=db.backref('user'), lazy='dynamic')
|
|
||||||
|
|
||||||
def set_password(self, password):
|
|
||||||
self.password_hash = generate_password_hash(password)
|
|
||||||
|
|
||||||
def validate_password(self, password):
|
|
||||||
return check_password_hash(self.password_hash, password)
|
|
||||||
|
|
||||||
|
|
||||||
# 创建中间表
|
|
||||||
user_role = db.Table(
|
|
||||||
"admin_user_role", # 中间表名称
|
|
||||||
db.Column("id", db.Integer, primary_key=True, autoincrement=True, comment='标识'), # 主键
|
|
||||||
db.Column("user_id", db.Integer, db.ForeignKey("admin_user.id"), comment='用户编号'), # 属性 外键
|
|
||||||
db.Column("role_id", db.Integer, db.ForeignKey("admin_role.id"), comment='角色编号'), # 属性 外键
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Role(db.Model):
|
|
||||||
__tablename__ = 'admin_role'
|
|
||||||
id = db.Column(db.Integer, primary_key=True, comment='角色ID')
|
|
||||||
name = db.Column(db.String(255), comment='角色名称')
|
|
||||||
code = db.Column(db.String(255), comment='角色标识')
|
|
||||||
enable = db.Column(db.Integer, comment='是否启用')
|
|
||||||
remark = db.Column(db.String(255), comment='备注')
|
|
||||||
details = db.Column(db.String(255), comment='详情')
|
|
||||||
sort = db.Column(db.Integer, comment='排序')
|
|
||||||
create_time = db.Column(db.DateTime, default=datetime.datetime.now, comment='创建时间')
|
|
||||||
update_time = db.Column(db.DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now, comment='更新时间')
|
|
||||||
power = db.relationship('Power', secondary="admin_role_power", backref=db.backref('role'))
|
|
||||||
|
|
||||||
|
|
||||||
# 创建中间表
|
|
||||||
role_power = db.Table(
|
|
||||||
"admin_role_power", # 中间表名称
|
|
||||||
db.Column("id", db.Integer, primary_key=True, autoincrement=True, comment='标识'), # 主键
|
|
||||||
db.Column("power_id", db.Integer, db.ForeignKey("admin_power.id"), comment='用户编号'), # 属性 外键
|
|
||||||
db.Column("role_id", db.Integer, db.ForeignKey("admin_role.id"), comment='角色编号'), # 属性 外键
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Power(db.Model):
|
|
||||||
__tablename__ = 'admin_power'
|
|
||||||
id = db.Column(db.Integer, primary_key=True, comment='权限编号')
|
|
||||||
name = db.Column(db.String(255), comment='权限名称')
|
|
||||||
type = db.Column(db.String(1), comment='权限类型')
|
|
||||||
code = db.Column(db.String(30), comment='权限标识')
|
|
||||||
url = db.Column(db.String(255), comment='权限路径')
|
|
||||||
open_type = db.Column(db.String(10), comment='打开方式')
|
|
||||||
parent_id = db.Column(db.Integer, comment='父类编号')
|
|
||||||
icon = db.Column(db.String(128), comment='图标')
|
|
||||||
sort = db.Column(db.Integer, comment='排序')
|
|
||||||
create_time = db.Column(db.DateTime, default=datetime.datetime.now, comment='创建时间')
|
|
||||||
update_time = db.Column(db.DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now, comment='更新时间')
|
|
||||||
enable = db.Column(db.Integer, comment='是否开启')
|
|
||||||
|
|
||||||
|
|
||||||
class AdminLog(db.Model):
|
|
||||||
__tablename__ = 'admin_admin_log'
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
|
||||||
method = db.Column(db.String(10))
|
|
||||||
uid = db.Column(db.Integer)
|
|
||||||
url = db.Column(db.String(255))
|
|
||||||
desc = db.Column(db.Text)
|
|
||||||
ip = db.Column(db.String(255))
|
|
||||||
success = db.Column(db.Integer)
|
|
||||||
user_agent = db.Column(db.Text)
|
|
||||||
create_time = db.Column(db.DateTime, default=datetime.datetime.now)
|
|
||||||
|
|
||||||
|
|
||||||
class Photo(db.Model):
|
|
||||||
__tablename__ = 'admin_photo'
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
|
||||||
name = db.Column(db.String(255), nullable=False)
|
|
||||||
href = db.Column(db.String(255))
|
|
||||||
mime = db.Column(db.CHAR(50), nullable=False)
|
|
||||||
size = db.Column(db.CHAR(30), nullable=False)
|
|
||||||
create_time = db.Column(db.DateTime, default=datetime.datetime.now)
|
|
||||||
|
|
||||||
|
|
||||||
class DictType(db.Model):
|
|
||||||
__tablename__ = 'admin_dict_type'
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
|
||||||
type_name = db.Column(db.String(255), comment='字典类型名称')
|
|
||||||
type_code = db.Column(db.String(255), comment='字典类型标识')
|
|
||||||
description = db.Column(db.String(255), comment='字典类型描述')
|
|
||||||
enable = db.Column(db.Integer, comment='是否开启')
|
|
||||||
create_time = db.Column(db.DateTime, default=datetime.datetime.now, comment='创建时间')
|
|
||||||
update_time = db.Column(db.DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now, comment='更新时间')
|
|
||||||
|
|
||||||
|
|
||||||
class DictData(db.Model):
|
|
||||||
__tablename__ = 'admin_dict_data'
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
|
||||||
data_label = db.Column(db.String(255), comment='字典类型名称')
|
|
||||||
data_value = db.Column(db.String(255), comment='字典类型标识')
|
|
||||||
type_code = db.Column(db.String(255), comment='字典类型描述')
|
|
||||||
is_default = db.Column(db.Integer, comment='是否默认')
|
|
||||||
enable = db.Column(db.Integer, comment='是否开启')
|
|
||||||
remark = db.Column(db.String(255), comment='备注')
|
|
||||||
create_time = db.Column(db.DateTime, default=datetime.datetime.now, comment='创建时间')
|
|
||||||
update_time = db.Column(db.DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now, comment='更新时间')
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import datetime
|
||||||
|
|
||||||
|
from applications.models import db
|
||||||
|
|
||||||
|
|
||||||
|
class DictType(db.Model):
|
||||||
|
__tablename__ = 'admin_dict_type'
|
||||||
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
type_name = db.Column(db.String(255), comment='字典类型名称')
|
||||||
|
type_code = db.Column(db.String(255), comment='字典类型标识')
|
||||||
|
description = db.Column(db.String(255), comment='字典类型描述')
|
||||||
|
enable = db.Column(db.Integer, comment='是否开启')
|
||||||
|
create_time = db.Column(db.DateTime, default=datetime.datetime.now, comment='创建时间')
|
||||||
|
update_time = db.Column(db.DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now, comment='更新时间')
|
||||||
|
|
||||||
|
|
||||||
|
class DictData(db.Model):
|
||||||
|
__tablename__ = 'admin_dict_data'
|
||||||
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
data_label = db.Column(db.String(255), comment='字典类型名称')
|
||||||
|
data_value = db.Column(db.String(255), comment='字典类型标识')
|
||||||
|
type_code = db.Column(db.String(255), comment='字典类型描述')
|
||||||
|
is_default = db.Column(db.Integer, comment='是否默认')
|
||||||
|
enable = db.Column(db.Integer, comment='是否开启')
|
||||||
|
remark = db.Column(db.String(255), comment='备注')
|
||||||
|
create_time = db.Column(db.DateTime, default=datetime.datetime.now, comment='创建时间')
|
||||||
|
update_time = db.Column(db.DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now, comment='更新时间')
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import datetime
|
||||||
|
from applications.models import db
|
||||||
|
|
||||||
|
|
||||||
|
class AdminLog(db.Model):
|
||||||
|
__tablename__ = 'admin_admin_log'
|
||||||
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
method = db.Column(db.String(10))
|
||||||
|
uid = db.Column(db.Integer)
|
||||||
|
url = db.Column(db.String(255))
|
||||||
|
desc = db.Column(db.Text)
|
||||||
|
ip = db.Column(db.String(255))
|
||||||
|
success = db.Column(db.Integer)
|
||||||
|
user_agent = db.Column(db.Text)
|
||||||
|
create_time = db.Column(db.DateTime, default=datetime.datetime.now)
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import datetime
|
||||||
|
|
||||||
|
from applications.models import db
|
||||||
|
|
||||||
|
|
||||||
|
class Photo(db.Model):
|
||||||
|
__tablename__ = 'admin_photo'
|
||||||
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
name = db.Column(db.String(255), nullable=False)
|
||||||
|
href = db.Column(db.String(255))
|
||||||
|
mime = db.Column(db.CHAR(50), nullable=False)
|
||||||
|
size = db.Column(db.CHAR(30), nullable=False)
|
||||||
|
create_time = db.Column(db.DateTime, default=datetime.datetime.now)
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import datetime
|
||||||
|
from applications.models import db
|
||||||
|
|
||||||
|
|
||||||
|
class Power(db.Model):
|
||||||
|
__tablename__ = 'admin_power'
|
||||||
|
id = db.Column(db.Integer, primary_key=True, comment='权限编号')
|
||||||
|
name = db.Column(db.String(255), comment='权限名称')
|
||||||
|
type = db.Column(db.String(1), comment='权限类型')
|
||||||
|
code = db.Column(db.String(30), comment='权限标识')
|
||||||
|
url = db.Column(db.String(255), comment='权限路径')
|
||||||
|
open_type = db.Column(db.String(10), comment='打开方式')
|
||||||
|
parent_id = db.Column(db.Integer, comment='父类编号')
|
||||||
|
icon = db.Column(db.String(128), comment='图标')
|
||||||
|
sort = db.Column(db.Integer, comment='排序')
|
||||||
|
create_time = db.Column(db.DateTime, default=datetime.datetime.now, comment='创建时间')
|
||||||
|
update_time = db.Column(db.DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now, comment='更新时间')
|
||||||
|
enable = db.Column(db.Integer, comment='是否开启')
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import datetime
|
||||||
|
from applications.models import db
|
||||||
|
|
||||||
|
|
||||||
|
class Role(db.Model):
|
||||||
|
__tablename__ = 'admin_role'
|
||||||
|
id = db.Column(db.Integer, primary_key=True, comment='角色ID')
|
||||||
|
name = db.Column(db.String(255), comment='角色名称')
|
||||||
|
code = db.Column(db.String(255), comment='角色标识')
|
||||||
|
enable = db.Column(db.Integer, comment='是否启用')
|
||||||
|
remark = db.Column(db.String(255), comment='备注')
|
||||||
|
details = db.Column(db.String(255), comment='详情')
|
||||||
|
sort = db.Column(db.Integer, comment='排序')
|
||||||
|
create_time = db.Column(db.DateTime, default=datetime.datetime.now, comment='创建时间')
|
||||||
|
update_time = db.Column(db.DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now, comment='更新时间')
|
||||||
|
power = db.relationship('Power', secondary="admin_role_power", backref=db.backref('role'))
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
from applications.models import db
|
||||||
|
# 创建中间表
|
||||||
|
role_power = db.Table(
|
||||||
|
"admin_role_power", # 中间表名称
|
||||||
|
db.Column("id", db.Integer, primary_key=True, autoincrement=True, comment='标识'), # 主键
|
||||||
|
db.Column("power_id", db.Integer, db.ForeignKey("admin_power.id"), comment='用户编号'), # 属性 外键
|
||||||
|
db.Column("role_id", db.Integer, db.ForeignKey("admin_role.id"), comment='角色编号'), # 属性 外键
|
||||||
|
)
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import datetime
|
||||||
|
from flask_login import UserMixin
|
||||||
|
from werkzeug.security import generate_password_hash, check_password_hash
|
||||||
|
from applications.models import db
|
||||||
|
|
||||||
|
|
||||||
|
class User(db.Model, UserMixin):
|
||||||
|
__tablename__ = 'admin_user'
|
||||||
|
id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment='用户ID')
|
||||||
|
username = db.Column(db.String(20), comment='用户名')
|
||||||
|
realname = db.Column(db.String(20), comment='真实名字')
|
||||||
|
avatar = db.Column(db.String(255), comment='头像', default="/static/admin/admin/images/avatar.jpg")
|
||||||
|
remark = db.Column(db.String(255), comment='备注')
|
||||||
|
password_hash = db.Column(db.String(128), comment='哈希密码')
|
||||||
|
enable = db.Column(db.Integer, default=0, comment='启用')
|
||||||
|
create_at = db.Column(db.DateTime, default=datetime.datetime.now, comment='创建时间')
|
||||||
|
update_at = db.Column(db.DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now, comment='创建时间')
|
||||||
|
role = db.relationship('Role', secondary="admin_user_role", backref=db.backref('user'), lazy='dynamic')
|
||||||
|
|
||||||
|
def set_password(self, password):
|
||||||
|
self.password_hash = generate_password_hash(password)
|
||||||
|
|
||||||
|
def validate_password(self, password):
|
||||||
|
return check_password_hash(self.password_hash, password)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
from applications.models import db
|
||||||
|
# 创建中间表
|
||||||
|
user_role = db.Table(
|
||||||
|
"admin_user_role", # 中间表名称
|
||||||
|
db.Column("id", db.Integer, primary_key=True, autoincrement=True, comment='标识'), # 主键
|
||||||
|
db.Column("user_id", db.Integer, db.ForeignKey("admin_user.id"), comment='用户编号'), # 属性 外键
|
||||||
|
db.Column("role_id", db.Integer, db.ForeignKey("admin_role.id"), comment='角色编号'), # 属性 外键
|
||||||
|
)
|
||||||
@@ -5,7 +5,7 @@ from flask_marshmallow import Marshmallow
|
|||||||
from marshmallow import fields
|
from marshmallow import fields
|
||||||
|
|
||||||
from applications.models import db
|
from applications.models import db
|
||||||
from applications.models.admin import DictType, DictData
|
from applications.models.admin_dict import DictType, DictData
|
||||||
|
|
||||||
ma = Marshmallow()
|
ma = Marshmallow()
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from flask_marshmallow import Marshmallow
|
|||||||
from marshmallow import fields
|
from marshmallow import fields
|
||||||
from sqlalchemy import desc
|
from sqlalchemy import desc
|
||||||
from applications.models import db
|
from applications.models import db
|
||||||
from applications.models.admin import Photo
|
from applications.models.admin_photo import Photo
|
||||||
from applications.service.upload import photos
|
from applications.service.upload import photos
|
||||||
|
|
||||||
ma = Marshmallow()
|
ma = Marshmallow()
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ from flask import session, make_response
|
|||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from flask_marshmallow import Marshmallow
|
from flask_marshmallow import Marshmallow
|
||||||
from marshmallow import fields
|
from marshmallow import fields
|
||||||
from applications.models.admin import Power
|
|
||||||
from applications.service.CaptchaTool import gen_captcha
|
from applications.service.CaptchaTool import gen_captcha
|
||||||
|
|
||||||
ma = Marshmallow()
|
ma = Marshmallow()
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ from flask_marshmallow import Marshmallow
|
|||||||
from marshmallow import fields
|
from marshmallow import fields
|
||||||
|
|
||||||
from applications.models import db
|
from applications.models import db
|
||||||
from applications.models.admin import Power, Role
|
from applications.models.admin_power import Power
|
||||||
|
from applications.models.admin_role import Role
|
||||||
|
|
||||||
ma = Marshmallow()
|
ma = Marshmallow()
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
from flask import jsonify
|
|
||||||
from flask_marshmallow import Marshmallow
|
from flask_marshmallow import Marshmallow
|
||||||
from marshmallow import fields
|
from marshmallow import fields
|
||||||
from sqlalchemy import and_
|
from sqlalchemy import and_
|
||||||
|
|
||||||
from applications.models import db
|
from applications.models import db
|
||||||
from applications.models.admin import Role, Power, User
|
from applications.models.admin_role import Role
|
||||||
|
from applications.models.admin_power import Power
|
||||||
|
from applications.models.admin_user import User
|
||||||
|
|
||||||
ma = Marshmallow()
|
ma = Marshmallow()
|
||||||
|
|
||||||
@@ -147,8 +147,6 @@ def disable_status(id):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 删除角色
|
# 删除角色
|
||||||
def remove_role(id):
|
def remove_role(id):
|
||||||
role = Role.query.filter_by(id=id).first()
|
role = Role.query.filter_by(id=id).first()
|
||||||
@@ -177,4 +175,3 @@ def batch_remove(ids):
|
|||||||
# db.session.commit()
|
# db.session.commit()
|
||||||
for id in ids:
|
for id in ids:
|
||||||
remove_role(id)
|
remove_role(id)
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ from sqlalchemy import and_, desc
|
|||||||
from sqlalchemy.sql import exists
|
from sqlalchemy.sql import exists
|
||||||
|
|
||||||
from applications.models import db
|
from applications.models import db
|
||||||
from applications.models.admin import User, Role, AdminLog
|
from applications.models.admin_user import User
|
||||||
|
from applications.models.admin_role import Role
|
||||||
|
from applications.models.admin_log import AdminLog
|
||||||
from sqlalchemy.orm.dynamic import AppenderQuery
|
from sqlalchemy.orm.dynamic import AppenderQuery
|
||||||
|
|
||||||
ma = Marshmallow()
|
ma = Marshmallow()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
|
|
||||||
from applications.models import db
|
from applications.models import db
|
||||||
from applications.models.admin import AdminLog
|
from applications.models.admin_log import AdminLog
|
||||||
|
|
||||||
|
|
||||||
def login_log(request,uid, is_access):
|
def login_log(request,uid, is_access):
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ def init_flask_login(app):
|
|||||||
|
|
||||||
@login_manager.user_loader
|
@login_manager.user_loader
|
||||||
def load_user(user_id):
|
def load_user(user_id):
|
||||||
from applications.models.admin import User
|
from applications.models.admin_user import User
|
||||||
user = User.query.get(int(user_id))
|
user = User.query.get(int(user_id))
|
||||||
return user
|
return user
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from flask_login import login_required
|
|||||||
from flask_marshmallow import Marshmallow
|
from flask_marshmallow import Marshmallow
|
||||||
from marshmallow import fields
|
from marshmallow import fields
|
||||||
from sqlalchemy import desc
|
from sqlalchemy import desc
|
||||||
from applications.models.admin import AdminLog
|
from applications.models.admin_log import AdminLog
|
||||||
|
|
||||||
ma = Marshmallow()
|
ma = Marshmallow()
|
||||||
admin_log = Blueprint('adminLog', __name__, url_prefix='/admin/log')
|
admin_log = Blueprint('adminLog', __name__, url_prefix='/admin/log')
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
from flask import Blueprint, request, render_template, jsonify
|
||||||
|
from flask_login import login_required
|
||||||
|
from flask_marshmallow import Marshmallow
|
||||||
|
|
||||||
|
from applications.models import db
|
||||||
|
|
||||||
|
ma = Marshmallow()
|
||||||
|
admin_curd = Blueprint('adminCurd', __name__, url_prefix='/admin/curd')
|
||||||
|
|
||||||
|
@admin_curd.route('/')
|
||||||
|
def index():
|
||||||
|
colums=[]
|
||||||
|
colums.append("table_name")
|
||||||
|
colums.append(db.Column('id',db.Integer))
|
||||||
|
colums.append(db.Column('id', db.Integer, primary_key=True, comment="ID"))
|
||||||
|
colums.append(db.Column('url', db.String(255), comment=u"来源"))
|
||||||
|
colums.append(db.Column('date', db.DateTime, comment=u"记录时间"))
|
||||||
|
colums.append(db.Column('status', db.Integer, comment=u"是否回访"))
|
||||||
|
re = db.Table(*colums).columns
|
||||||
|
db.create_all()
|
||||||
|
return str(re)
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
from flask import Blueprint, render_template, request, jsonify
|
from flask import Blueprint, render_template, request, jsonify
|
||||||
|
|
||||||
from applications.models.admin import DictType, DictData
|
from applications.models.admin_dict import DictType, DictData
|
||||||
from applications.service.admin.dict import get_dict_type, get_dict_data, save_dict_type, save_dict_data, \
|
from applications.service.admin.dict import get_dict_type, get_dict_data, save_dict_type, save_dict_data, \
|
||||||
delete_type_by_id, delete_data_by_id, update_dict_type, enable_dict_type_status, disable_dict_type_status, \
|
delete_type_by_id, delete_data_by_id, update_dict_type, enable_dict_type_status, disable_dict_type_status, \
|
||||||
enable_dict_data_status, disable_dict_data_status, update_dict_data
|
enable_dict_data_status, disable_dict_data_status, update_dict_data
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import os
|
|||||||
from flask import Blueprint, request, render_template, jsonify, current_app
|
from flask import Blueprint, request, render_template, jsonify, current_app
|
||||||
from flask_login import login_required
|
from flask_login import login_required
|
||||||
from applications.models import db
|
from applications.models import db
|
||||||
from applications.models.admin import Photo
|
from applications.models.admin_photo import Photo
|
||||||
from applications.service.admin.file import get_photo, upload_one, delete_photo_by_id
|
from applications.service.admin.file import get_photo, upload_one, delete_photo_by_id
|
||||||
from applications.service.route_auth import authorize_and_log
|
from applications.service.route_auth import authorize_and_log
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from flask import Blueprint, render_template, jsonify, request, session, redirec
|
|||||||
from flask_login import login_user, login_required, logout_user, current_user
|
from flask_login import login_user, login_required, logout_user, current_user
|
||||||
from applications.service.admin.index import add_auth_session, make_menu_tree, get_captcha
|
from applications.service.admin.index import add_auth_session, make_menu_tree, get_captcha
|
||||||
from applications.service.admin_log import login_log
|
from applications.service.admin_log import login_log
|
||||||
from applications.models.admin import User
|
from applications.models.admin_user import User
|
||||||
|
|
||||||
admin_index = Blueprint('adminIndex', __name__, url_prefix='/admin')
|
admin_index = Blueprint('adminIndex', __name__, url_prefix='/admin')
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from flask import Blueprint, render_template, request, jsonify
|
from flask import Blueprint, render_template, request, jsonify
|
||||||
from flask_login import login_required, current_user
|
from flask_login import login_required, current_user
|
||||||
from applications.models.admin import User, Role
|
from applications.models.admin_user import User
|
||||||
|
from applications.models.admin_role import Role
|
||||||
from applications.service.admin.user import get_user_data_dict, add_user, delete_by_id, \
|
from applications.service.admin.user import get_user_data_dict, add_user, delete_by_id, \
|
||||||
batch_remove, update_user, update_user_role, is_user_exists, add_user_role, enable_status, disable_status, \
|
batch_remove, update_user, update_user_role, is_user_exists, add_user_role, enable_status, disable_status, \
|
||||||
edit_password, get_current_user_logs, update_current_user_info, update_avatar
|
edit_password, get_current_user_logs, update_current_user_info, update_avatar
|
||||||
|
|||||||
+4
-13
@@ -11,7 +11,7 @@
|
|||||||
Target Server Version : 50726
|
Target Server Version : 50726
|
||||||
File Encoding : 65001
|
File Encoding : 65001
|
||||||
|
|
||||||
Date: 16/04/2021 14:06:40
|
Date: 27/04/2021 11:57:13
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SET NAMES utf8mb4;
|
SET NAMES utf8mb4;
|
||||||
@@ -37,15 +37,6 @@ CREATE TABLE `admin_admin_log` (
|
|||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of admin_admin_log
|
-- Records of admin_admin_log
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `admin_admin_log` VALUES (1258, 'GET', 1, '/admin/user/', '{}', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36', '2021-04-16 14:06:11', 1);
|
|
||||||
INSERT INTO `admin_admin_log` VALUES (1259, 'GET', 1, '/admin/power/', '{}', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36', '2021-04-16 14:06:11', 1);
|
|
||||||
INSERT INTO `admin_admin_log` VALUES (1260, 'GET', 1, '/admin/role/', '{}', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36', '2021-04-16 14:06:11', 1);
|
|
||||||
INSERT INTO `admin_admin_log` VALUES (1261, 'GET', 1, '/admin/dict/', '{}', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36', '2021-04-16 14:06:11', 1);
|
|
||||||
INSERT INTO `admin_admin_log` VALUES (1262, 'GET', 1, '/admin/dict/dictType/data', '{\'page\': \'1\', \'limit\': \'10\'}', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36', '2021-04-16 14:06:12', 1);
|
|
||||||
INSERT INTO `admin_admin_log` VALUES (1263, 'GET', 1, '/admin/user/data', '{\'page\': \'1\', \'limit\': \'10\'}', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36', '2021-04-16 14:06:12', 1);
|
|
||||||
INSERT INTO `admin_admin_log` VALUES (1264, 'GET', 1, '/admin/role/data', '{\'page\': \'1\', \'limit\': \'10\'}', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36', '2021-04-16 14:06:12', 1);
|
|
||||||
INSERT INTO `admin_admin_log` VALUES (1265, 'GET', 1, '/admin/power/data', '{}', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36', '2021-04-16 14:06:12', 1);
|
|
||||||
INSERT INTO `admin_admin_log` VALUES (1266, 'GET', 1, '/admin/dict/dictType/add', '{}', '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36', '2021-04-16 14:06:14', 1);
|
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for admin_dict_data
|
-- Table structure for admin_dict_data
|
||||||
@@ -62,7 +53,7 @@ CREATE TABLE `admin_dict_data` (
|
|||||||
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
|
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
|
||||||
PRIMARY KEY (`id`) USING BTREE
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;
|
) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = DYNAMIC;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of admin_dict_data
|
-- Records of admin_dict_data
|
||||||
@@ -83,7 +74,7 @@ CREATE TABLE `admin_dict_type` (
|
|||||||
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
|
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
|
||||||
PRIMARY KEY (`id`) USING BTREE
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;
|
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = DYNAMIC;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of admin_dict_type
|
-- Records of admin_dict_type
|
||||||
@@ -288,6 +279,6 @@ CREATE TABLE `alembic_version` (
|
|||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of alembic_version
|
-- Records of alembic_version
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `alembic_version` VALUES ('85fcf9a09800');
|
INSERT INTO `alembic_version` VALUES ('ec21e19825ff');
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS = 1;
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Migrate(app=app, db=db)
|
|||||||
manager.add_command('db', MigrateCommand) # 创建数据库映射命令
|
manager.add_command('db', MigrateCommand) # 创建数据库映射命令
|
||||||
|
|
||||||
# import models不能省
|
# import models不能省
|
||||||
from applications.models import *
|
from applications.models import admin_user,admin_role,admin_power,admin_log,admin_photo,admin_dict,admin_role_power,admin_user_role
|
||||||
|
|
||||||
manager.add_command('start', Server(port=8080, use_debugger=True)) # 创建启动命令
|
manager.add_command('start', Server(port=8080, use_debugger=True)) # 创建启动命令
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Generic single-database configuration.
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# A generic, single database configuration.
|
||||||
|
|
||||||
|
[alembic]
|
||||||
|
# template used to generate migration files
|
||||||
|
# file_template = %%(rev)s_%%(slug)s
|
||||||
|
|
||||||
|
# set to 'true' to run the environment during
|
||||||
|
# the 'revision' command, regardless of autogenerate
|
||||||
|
# revision_environment = false
|
||||||
|
|
||||||
|
|
||||||
|
# Logging configuration
|
||||||
|
[loggers]
|
||||||
|
keys = root,sqlalchemy,alembic
|
||||||
|
|
||||||
|
[handlers]
|
||||||
|
keys = console
|
||||||
|
|
||||||
|
[formatters]
|
||||||
|
keys = generic
|
||||||
|
|
||||||
|
[logger_root]
|
||||||
|
level = WARN
|
||||||
|
handlers = console
|
||||||
|
qualname =
|
||||||
|
|
||||||
|
[logger_sqlalchemy]
|
||||||
|
level = WARN
|
||||||
|
handlers =
|
||||||
|
qualname = sqlalchemy.engine
|
||||||
|
|
||||||
|
[logger_alembic]
|
||||||
|
level = INFO
|
||||||
|
handlers =
|
||||||
|
qualname = alembic
|
||||||
|
|
||||||
|
[handler_console]
|
||||||
|
class = StreamHandler
|
||||||
|
args = (sys.stderr,)
|
||||||
|
level = NOTSET
|
||||||
|
formatter = generic
|
||||||
|
|
||||||
|
[formatter_generic]
|
||||||
|
format = %(levelname)-5.5s [%(name)s] %(message)s
|
||||||
|
datefmt = %H:%M:%S
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
from __future__ import with_statement
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from logging.config import fileConfig
|
||||||
|
|
||||||
|
from sqlalchemy import engine_from_config
|
||||||
|
from sqlalchemy import pool
|
||||||
|
from flask import current_app
|
||||||
|
|
||||||
|
from alembic import context
|
||||||
|
|
||||||
|
# this is the Alembic Config object, which provides
|
||||||
|
# access to the values within the .ini file in use.
|
||||||
|
config = context.config
|
||||||
|
|
||||||
|
# Interpret the config file for Python logging.
|
||||||
|
# This line sets up loggers basically.
|
||||||
|
fileConfig(config.config_file_name)
|
||||||
|
logger = logging.getLogger('alembic.env')
|
||||||
|
|
||||||
|
# add your model's MetaData object here
|
||||||
|
# for 'autogenerate' support
|
||||||
|
# from myapp import mymodel
|
||||||
|
# target_metadata = mymodel.Base.metadata
|
||||||
|
config.set_main_option(
|
||||||
|
'sqlalchemy.url',
|
||||||
|
str(current_app.extensions['migrate'].db.engine.url).replace('%', '%%'))
|
||||||
|
target_metadata = current_app.extensions['migrate'].db.metadata
|
||||||
|
|
||||||
|
# other values from the config, defined by the needs of env.py,
|
||||||
|
# can be acquired:
|
||||||
|
# my_important_option = config.get_main_option("my_important_option")
|
||||||
|
# ... etc.
|
||||||
|
|
||||||
|
|
||||||
|
def run_migrations_offline():
|
||||||
|
"""Run migrations in 'offline' mode.
|
||||||
|
|
||||||
|
This configures the context with just a URL
|
||||||
|
and not an Engine, though an Engine is acceptable
|
||||||
|
here as well. By skipping the Engine creation
|
||||||
|
we don't even need a DBAPI to be available.
|
||||||
|
|
||||||
|
Calls to context.execute() here emit the given string to the
|
||||||
|
script output.
|
||||||
|
|
||||||
|
"""
|
||||||
|
url = config.get_main_option("sqlalchemy.url")
|
||||||
|
context.configure(
|
||||||
|
url=url, target_metadata=target_metadata, literal_binds=True
|
||||||
|
)
|
||||||
|
|
||||||
|
with context.begin_transaction():
|
||||||
|
context.run_migrations()
|
||||||
|
|
||||||
|
|
||||||
|
def run_migrations_online():
|
||||||
|
"""Run migrations in 'online' mode.
|
||||||
|
|
||||||
|
In this scenario we need to create an Engine
|
||||||
|
and associate a connection with the context.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# this callback is used to prevent an auto-migration from being generated
|
||||||
|
# when there are no changes to the schema
|
||||||
|
# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
|
||||||
|
def process_revision_directives(context, revision, directives):
|
||||||
|
if getattr(config.cmd_opts, 'autogenerate', False):
|
||||||
|
script = directives[0]
|
||||||
|
if script.upgrade_ops.is_empty():
|
||||||
|
directives[:] = []
|
||||||
|
logger.info('No changes in schema detected.')
|
||||||
|
|
||||||
|
connectable = engine_from_config(
|
||||||
|
config.get_section(config.config_ini_section),
|
||||||
|
prefix='sqlalchemy.',
|
||||||
|
poolclass=pool.NullPool,
|
||||||
|
)
|
||||||
|
|
||||||
|
with connectable.connect() as connection:
|
||||||
|
context.configure(
|
||||||
|
connection=connection,
|
||||||
|
target_metadata=target_metadata,
|
||||||
|
process_revision_directives=process_revision_directives,
|
||||||
|
**current_app.extensions['migrate'].configure_args
|
||||||
|
)
|
||||||
|
|
||||||
|
with context.begin_transaction():
|
||||||
|
context.run_migrations()
|
||||||
|
|
||||||
|
|
||||||
|
if context.is_offline_mode():
|
||||||
|
run_migrations_offline()
|
||||||
|
else:
|
||||||
|
run_migrations_online()
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
"""${message}
|
||||||
|
|
||||||
|
Revision ID: ${up_revision}
|
||||||
|
Revises: ${down_revision | comma,n}
|
||||||
|
Create Date: ${create_date}
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
${imports if imports else ""}
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = ${repr(up_revision)}
|
||||||
|
down_revision = ${repr(down_revision)}
|
||||||
|
branch_labels = ${repr(branch_labels)}
|
||||||
|
depends_on = ${repr(depends_on)}
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
${upgrades if upgrades else "pass"}
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
${downgrades if downgrades else "pass"}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
"""empty message
|
"""empty message
|
||||||
|
|
||||||
Revision ID: 9a591b224cc7
|
Revision ID: ec21e19825ff
|
||||||
Revises:
|
Revises:
|
||||||
Create Date: 2021-04-16 10:13:27.930524
|
Create Date: 2021-04-27 11:54:00.453274
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from alembic import op
|
from alembic import op
|
||||||
@@ -10,7 +10,7 @@ import sqlalchemy as sa
|
|||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = '9a591b224cc7'
|
revision = 'ec21e19825ff'
|
||||||
down_revision = None
|
down_revision = None
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
Reference in New Issue
Block a user