flask-restful依赖替换完成
This commit is contained in:
@@ -13,3 +13,64 @@ power_fields = {
|
|||||||
'update_time': fields.DateTime,
|
'update_time': fields.DateTime,
|
||||||
'enable': fields.Integer,
|
'enable': fields.Integer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
power2_fields = {
|
||||||
|
'id': fields.Integer,
|
||||||
|
'title': fields.String(attribute="name"),
|
||||||
|
'type': fields.String,
|
||||||
|
'code': fields.String,
|
||||||
|
'href': fields.String(attribute="url"),
|
||||||
|
'openType': fields.String(attribute="open_type"),
|
||||||
|
'parent_id': fields.Integer,
|
||||||
|
'icon': fields.String,
|
||||||
|
'sort': fields.Integer,
|
||||||
|
'create_time': fields.DateTime,
|
||||||
|
'update_time': fields.DateTime,
|
||||||
|
'enable': fields.Integer,
|
||||||
|
}
|
||||||
|
|
||||||
|
role_fields = {
|
||||||
|
'id': fields.Integer,
|
||||||
|
'roleName': fields.String(attribute="name"),
|
||||||
|
'roleCode': fields.String(attribute="code"),
|
||||||
|
'enable': fields.String,
|
||||||
|
'remark': fields.String,
|
||||||
|
'details': fields.String,
|
||||||
|
'sort': fields.Integer,
|
||||||
|
'create_at': fields.DateTime,
|
||||||
|
'update_at': fields.DateTime,
|
||||||
|
}
|
||||||
|
|
||||||
|
log_fields = {
|
||||||
|
'id': fields.Integer,
|
||||||
|
'method': fields.String,
|
||||||
|
'uid': fields.String,
|
||||||
|
'url': fields.String,
|
||||||
|
'desc': fields.String,
|
||||||
|
'ip': fields.String,
|
||||||
|
'user_agent': fields.String,
|
||||||
|
'success': fields.Boolean,
|
||||||
|
'create_time': fields.DateTime,
|
||||||
|
}
|
||||||
|
|
||||||
|
dept_fields = {
|
||||||
|
'deptId': fields.Integer(attribute="id"),
|
||||||
|
'parentId': fields.Integer(attribute="parent_id"),
|
||||||
|
'deptName': fields.String(attribute="dept_name"),
|
||||||
|
'leader': fields.String,
|
||||||
|
'phone': fields.String,
|
||||||
|
'email': fields.String,
|
||||||
|
'address': fields.String,
|
||||||
|
'status': fields.Integer,
|
||||||
|
'sort': fields.Integer,
|
||||||
|
}
|
||||||
|
|
||||||
|
photo_fields = {
|
||||||
|
'id': fields.Integer,
|
||||||
|
'name': fields.String,
|
||||||
|
'href': fields.String,
|
||||||
|
'mime': fields.String,
|
||||||
|
'size': fields.String,
|
||||||
|
'ext': fields.String,
|
||||||
|
'create_time': fields.DateTime,
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class TestingConfig(BaseConfig):
|
|||||||
|
|
||||||
class DevelopmentConfig(BaseConfig):
|
class DevelopmentConfig(BaseConfig):
|
||||||
""" 开发配置 """
|
""" 开发配置 """
|
||||||
# SQLALCHEMY_DATABASE_URI = r'sqlite:///../sql_pear_admin.db'
|
SQLALCHEMY_DATABASE_URI = r'sqlite:///../sql_pear_admin.db'
|
||||||
SQLALCHEMY_TRACK_MODIFICATIONS = True
|
SQLALCHEMY_TRACK_MODIFICATIONS = True
|
||||||
SQLALCHEMY_ECHO = False
|
SQLALCHEMY_ECHO = False
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
|
||||||
from .init_databases import register_script
|
from .init_databases import register_script
|
||||||
from .init_sqlalchemy import db, ma, init_databases
|
from .init_sqlalchemy import db, init_databases
|
||||||
from .init_login import init_login_manager
|
from .init_login import init_login_manager
|
||||||
from .init_template_directives import init_template_directives
|
from .init_template_directives import init_template_directives
|
||||||
from .init_error_views import init_error_views
|
from .init_error_views import init_error_views
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
import json
|
|
||||||
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
import re
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
date_str = re.compile('\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d$')
|
||||||
|
|
||||||
|
|
||||||
def add_data(fields, data_list, obj):
|
def add_data(fields, data_list, obj):
|
||||||
from applications.extensions import db
|
from applications.extensions import db
|
||||||
|
|
||||||
for _data in data_list:
|
for _data in data_list:
|
||||||
dept = obj()
|
dept = obj()
|
||||||
for key, value in dict(zip(fields, _data)).items():
|
for key, value in dict(zip(fields, _data)).items():
|
||||||
|
|
||||||
|
if isinstance(value, str) and date_str.match(value):
|
||||||
|
value = datetime.strptime(value, "%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
setattr(dept, key, value)
|
setattr(dept, key, value)
|
||||||
db.session.add(dept)
|
db.session.add(dept)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
@@ -29,8 +36,10 @@ def create_dept_data():
|
|||||||
]
|
]
|
||||||
_fields = ['id', 'parent_id', 'dept_name', 'sort', 'leader', 'phone', 'email', 'status', 'remark', 'address',
|
_fields = ['id', 'parent_id', 'dept_name', 'sort', 'leader', 'phone', 'email', 'status', 'remark', 'address',
|
||||||
'create_at', 'update_at']
|
'create_at', 'update_at']
|
||||||
add_data(_fields, _data_list, Dept)
|
|
||||||
|
|
||||||
|
_data_list = [item for item in _data_list]
|
||||||
|
|
||||||
|
add_data(_fields, _data_list, Dept)
|
||||||
|
|
||||||
|
|
||||||
def create_admin_photo():
|
def create_admin_photo():
|
||||||
@@ -65,10 +74,6 @@ def create_admin_power():
|
|||||||
(4, '权限管理', '1', 'admin:power:main', '/rights/', '_iframe', '1', None, 2, None, None, 1),
|
(4, '权限管理', '1', 'admin:power:main', '/rights/', '_iframe', '1', None, 2, None, None, 1),
|
||||||
(9, '角色管理', '1', 'admin:role:main', '/admin/role', '_iframe', '1', 'layui-icon layui-icon-username', 2,
|
(9, '角色管理', '1', 'admin:role:main', '/admin/role', '_iframe', '1', 'layui-icon layui-icon-username', 2,
|
||||||
'2021-03-16 22:24:58', '2021-03-25 19:15:24', 1),
|
'2021-03-16 22:24:58', '2021-03-25 19:15:24', 1),
|
||||||
(
|
|
||||||
12, '系统监控', '1', 'admin:monitor:main', '/admin/monitor', '_iframe', '1',
|
|
||||||
'layui-icon layui-icon-vercode', 5,
|
|
||||||
'2021-03-18 22:05:19', '2021-03-25 19:15:27', 1),
|
|
||||||
(13, '日志管理', '1', 'admin:log:main', '/logs', '_iframe', '1', 'layui-icon layui-icon-read', 4,
|
(13, '日志管理', '1', 'admin:log:main', '/logs', '_iframe', '1', 'layui-icon layui-icon-read', 4,
|
||||||
'2021-03-18 22:37:10', '2021-06-03 11:06:25', 1),
|
'2021-03-18 22:37:10', '2021-06-03 11:06:25', 1),
|
||||||
(17, '文件管理', '0', '', '', '', '0', 'layui-icon layui-icon-camera', 2, '2021-03-19 18:56:23',
|
(17, '文件管理', '0', '', '', '', '0', 'layui-icon layui-icon-camera', 2, '2021-03-19 18:56:23',
|
||||||
@@ -158,7 +163,6 @@ def create_admin_role():
|
|||||||
|
|
||||||
|
|
||||||
def create_admin_role_power():
|
def create_admin_role_power():
|
||||||
from applications.models import user_role
|
|
||||||
from applications.extensions import db
|
from applications.extensions import db
|
||||||
|
|
||||||
_data_list = [
|
_data_list = [
|
||||||
@@ -252,15 +256,6 @@ def create_admin_user_role() -> object:
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
def create_example():
|
|
||||||
from applications.models import DictData
|
|
||||||
|
|
||||||
_fields = []
|
|
||||||
_data_list = []
|
|
||||||
|
|
||||||
add_data(_fields, _data_list, DictData)
|
|
||||||
|
|
||||||
|
|
||||||
def register_script(app: Flask):
|
def register_script(app: Flask):
|
||||||
@app.cli.command()
|
@app.cli.command()
|
||||||
def init_db():
|
def init_db():
|
||||||
@@ -275,6 +270,7 @@ def register_script(app: Flask):
|
|||||||
|
|
||||||
@app.cli.command()
|
@app.cli.command()
|
||||||
def turn():
|
def turn():
|
||||||
|
"""清空数据库"""
|
||||||
from applications.extensions import db
|
from applications.extensions import db
|
||||||
db.drop_all()
|
db.drop_all()
|
||||||
db.create_all()
|
db.create_all()
|
||||||
|
|||||||
@@ -1,57 +1,11 @@
|
|||||||
from flask import Flask
|
from flask import Flask
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
from flask_marshmallow import Marshmallow
|
|
||||||
from flask_migrate import Migrate
|
from flask_migrate import Migrate
|
||||||
from marshmallow import fields
|
|
||||||
from marshmallow.validate import (
|
|
||||||
URL, Email, Range, Length, Equal, Regexp,
|
|
||||||
Predicate, NoneOf, OneOf, ContainsOnly
|
|
||||||
)
|
|
||||||
|
|
||||||
URL.default_message = '无效的链接'
|
|
||||||
Email.default_message = '无效的邮箱地址'
|
|
||||||
Range.message_min = '不能小于{min}'
|
|
||||||
Range.message_max = '不能小于{max}'
|
|
||||||
Range.message_all = '不能超过{min}和{max}这个范围'
|
|
||||||
Length.message_min = '长度不得小于{min}位'
|
|
||||||
Length.message_max = '长度不得大于{max}位'
|
|
||||||
Length.message_all = '长度不能超过{min}和{max}这个范围'
|
|
||||||
Length.message_equal = '长度必须等于{equal}位'
|
|
||||||
Equal.default_message = '必须等于{other}'
|
|
||||||
Regexp.default_message = '非法输入'
|
|
||||||
Predicate.default_message = '非法输入'
|
|
||||||
NoneOf.default_message = '非法输入'
|
|
||||||
OneOf.default_message = '无效的选择'
|
|
||||||
ContainsOnly.default_message = '一个或多个无效的选择'
|
|
||||||
|
|
||||||
fields.Field.default_error_messages = {
|
|
||||||
"required": "缺少必要数据",
|
|
||||||
"null": "数据不能为空",
|
|
||||||
"validator_failed": "非法数据",
|
|
||||||
}
|
|
||||||
|
|
||||||
fields.Str.default_error_messages = {
|
|
||||||
'invalid': "不是合法文本"
|
|
||||||
}
|
|
||||||
|
|
||||||
fields.Int.default_error_messages = {
|
|
||||||
"invalid": "不是合法整数"
|
|
||||||
}
|
|
||||||
|
|
||||||
fields.Number.default_error_messages = {
|
|
||||||
"invalid": "不是合法数字"
|
|
||||||
}
|
|
||||||
|
|
||||||
fields.Boolean.default_error_messages = {
|
|
||||||
"invalid": "不是合法布尔值"
|
|
||||||
}
|
|
||||||
|
|
||||||
db = SQLAlchemy()
|
db = SQLAlchemy()
|
||||||
ma = Marshmallow()
|
|
||||||
migrate = Migrate()
|
migrate = Migrate()
|
||||||
|
|
||||||
|
|
||||||
def init_databases(app: Flask):
|
def init_databases(app: Flask):
|
||||||
db.init_app(app)
|
db.init_app(app)
|
||||||
ma.init_app(app)
|
|
||||||
migrate.init_app(app, db)
|
migrate.init_app(app, db)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from applications.models.company import Dept, DeptSchema, User
|
from applications.models.company import Dept, User
|
||||||
from .log import AdminLog, LogSchema
|
from applications.models.log import AdminLog
|
||||||
from applications.models.file.photo import Photo, PhotoSchema
|
from applications.models.file.photo import Photo
|
||||||
from applications.models.rights.power import Power, PowerSchema
|
from applications.models.rights.power import Power
|
||||||
from applications.models.rights.role import Role, RoleSchema
|
from applications.models.rights.role import Role
|
||||||
from applications.models.rights.role_power import role_power
|
from applications.models.rights.role_power import role_power
|
||||||
from applications.models.rights.user_role import user_role
|
from applications.models.rights.user_role import user_role
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
from .dept import Dept, DeptSchema
|
from .dept import Dept
|
||||||
from .users import User
|
from .users import User
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from applications.extensions import db, ma
|
from applications.extensions import db
|
||||||
from marshmallow import fields, validate
|
|
||||||
|
|
||||||
|
|
||||||
class Dept(db.Model):
|
class Dept(db.Model):
|
||||||
@@ -17,15 +16,3 @@ class Dept(db.Model):
|
|||||||
address = db.Column(db.String(255), comment="详细地址")
|
address = db.Column(db.String(255), comment="详细地址")
|
||||||
create_at = db.Column(db.DateTime, default=datetime.datetime.now, 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='创建时间')
|
update_at = db.Column(db.DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now, comment='创建时间')
|
||||||
|
|
||||||
|
|
||||||
class DeptSchema(ma.Schema): # 序列化类
|
|
||||||
deptId = fields.Integer(attribute="id")
|
|
||||||
parentId = fields.Integer(attribute="parent_id")
|
|
||||||
deptName = fields.Str(attribute="dept_name")
|
|
||||||
leader = fields.Str()
|
|
||||||
phone = fields.Str()
|
|
||||||
email = fields.Str(validate=validate.Email())
|
|
||||||
address = fields.Str()
|
|
||||||
status = fields.Str(validate=validate.OneOf(["0", "1"]))
|
|
||||||
sort = fields.Integer()
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from flask_login import UserMixin
|
from flask_login import UserMixin
|
||||||
from werkzeug.security import generate_password_hash, check_password_hash
|
from werkzeug.security import generate_password_hash, check_password_hash
|
||||||
from applications.extensions import db, ma
|
from applications.extensions import db
|
||||||
from marshmallow import fields
|
|
||||||
|
|
||||||
|
|
||||||
class User(db.Model, UserMixin):
|
class User(db.Model, UserMixin):
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from applications.extensions import db, ma
|
from applications.extensions import db
|
||||||
from marshmallow import fields
|
|
||||||
|
|
||||||
|
|
||||||
class Photo(db.Model):
|
class Photo(db.Model):
|
||||||
@@ -13,12 +12,3 @@ class Photo(db.Model):
|
|||||||
size = db.Column(db.CHAR(30), nullable=False)
|
size = db.Column(db.CHAR(30), nullable=False)
|
||||||
create_time = db.Column(db.DateTime, default=datetime.datetime.now)
|
create_time = db.Column(db.DateTime, default=datetime.datetime.now)
|
||||||
|
|
||||||
|
|
||||||
class PhotoSchema(ma.Schema):
|
|
||||||
id = fields.Integer()
|
|
||||||
name = fields.Str()
|
|
||||||
href = fields.Str()
|
|
||||||
mime = fields.Str()
|
|
||||||
size = fields.Str()
|
|
||||||
ext = fields.Str()
|
|
||||||
create_time = fields.DateTime()
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from applications.extensions import db, ma
|
from applications.extensions import db
|
||||||
from marshmallow import fields
|
|
||||||
|
|
||||||
|
|
||||||
class AdminLog(db.Model):
|
class AdminLog(db.Model):
|
||||||
@@ -14,15 +13,3 @@ class AdminLog(db.Model):
|
|||||||
success = db.Column(db.Integer)
|
success = db.Column(db.Integer)
|
||||||
user_agent = db.Column(db.Text)
|
user_agent = db.Column(db.Text)
|
||||||
create_time = db.Column(db.DateTime, default=datetime.now)
|
create_time = db.Column(db.DateTime, default=datetime.now)
|
||||||
|
|
||||||
|
|
||||||
class LogSchema(ma.Schema): # 序列化类
|
|
||||||
id = fields.Integer()
|
|
||||||
method = fields.Str()
|
|
||||||
uid = fields.Str()
|
|
||||||
url = fields.Str()
|
|
||||||
desc = fields.Str()
|
|
||||||
ip = fields.Str()
|
|
||||||
user_agent = fields.Str()
|
|
||||||
success = fields.Bool()
|
|
||||||
create_time = fields.DateTime()
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from applications.extensions import db, ma
|
from applications.extensions import db
|
||||||
from marshmallow import fields
|
|
||||||
|
|
||||||
|
|
||||||
class Power(db.Model):
|
class Power(db.Model):
|
||||||
@@ -19,21 +18,3 @@ class Power(db.Model):
|
|||||||
enable = db.Column(db.Integer, comment='是否开启')
|
enable = db.Column(db.Integer, comment='是否开启')
|
||||||
|
|
||||||
parent = db.relationship("Power", remote_side=[id]) # 自关联
|
parent = db.relationship("Power", remote_side=[id]) # 自关联
|
||||||
|
|
||||||
|
|
||||||
# 权限 models 序列化类
|
|
||||||
class PowerSchema(ma.Schema):
|
|
||||||
id = fields.Integer()
|
|
||||||
title = fields.Str(attribute="name")
|
|
||||||
type = fields.Str()
|
|
||||||
code = fields.Str()
|
|
||||||
href = fields.Str(attribute="url")
|
|
||||||
openType = fields.Str(attribute="open_type")
|
|
||||||
parent_id = fields.Integer()
|
|
||||||
icon = fields.Str()
|
|
||||||
sort = fields.Integer()
|
|
||||||
create_time = fields.DateTime()
|
|
||||||
update_time = fields.DateTime()
|
|
||||||
enable = fields.Integer()
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from applications.extensions import db, ma
|
from applications.extensions import db
|
||||||
from marshmallow import fields
|
|
||||||
|
|
||||||
|
|
||||||
class Role(db.Model):
|
class Role(db.Model):
|
||||||
@@ -15,15 +14,3 @@ class Role(db.Model):
|
|||||||
create_time = db.Column(db.DateTime, default=datetime.datetime.now, 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='更新时间')
|
update_time = db.Column(db.DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now, comment='更新时间')
|
||||||
power = db.relationship('Power', secondary="rt_role_power", backref=db.backref('role'))
|
power = db.relationship('Power', secondary="rt_role_power", backref=db.backref('role'))
|
||||||
|
|
||||||
|
|
||||||
class RoleSchema(ma.Schema):
|
|
||||||
id = fields.Integer()
|
|
||||||
roleName = fields.Str(attribute="name")
|
|
||||||
roleCode = fields.Str(attribute="code")
|
|
||||||
enable = fields.Str()
|
|
||||||
remark = fields.Str()
|
|
||||||
details = fields.Str()
|
|
||||||
sort = fields.Integer()
|
|
||||||
create_at = fields.DateTime()
|
|
||||||
update_at = fields.DateTime()
|
|
||||||
|
|||||||
+2
-2
@@ -2024,7 +2024,7 @@ window.tinymce.Resource.add("tinymce.plugins.emoticons", {
|
|||||||
category: "people"
|
category: "people"
|
||||||
},
|
},
|
||||||
school_satchel: {
|
school_satchel: {
|
||||||
keywords: [ "vip", "education", "bag", "backpack" ],
|
keywords: [ "student", "education", "bag", "backpack" ],
|
||||||
"char": '<img data-emoticon="true" style="width:1em;height:1em;margin:0 .05em 0 .1em;vertical-align:-.1em" draggable="false" alt="\ud83c\udf92" src="1f392.png"/>',
|
"char": '<img data-emoticon="true" style="width:1em;height:1em;margin:0 .05em 0 .1em;vertical-align:-.1em" draggable="false" alt="\ud83c\udf92" src="1f392.png"/>',
|
||||||
fitzpatrick_scale: false,
|
fitzpatrick_scale: false,
|
||||||
category: "people"
|
category: "people"
|
||||||
@@ -5012,7 +5012,7 @@ window.tinymce.Resource.add("tinymce.plugins.emoticons", {
|
|||||||
category: "travel_and_places"
|
category: "travel_and_places"
|
||||||
},
|
},
|
||||||
school: {
|
school: {
|
||||||
keywords: [ "building", "vip", "education", "learn", "teach" ],
|
keywords: [ "building", "student", "education", "learn", "teach" ],
|
||||||
"char": '<img data-emoticon="true" style="width:1em;height:1em;margin:0 .05em 0 .1em;vertical-align:-.1em" draggable="false" alt="\ud83c\udfeb" src="1f3eb.png"/>',
|
"char": '<img data-emoticon="true" style="width:1em;height:1em;margin:0 .05em 0 .1em;vertical-align:-.1em" draggable="false" alt="\ud83c\udfeb" src="1f3eb.png"/>',
|
||||||
fitzpatrick_scale: false,
|
fitzpatrick_scale: false,
|
||||||
category: "travel_and_places"
|
category: "travel_and_places"
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+2
-2
@@ -2011,7 +2011,7 @@ window.tinymce.Resource.add("tinymce.plugins.emoticons", {
|
|||||||
category: "people"
|
category: "people"
|
||||||
},
|
},
|
||||||
school_satchel: {
|
school_satchel: {
|
||||||
keywords: [ "vip", "education", "bag", "backpack" ],
|
keywords: [ "student", "education", "bag", "backpack" ],
|
||||||
"char": "\ud83c\udf92",
|
"char": "\ud83c\udf92",
|
||||||
fitzpatrick_scale: false,
|
fitzpatrick_scale: false,
|
||||||
category: "people"
|
category: "people"
|
||||||
@@ -4999,7 +4999,7 @@ window.tinymce.Resource.add("tinymce.plugins.emoticons", {
|
|||||||
category: "travel_and_places"
|
category: "travel_and_places"
|
||||||
},
|
},
|
||||||
school: {
|
school: {
|
||||||
keywords: [ "building", "vip", "education", "learn", "teach" ],
|
keywords: [ "building", "student", "education", "learn", "teach" ],
|
||||||
"char": "\ud83c\udfeb",
|
"char": "\ud83c\udfeb",
|
||||||
fitzpatrick_scale: false,
|
fitzpatrick_scale: false,
|
||||||
category: "travel_and_places"
|
category: "travel_and_places"
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -102,7 +102,7 @@
|
|||||||
/*表单组件,提交按钮之后触发的事件*/
|
/*表单组件,提交按钮之后触发的事件*/
|
||||||
form.on('submit(dept-save)', function (data) {
|
form.on('submit(dept-save)', function (data) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/dept/save',
|
url: '/dept/add',
|
||||||
data: JSON.stringify(data.field),
|
data: JSON.stringify(data.field),
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
|
|||||||
@@ -100,7 +100,7 @@
|
|||||||
// 当点击更新之后,获取数据
|
// 当点击更新之后,获取数据
|
||||||
form.on('submit(dept-update)', function (data) {
|
form.on('submit(dept-update)', function (data) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/dept/update',
|
url: '/dept/edit' + data.field.deptId,
|
||||||
data: JSON.stringify(data.field),
|
data: JSON.stringify(data.field),
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
|
|||||||
@@ -180,14 +180,14 @@
|
|||||||
form.on('switch(dept-enable)', function (obj) {
|
form.on('switch(dept-enable)', function (obj) {
|
||||||
let operate
|
let operate
|
||||||
if (obj.elem.checked) {
|
if (obj.elem.checked) {
|
||||||
operate = 'enable'
|
operate = 1
|
||||||
} else {
|
} else {
|
||||||
operate = 'disable'
|
operate = 0
|
||||||
}
|
}
|
||||||
let loading = layer.load()
|
let loading = layer.load()
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/dept/' + operate,
|
url: '/dept/enable',
|
||||||
data: JSON.stringify({ deptId: this.value }),
|
data: JSON.stringify({ deptId: this.value, operate: operate }),
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
type: 'put',
|
type: 'put',
|
||||||
@@ -218,7 +218,7 @@
|
|||||||
title: '修改',
|
title: '修改',
|
||||||
shade: 0.1,
|
shade: 0.1,
|
||||||
area: ['450px', '500px'],
|
area: ['450px', '500px'],
|
||||||
content: MODULE_PATH + 'edit?deptId=' + obj.data['deptId'] /*编辑修改窗口从那里来*/
|
content: MODULE_PATH + 'edit/' + obj.data['deptId'] /*编辑修改窗口从那里来*/
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@
|
|||||||
layer.close(index)
|
layer.close(index)
|
||||||
let loading = layer.load()
|
let loading = layer.load()
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: MODULE_PATH + 'remove/' + obj.data['deptId'],
|
url: MODULE_PATH + 'edit/' + obj.data['deptId'],
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
type: 'delete',
|
type: 'delete',
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
|
|||||||
@@ -1,18 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from sqlalchemy import desc
|
|
||||||
|
|
||||||
from applications.common.utils.upload import photos
|
from applications.common.utils.upload import photos
|
||||||
from applications.extensions import db
|
from applications.extensions import db
|
||||||
from applications.models import Photo, PhotoSchema
|
from applications.models import Photo
|
||||||
from applications.common.curd import model_to_dicts
|
|
||||||
|
|
||||||
|
|
||||||
def get_photo(page, limit):
|
|
||||||
photo = Photo.query.order_by(desc(Photo.create_time)).paginate(page=page, per_page=limit, error_out=False)
|
|
||||||
count = Photo.query.count()
|
|
||||||
data = model_to_dicts(Schema=PhotoSchema, model=photo.items)
|
|
||||||
return data, count
|
|
||||||
|
|
||||||
|
|
||||||
def upload_one(photo, mime):
|
def upload_one(photo, mime):
|
||||||
@@ -1,11 +1,15 @@
|
|||||||
import os
|
import os
|
||||||
from flask import Blueprint, request, render_template, jsonify, current_app, make_response
|
from flask import Blueprint, request, render_template, jsonify, current_app, make_response
|
||||||
from flask_restful import Api, Resource
|
from flask_restful import Api, Resource, marshal
|
||||||
|
from sqlalchemy import desc
|
||||||
|
|
||||||
|
from applications.common.serialization import photo_fields
|
||||||
from applications.common.utils.http import fail_api, success_api, table_api
|
from applications.common.utils.http import fail_api, success_api, table_api
|
||||||
from applications.common.utils.rights import authorize
|
from applications.common.utils.rights import authorize
|
||||||
from applications.extensions import db
|
from applications.extensions import db
|
||||||
from applications.models import Photo
|
from applications.models import Photo
|
||||||
from applications.view.admin import file_curd
|
|
||||||
|
from ._utils import delete_photo_by_id, upload_one
|
||||||
|
|
||||||
file_bp = Blueprint('file', __name__, url_prefix='/file')
|
file_bp = Blueprint('file', __name__, url_prefix='/file')
|
||||||
file_api = Api(file_bp)
|
file_api = Api(file_bp)
|
||||||
@@ -24,8 +28,9 @@ def index():
|
|||||||
def table():
|
def table():
|
||||||
page = request.args.get('page', type=int)
|
page = request.args.get('page', type=int)
|
||||||
limit = request.args.get('limit', type=int)
|
limit = request.args.get('limit', type=int)
|
||||||
data, count = file_curd.get_photo(page=page, limit=limit)
|
photo_paginate = Photo.query.order_by(desc(Photo.create_time)).paginate(page=page, per_page=limit, error_out=False)
|
||||||
return table_api(data=data, count=count)
|
data = marshal(photo_paginate.items, photo_fields)
|
||||||
|
return table_api(data=data, count=photo_paginate.total)
|
||||||
|
|
||||||
|
|
||||||
@file_api.resource('/upload')
|
@file_api.resource('/upload')
|
||||||
@@ -39,7 +44,8 @@ class Upload(Resource):
|
|||||||
if 'file' in request.files:
|
if 'file' in request.files:
|
||||||
photo = request.files['file']
|
photo = request.files['file']
|
||||||
mime = request.files['file'].content_type
|
mime = request.files['file'].content_type
|
||||||
file_url = file_curd.upload_one(photo=photo, mime=mime)
|
file_url = upload_one(photo=photo, mime=mime)
|
||||||
|
|
||||||
res = {
|
res = {
|
||||||
"msg": "上传成功",
|
"msg": "上传成功",
|
||||||
"code": 0,
|
"code": 0,
|
||||||
@@ -53,7 +59,7 @@ class Upload(Resource):
|
|||||||
@authorize("admin:file:delete", log=True)
|
@authorize("admin:file:delete", log=True)
|
||||||
def delete(self):
|
def delete(self):
|
||||||
_id = request.form.get('id')
|
_id = request.form.get('id')
|
||||||
res = file_curd.delete_photo_by_id(_id)
|
res = delete_photo_by_id(_id)
|
||||||
if res:
|
if res:
|
||||||
return success_api(msg="删除成功")
|
return success_api(msg="删除成功")
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
from flask import Blueprint, request, render_template
|
from flask import Blueprint, request, render_template
|
||||||
from sqlalchemy import desc
|
from sqlalchemy import desc
|
||||||
|
from flask_restful import marshal
|
||||||
|
from applications.common.serialization import log_fields
|
||||||
|
|
||||||
from applications.common.utils.http import table_api
|
from applications.common.utils.http import table_api
|
||||||
from applications.common.utils.rights import authorize
|
from applications.common.utils.rights import authorize
|
||||||
from applications.models import AdminLog, LogSchema
|
from applications.models import AdminLog
|
||||||
from applications.common.curd import model_to_dicts
|
|
||||||
|
|
||||||
admin_log = Blueprint('logs', __name__, url_prefix='/logs')
|
admin_log = Blueprint('logs', __name__, url_prefix='/logs')
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ def login_log():
|
|||||||
url='/passport/login').order_by(
|
url='/passport/login').order_by(
|
||||||
desc(AdminLog.create_time)).paginate(
|
desc(AdminLog.create_time)).paginate(
|
||||||
page=page, per_page=limit, error_out=False)
|
page=page, per_page=limit, error_out=False)
|
||||||
data = model_to_dicts(Schema=LogSchema, model=log_paginate.items)
|
data = marshal(log_paginate.items, log_fields)
|
||||||
|
|
||||||
return table_api(data=data, count=log_paginate.total)
|
return table_api(data=data, count=log_paginate.total)
|
||||||
|
|
||||||
@@ -34,10 +35,9 @@ def login_log():
|
|||||||
def operate_log():
|
def operate_log():
|
||||||
page = request.args.get('page', type=int)
|
page = request.args.get('page', type=int)
|
||||||
limit = request.args.get('limit', type=int)
|
limit = request.args.get('limit', type=int)
|
||||||
log = AdminLog.query.filter(
|
log_paginate = AdminLog.query.filter(
|
||||||
AdminLog.url != '/passport/login').order_by(
|
AdminLog.url != '/passport/login').order_by(
|
||||||
desc(AdminLog.create_time)).paginate(
|
desc(AdminLog.create_time)).paginate(
|
||||||
page=page, per_page=limit, error_out=False)
|
page=page, per_page=limit, error_out=False)
|
||||||
count = AdminLog.query.filter(AdminLog.url != '/admin/login').count()
|
data = marshal(log_paginate.items, log_fields)
|
||||||
data = model_to_dicts(Schema=LogSchema, model=log.items)
|
return table_api(data=data, count=log_paginate.total)
|
||||||
return table_api(data=data, count=count)
|
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
from flask import Blueprint, render_template, request, jsonify
|
from flask import Blueprint, render_template, jsonify, make_response
|
||||||
from marshmallow import INCLUDE
|
from flask_restful import marshal, Api, Resource, reqparse
|
||||||
|
|
||||||
|
from applications.common.serialization import dept_fields
|
||||||
from applications.common.utils.http import success_api, fail_api
|
from applications.common.utils.http import success_api, fail_api
|
||||||
from applications.common.utils.rights import authorize
|
from applications.common.utils.rights import authorize
|
||||||
from applications.common.utils.validate import check_data
|
from applications.extensions import db
|
||||||
from applications.models import DeptSchema
|
from applications.models import Dept, User
|
||||||
from applications.view.company.department import dept_curd as dept_curd
|
|
||||||
|
# from applications.view.company.department import dept_curd
|
||||||
|
|
||||||
dept_bp = Blueprint('dept', __name__, url_prefix='/dept')
|
dept_bp = Blueprint('dept', __name__, url_prefix='/dept')
|
||||||
|
dept_api = Api(dept_bp)
|
||||||
|
|
||||||
|
|
||||||
def register_dept_views(app):
|
def register_dept_views(app):
|
||||||
@@ -23,90 +26,118 @@ def main():
|
|||||||
@dept_bp.get('/data')
|
@dept_bp.get('/data')
|
||||||
@authorize("admin:dept:main", log=True)
|
@authorize("admin:dept:main", log=True)
|
||||||
def data():
|
def data():
|
||||||
power_data = dept_curd.get_dept_dict()
|
dept_data = Dept.query.order_by(Dept.sort).all()
|
||||||
|
|
||||||
res = {
|
res = {
|
||||||
"data": power_data
|
"data": marshal(dept_data, dept_fields)
|
||||||
}
|
}
|
||||||
return jsonify(res)
|
return jsonify(res)
|
||||||
|
|
||||||
|
|
||||||
@dept_bp.get('/add')
|
@dept_api.resource('/add')
|
||||||
@authorize("admin:dept:add", log=True)
|
class AddDepartment(Resource):
|
||||||
def add():
|
@authorize("admin:dept:add", log=True)
|
||||||
return render_template('admin/dept/add.html')
|
def get(self):
|
||||||
|
return make_response(render_template('admin/dept/add.html'))
|
||||||
|
|
||||||
|
@authorize("admin:dept:add", log=True)
|
||||||
|
def post(self):
|
||||||
|
parser = reqparse.RequestParser()
|
||||||
|
parser.add_argument('address', type=str)
|
||||||
|
parser.add_argument('deptName', type=str, dest='dept_name')
|
||||||
|
parser.add_argument('email', type=str)
|
||||||
|
parser.add_argument('leader', type=str)
|
||||||
|
parser.add_argument('parentId', type=int, dest='parent_id')
|
||||||
|
parser.add_argument('phone', type=str)
|
||||||
|
parser.add_argument('sort', type=int)
|
||||||
|
parser.add_argument('status', type=int)
|
||||||
|
|
||||||
|
res = parser.parse_args()
|
||||||
|
|
||||||
|
dept = Dept(
|
||||||
|
parent_id=res.parent_id,
|
||||||
|
dept_name=res.dept_name,
|
||||||
|
sort=res.sort,
|
||||||
|
leader=res.leader,
|
||||||
|
phone=res.phone,
|
||||||
|
email=res.email,
|
||||||
|
status=res.status,
|
||||||
|
address=res.address
|
||||||
|
)
|
||||||
|
db.session.add(dept)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
return success_api(msg="成功")
|
||||||
|
|
||||||
|
|
||||||
@dept_bp.get('/tree')
|
@dept_bp.get('/tree')
|
||||||
@authorize("admin:dept:main", log=True)
|
@authorize("admin:dept:main", log=True)
|
||||||
def tree():
|
def tree():
|
||||||
power_data = dept_curd.get_dept_dict()
|
dept_data = Dept.query.order_by(Dept.sort).all()
|
||||||
res = {
|
res = {
|
||||||
"status": {"code": 200, "message": "默认"},
|
"status": {"code": 200, "message": "默认"},
|
||||||
"data": power_data
|
"data": marshal(dept_data, dept_fields)
|
||||||
|
|
||||||
}
|
}
|
||||||
return jsonify(res)
|
return jsonify(res)
|
||||||
|
|
||||||
|
|
||||||
@dept_bp.post('/save')
|
|
||||||
@authorize("admin:dept:add", log=True)
|
|
||||||
def save():
|
|
||||||
req = request.json
|
|
||||||
check_data(DeptSchema(unknown=INCLUDE), req)
|
|
||||||
dept_curd.save_dept(req)
|
|
||||||
return success_api(msg="成功")
|
|
||||||
|
|
||||||
|
|
||||||
@dept_bp.get('/edit')
|
|
||||||
@authorize("admin:dept:edit", log=True)
|
|
||||||
def edit():
|
|
||||||
_id = request.args.get("deptId")
|
|
||||||
dept = dept_curd.get_dept_by_id(_id)
|
|
||||||
return render_template('admin/dept/edit.html', dept=dept)
|
|
||||||
|
|
||||||
|
|
||||||
# 启用
|
# 启用
|
||||||
@dept_bp.put('/enable')
|
@dept_bp.put('/enable')
|
||||||
@authorize("admin:dept:edit", log=True)
|
@authorize("admin:dept:edit", log=True)
|
||||||
def enable():
|
def enable():
|
||||||
_id = request.json.get('deptId')
|
parser = reqparse.RequestParser()
|
||||||
if id:
|
parser.add_argument('deptId', type=int, dest='dept_id', required=True)
|
||||||
res = dept_curd.enable_status(_id)
|
parser.add_argument('operate', type=int, choices=[0, 1], required=True)
|
||||||
|
|
||||||
|
res = parser.parse_args()
|
||||||
|
d = Dept.query.filter_by(id=res.dept_id).update({"status": res.operate})
|
||||||
|
if d:
|
||||||
|
db.session.commit()
|
||||||
|
message = '启用成功' if res.operate else '禁用成功'
|
||||||
|
return success_api(msg=message)
|
||||||
|
return fail_api(msg="出错啦")
|
||||||
|
|
||||||
|
|
||||||
|
@dept_api.resource('/edit/<int:dept_id>')
|
||||||
|
class DeptURD(Resource):
|
||||||
|
@authorize("admin:dept:edit", log=True)
|
||||||
|
def get(self, dept_id):
|
||||||
|
dept = Dept.query.filter_by(id=dept_id).first()
|
||||||
|
return make_response(render_template('admin/dept/edit.html', dept=dept))
|
||||||
|
|
||||||
|
@authorize("admin:dept:edit", log=True)
|
||||||
|
def put(self, dept_id):
|
||||||
|
parser = reqparse.RequestParser()
|
||||||
|
parser.add_argument('address', type=str)
|
||||||
|
parser.add_argument('deptName', type=str, dest='dept_name')
|
||||||
|
parser.add_argument('email', type=str)
|
||||||
|
parser.add_argument('leader', type=str)
|
||||||
|
parser.add_argument('phone', type=str)
|
||||||
|
parser.add_argument('sort', type=int)
|
||||||
|
parser.add_argument('status', type=int)
|
||||||
|
|
||||||
|
res = parser.parse_args()
|
||||||
|
data = {
|
||||||
|
"dept_name": res.dept_name,
|
||||||
|
"sort": res.sort,
|
||||||
|
"leader": res.leader,
|
||||||
|
"phone": res.phone,
|
||||||
|
"email": res.email,
|
||||||
|
"status": res.status,
|
||||||
|
"address": res.address
|
||||||
|
}
|
||||||
|
res = Dept.query.filter_by(id=dept_id).update(data)
|
||||||
if not res:
|
if not res:
|
||||||
return fail_api(msg="出错啦")
|
return fail_api(msg="更新失败")
|
||||||
return success_api(msg="启用成功")
|
db.session.commit()
|
||||||
return fail_api(msg="数据错误")
|
return success_api(msg="更新成功")
|
||||||
|
|
||||||
|
@authorize("admin:dept:remove", log=True)
|
||||||
# 禁用
|
def delete(self, dept_id):
|
||||||
@dept_bp.put('/disable')
|
ret = Dept.query.filter_by(id=dept_id).delete()
|
||||||
@authorize("admin:dept:edit", log=True)
|
User.query.filter_by(dept_id=dept_id).update({"dept_id": None})
|
||||||
def dis_enable():
|
db.session.commit()
|
||||||
_id = request.json.get('deptId')
|
if ret:
|
||||||
if id:
|
return success_api(msg="删除成功")
|
||||||
res = dept_curd.disable_status(_id)
|
|
||||||
if not res:
|
|
||||||
return fail_api(msg="出错啦")
|
|
||||||
return success_api(msg="禁用成功")
|
|
||||||
return fail_api(msg="数据错误")
|
|
||||||
|
|
||||||
|
|
||||||
@dept_bp.put('/update')
|
|
||||||
@authorize("admin:dept:edit", log=True)
|
|
||||||
def update():
|
|
||||||
req = request.json
|
|
||||||
check_data(DeptSchema(unknown=INCLUDE), req)
|
|
||||||
res = dept_curd.update_dept(req)
|
|
||||||
if not res:
|
|
||||||
return fail_api(msg="更新失败")
|
|
||||||
return success_api(msg="更新成功")
|
|
||||||
|
|
||||||
|
|
||||||
@dept_bp.delete('/remove/<int:_id>')
|
|
||||||
@authorize("admin:dept:remove", log=True)
|
|
||||||
def remove(_id):
|
|
||||||
res = dept_curd.remove_dept(_id)
|
|
||||||
if res:
|
|
||||||
return success_api(msg="删除成功")
|
|
||||||
else:
|
|
||||||
return fail_api(msg="删除失败")
|
return fail_api(msg="删除失败")
|
||||||
|
|||||||
@@ -1,88 +0,0 @@
|
|||||||
from applications.extensions import db
|
|
||||||
from applications.models import Dept, DeptSchema
|
|
||||||
from applications.models import User
|
|
||||||
from applications.common.curd import model_to_dicts
|
|
||||||
|
|
||||||
|
|
||||||
def get_dept_dict():
|
|
||||||
dept = Dept.query.order_by(Dept.sort).all()
|
|
||||||
res = model_to_dicts(Schema=DeptSchema, model=dept)
|
|
||||||
return res
|
|
||||||
|
|
||||||
|
|
||||||
def save_dept(req):
|
|
||||||
address = req.get("address")
|
|
||||||
deptName = req.get("deptName")
|
|
||||||
email = req.get("email")
|
|
||||||
leader = req.get("leader")
|
|
||||||
parentId = req.get("parentId")
|
|
||||||
phone = req.get("phone")
|
|
||||||
sort = req.get("sort")
|
|
||||||
status = req.get("status")
|
|
||||||
dept = Dept(
|
|
||||||
parent_id=parentId,
|
|
||||||
dept_name=deptName,
|
|
||||||
sort=sort,
|
|
||||||
leader=leader,
|
|
||||||
phone=phone,
|
|
||||||
email=email,
|
|
||||||
status=status,
|
|
||||||
address=address
|
|
||||||
)
|
|
||||||
r = db.session.add(dept)
|
|
||||||
db.session.commit()
|
|
||||||
return r
|
|
||||||
|
|
||||||
|
|
||||||
def get_dept_by_id(_id):
|
|
||||||
"""根据 id 获取部门"""
|
|
||||||
d = Dept.query.filter_by(id=_id).first()
|
|
||||||
return d
|
|
||||||
|
|
||||||
|
|
||||||
def enable_status(_id):
|
|
||||||
""" 启用权限 """
|
|
||||||
enable = 1
|
|
||||||
d = Dept.query.filter_by(id=_id).update({"status": enable})
|
|
||||||
if d:
|
|
||||||
db.session.commit()
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def disable_status(_id):
|
|
||||||
""" 停用权限 """
|
|
||||||
enable = 0
|
|
||||||
d = Dept.query.filter_by(id=_id).update({"status": enable})
|
|
||||||
if d:
|
|
||||||
db.session.commit()
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def update_dept(json):
|
|
||||||
""" 更新部门信息 """
|
|
||||||
_id = json.get("deptId"),
|
|
||||||
data = {
|
|
||||||
"dept_name": json.get("deptName"),
|
|
||||||
"sort": json.get("sort"),
|
|
||||||
"leader": json.get("leader"),
|
|
||||||
"phone": json.get("phone"),
|
|
||||||
"email": json.get("email"),
|
|
||||||
"status": json.get("status"),
|
|
||||||
"address": json.get("address")
|
|
||||||
}
|
|
||||||
d = Dept.query.filter_by(id=_id).update(data)
|
|
||||||
if not d:
|
|
||||||
return False
|
|
||||||
db.session.commit()
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def remove_dept(_id):
|
|
||||||
d = Dept.query.filter_by(id=_id).delete()
|
|
||||||
if not d:
|
|
||||||
return False
|
|
||||||
User.query.filter_by(dept_id=_id).update({"dept_id": None})
|
|
||||||
db.session.commit()
|
|
||||||
return True
|
|
||||||
@@ -7,7 +7,9 @@ from flask_restful import marshal
|
|||||||
|
|
||||||
from applications.common.serialization import power_fields
|
from applications.common.serialization import power_fields
|
||||||
from applications.extensions import db
|
from applications.extensions import db
|
||||||
from applications.models import PowerSchema, Power, Role, User
|
from applications.models import Power, Role, User
|
||||||
|
|
||||||
|
from applications.common.serialization import power2_fields
|
||||||
|
|
||||||
|
|
||||||
def get_render_config():
|
def get_render_config():
|
||||||
@@ -99,8 +101,7 @@ def make_menu_tree():
|
|||||||
if p.type == 0 or p.type == 1:
|
if p.type == 0 or p.type == 1:
|
||||||
powers.append(p)
|
powers.append(p)
|
||||||
|
|
||||||
power_schema = PowerSchema(many=True) # 用已继承 ma.ModelSchema 类的自定制类生成序列化类
|
power_dict = marshal(powers, power2_fields) # 生成可序列化对象
|
||||||
power_dict = power_schema.dump(powers) # 生成可序列化对象
|
|
||||||
power_dict.sort(key=lambda x: x['id'], reverse=True)
|
power_dict.sort(key=lambda x: x['id'], reverse=True)
|
||||||
|
|
||||||
menu_dict = OrderedDict()
|
menu_dict = OrderedDict()
|
||||||
@@ -115,7 +116,6 @@ def make_menu_tree():
|
|||||||
menu_dict[_dict['parent_id']] = [_dict]
|
menu_dict[_dict['parent_id']] = [_dict]
|
||||||
else:
|
else:
|
||||||
menu_dict[_dict['parent_id']].append(_dict)
|
menu_dict[_dict['parent_id']].append(_dict)
|
||||||
|
|
||||||
return menu_dict.get(0)
|
return menu_dict.get(0)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
from flask import Blueprint, render_template, request, jsonify, make_response
|
from flask import Blueprint, render_template, jsonify, make_response
|
||||||
from flask_login import login_required
|
from flask_login import login_required
|
||||||
|
|
||||||
from flask_restful import Resource, Api, reqparse
|
from flask_restful import Resource, Api, reqparse
|
||||||
|
|
||||||
from applications.extensions import db
|
from applications.extensions import db
|
||||||
from applications.models import Role, Power
|
from applications.models import Role, Power
|
||||||
# from applications.view.rights import role_curd
|
|
||||||
from applications.common.utils.http import table_api, success_api, fail_api
|
from applications.common.utils.http import table_api, success_api, fail_api
|
||||||
from applications.common.utils.rights import authorize
|
from applications.common.utils.rights import authorize
|
||||||
from flask_restful import reqparse, marshal
|
from flask_restful import reqparse, marshal
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
alembic==1.6.5
|
alembic==1.6.5
|
||||||
|
aniso8601==9.0.1
|
||||||
captcha==0.3
|
captcha==0.3
|
||||||
click==8.0.1
|
click==8.0.1
|
||||||
colorama==0.4.4
|
colorama==0.4.4
|
||||||
Flask==2.0.1
|
Flask==2.0.1
|
||||||
Flask-Login==0.5.0
|
Flask-Login==0.5.0
|
||||||
flask-marshmallow==0.14.0
|
|
||||||
Flask-Migrate==3.0.1
|
Flask-Migrate==3.0.1
|
||||||
|
Flask-RESTful==0.3.9
|
||||||
Flask-SQLAlchemy==2.5.1
|
Flask-SQLAlchemy==2.5.1
|
||||||
Flask-Uploads==0.2.1
|
Flask-Uploads==0.2.1
|
||||||
greenlet==1.1.0
|
greenlet==1.1.0
|
||||||
@@ -13,14 +14,13 @@ itsdangerous==2.0.1
|
|||||||
Jinja2==3.0.1
|
Jinja2==3.0.1
|
||||||
Mako==1.1.4
|
Mako==1.1.4
|
||||||
MarkupSafe==2.0.1
|
MarkupSafe==2.0.1
|
||||||
marshmallow==3.12.1
|
|
||||||
marshmallow-sqlalchemy==0.26.1
|
|
||||||
Pillow==8.2.0
|
Pillow==8.2.0
|
||||||
psutil==5.8.0
|
psutil==5.8.0
|
||||||
PyMySQL==1.0.2
|
PyMySQL==1.0.2
|
||||||
python-dateutil==2.8.1
|
python-dateutil==2.8.1
|
||||||
python-dotenv==0.18.0
|
python-dotenv==0.18.0
|
||||||
python-editor==1.0.4
|
python-editor==1.0.4
|
||||||
|
pytz==2021.1
|
||||||
six==1.16.0
|
six==1.16.0
|
||||||
SQLAlchemy==1.4.18
|
SQLAlchemy==1.4.18
|
||||||
Werkzeug==2.0.1
|
Werkzeug==2.0.1
|
||||||
|
|||||||
Reference in New Issue
Block a user