删除curd层
This commit is contained in:
@@ -1,88 +0,0 @@
|
|||||||
from applications.common.utils.validate import xss_escape
|
|
||||||
from applications.extensions import db
|
|
||||||
from applications.models import Dept
|
|
||||||
from applications.schemas import 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 = xss_escape(req.get("address"))
|
|
||||||
deptName = xss_escape(req.get("deptName"))
|
|
||||||
email = xss_escape(req.get("email"))
|
|
||||||
leader = xss_escape(req.get("leader"))
|
|
||||||
parentId = xss_escape(req.get("parentId"))
|
|
||||||
phone = xss_escape(req.get("phone"))
|
|
||||||
sort = xss_escape(req.get("sort"))
|
|
||||||
status = xss_escape(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):
|
|
||||||
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": xss_escape(json.get("deptName")),
|
|
||||||
"sort": xss_escape(json.get("sort")),
|
|
||||||
"leader": xss_escape(json.get("leader")),
|
|
||||||
"phone": xss_escape(json.get("phone")),
|
|
||||||
"email": xss_escape(json.get("email")),
|
|
||||||
"status": xss_escape(json.get("status")),
|
|
||||||
"address": xss_escape(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
|
|
||||||
@@ -1,146 +0,0 @@
|
|||||||
from applications.common.utils.validate import xss_escape
|
|
||||||
from applications.extensions import db
|
|
||||||
from applications.models import DictType, DictData
|
|
||||||
from applications.schemas import DictTypeSchema, DictDataSchema
|
|
||||||
from applications.common.curd import model_to_dicts
|
|
||||||
|
|
||||||
|
|
||||||
def get_dict(typecode: str):
|
|
||||||
dict_list = []
|
|
||||||
if DictType.query.filter_by(type_code=typecode, enable=1).first():
|
|
||||||
dicts = DictData.query.filter_by(type_code=typecode, enable=1).all()
|
|
||||||
for d in dicts:
|
|
||||||
dict_dict = {"key": d.data_label, "value": d.data_value}
|
|
||||||
dict_list.append(dict_dict)
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
return dict_list
|
|
||||||
|
|
||||||
|
|
||||||
def get_dict_type(page, limit, type_name):
|
|
||||||
dict_all = DictType.query
|
|
||||||
if type_name:
|
|
||||||
dict_all = dict_all.filter(DictType.type_name.like('%' + type_name + '%'))
|
|
||||||
dict_all = dict_all.paginate(page=page,
|
|
||||||
per_page=limit,
|
|
||||||
error_out=False)
|
|
||||||
count = DictType.query.count()
|
|
||||||
data = model_to_dicts(Schema=DictTypeSchema, model=dict_all.items)
|
|
||||||
return data, count
|
|
||||||
|
|
||||||
|
|
||||||
def get_dict_data(page, limit, type_code):
|
|
||||||
dict_all = DictData.query.filter_by(type_code=type_code).paginate(page=page,
|
|
||||||
per_page=limit,
|
|
||||||
error_out=False)
|
|
||||||
count = DictType.query.count()
|
|
||||||
dict_dict = model_to_dicts(Schema=DictDataSchema, model=dict_all.items)
|
|
||||||
return dict_dict, count
|
|
||||||
|
|
||||||
|
|
||||||
# 增加 dict type
|
|
||||||
def save_dict_type(req_json):
|
|
||||||
description = xss_escape(req_json.get("description"))
|
|
||||||
enable = xss_escape(req_json.get("enable"))
|
|
||||||
type_code = xss_escape(req_json.get("typeCode"))
|
|
||||||
type_name = xss_escape(req_json.get("typeName"))
|
|
||||||
d = DictType(type_name=type_name, type_code=type_code, enable=enable, description=description)
|
|
||||||
db.session.add(d)
|
|
||||||
db.session.commit()
|
|
||||||
return d.id
|
|
||||||
|
|
||||||
|
|
||||||
# 编辑字典类型
|
|
||||||
def update_dict_type(req_json):
|
|
||||||
id = xss_escape(req_json.get("id"))
|
|
||||||
description = xss_escape(req_json.get("description"))
|
|
||||||
enable = xss_escape(req_json.get("enable"))
|
|
||||||
type_code = xss_escape(req_json.get("typeCode"))
|
|
||||||
type_name = xss_escape(req_json.get("typeName"))
|
|
||||||
DictType.query.filter_by(id=id).update({
|
|
||||||
"description": description,
|
|
||||||
"enable": enable,
|
|
||||||
"type_code": type_code,
|
|
||||||
"type_name": type_name
|
|
||||||
})
|
|
||||||
db.session.commit()
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def enable_dict_type_status(id):
|
|
||||||
enable = 1
|
|
||||||
res = DictType.query.filter_by(id=id).update({"enable": enable})
|
|
||||||
if res:
|
|
||||||
db.session.commit()
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def disable_dict_type_status(id):
|
|
||||||
enable = 0
|
|
||||||
res = DictType.query.filter_by(id=id).update({"enable": enable})
|
|
||||||
if res:
|
|
||||||
db.session.commit()
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
# 删除字典类型
|
|
||||||
def delete_type_by_id(id):
|
|
||||||
type_code = DictType.query.filter_by(id=id).first().type_code
|
|
||||||
DictData.query.filter_by(type_code=type_code).delete()
|
|
||||||
res = DictType.query.filter_by(id=id).delete()
|
|
||||||
db.session.commit()
|
|
||||||
return res
|
|
||||||
|
|
||||||
|
|
||||||
# 增加dictdata
|
|
||||||
def save_dict_data(req_json):
|
|
||||||
data_label = xss_escape(req_json.get("dataLabel"))
|
|
||||||
data_value = xss_escape(req_json.get("dataValue"))
|
|
||||||
enable = xss_escape(req_json.get("enable"))
|
|
||||||
remark = xss_escape(req_json.get("remark"))
|
|
||||||
type_code = xss_escape(req_json.get("typeCode"))
|
|
||||||
d = DictData(data_label=data_label, data_value=data_value, enable=enable, remark=remark, type_code=type_code)
|
|
||||||
db.session.add(d)
|
|
||||||
db.session.commit()
|
|
||||||
return d.id
|
|
||||||
|
|
||||||
|
|
||||||
# 编辑字典数据
|
|
||||||
def update_dict_data(req_json):
|
|
||||||
id = req_json.get("dataId")
|
|
||||||
DictData.query.filter_by(id=id).update({
|
|
||||||
"data_label": xss_escape(req_json.get("dataLabel")),
|
|
||||||
"data_value": xss_escape(req_json.get("dataValue")),
|
|
||||||
"enable": xss_escape(req_json.get("enable")),
|
|
||||||
"remark": xss_escape(req_json.get("remark")),
|
|
||||||
"type_code": xss_escape(req_json.get("typeCode"))
|
|
||||||
})
|
|
||||||
db.session.commit()
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def enable_dict_data_status(id):
|
|
||||||
enable = 1
|
|
||||||
res = DictData.query.filter_by(id=id).update({"enable": enable})
|
|
||||||
if res:
|
|
||||||
db.session.commit()
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def disable_dict_data_status(id):
|
|
||||||
enable = 0
|
|
||||||
res = DictData.query.filter_by(id=id).update({"enable": enable})
|
|
||||||
if res:
|
|
||||||
db.session.commit()
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
# 删除dictdata
|
|
||||||
def delete_data_by_id(id):
|
|
||||||
res = DictData.query.filter_by(id=id).delete()
|
|
||||||
db.session.commit()
|
|
||||||
return res
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
import os
|
|
||||||
from flask import current_app
|
|
||||||
from sqlalchemy import desc
|
|
||||||
|
|
||||||
from applications.common.utils.upload import photos
|
|
||||||
from applications.extensions import db
|
|
||||||
from applications.models import Photo
|
|
||||||
from applications.schemas import PhotoSchema
|
|
||||||
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):
|
|
||||||
filename = photos.save(photo)
|
|
||||||
file_url = photos.url(filename)
|
|
||||||
|
|
||||||
upload_url = current_app.config.get("UPLOADED_PHOTOS_DEST")
|
|
||||||
size = os.path.getsize(upload_url + '/' + filename)
|
|
||||||
photo = Photo(name=filename, href=file_url, mime=mime, size=size)
|
|
||||||
db.session.add(photo)
|
|
||||||
db.session.commit()
|
|
||||||
return file_url
|
|
||||||
|
|
||||||
|
|
||||||
def delete_photo_by_id(_id):
|
|
||||||
photo_name = Photo.query.filter_by(id=_id).first().name
|
|
||||||
photo = Photo.query.filter_by(id=_id).delete()
|
|
||||||
db.session.commit()
|
|
||||||
upload_url = current_app.config.get("UPLOADED_PHOTOS_DEST")
|
|
||||||
os.remove(upload_url + '/' + photo_name)
|
|
||||||
return photo
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
from applications.common.utils.validate import xss_escape
|
|
||||||
from applications.extensions import db
|
|
||||||
from applications.models.admin_power import Power
|
|
||||||
from applications.schemas import PowerSchema2
|
|
||||||
from applications.models import Role
|
|
||||||
from applications.common.curd import model_to_dicts
|
|
||||||
|
|
||||||
|
|
||||||
def get_power_dict():
|
|
||||||
power = Power.query.all()
|
|
||||||
res = model_to_dicts(Schema=PowerSchema2, model=power)
|
|
||||||
return res
|
|
||||||
|
|
||||||
|
|
||||||
# 选择父节点
|
|
||||||
def select_parent():
|
|
||||||
power = Power.query.all()
|
|
||||||
res = model_to_dicts(Schema=PowerSchema2, model=power)
|
|
||||||
res.append({"powerId": 0, "powerName": "顶级权限", "parentId": -1})
|
|
||||||
return res
|
|
||||||
|
|
||||||
|
|
||||||
# 增加权限
|
|
||||||
def save_power(req):
|
|
||||||
icon = xss_escape(req.get("icon"))
|
|
||||||
openType = xss_escape(req.get("openType"))
|
|
||||||
parentId = xss_escape(req.get("parentId"))
|
|
||||||
powerCode = xss_escape(req.get("powerCode"))
|
|
||||||
powerName = xss_escape(req.get("powerName"))
|
|
||||||
powerType = xss_escape(req.get("powerType"))
|
|
||||||
powerUrl = xss_escape(req.get("powerUrl"))
|
|
||||||
sort = xss_escape(req.get("sort"))
|
|
||||||
power = Power(
|
|
||||||
icon=icon,
|
|
||||||
open_type=openType,
|
|
||||||
parent_id=parentId,
|
|
||||||
code=powerCode,
|
|
||||||
name=powerName,
|
|
||||||
type=powerType,
|
|
||||||
url=powerUrl,
|
|
||||||
sort=sort,
|
|
||||||
enable=1
|
|
||||||
)
|
|
||||||
r = db.session.add(power)
|
|
||||||
db.session.commit()
|
|
||||||
return r
|
|
||||||
|
|
||||||
|
|
||||||
# 根据id查询权限
|
|
||||||
def get_power_by_id(id):
|
|
||||||
p = Power.query.filter_by(id=id).first()
|
|
||||||
return p
|
|
||||||
|
|
||||||
|
|
||||||
# 更新权限
|
|
||||||
def update_power(req_json):
|
|
||||||
id = req_json.get("powerId")
|
|
||||||
data = {
|
|
||||||
"icon": xss_escape(req_json.get("icon")),
|
|
||||||
"open_type": xss_escape(req_json.get("openType")),
|
|
||||||
"parent_id": xss_escape(req_json.get("parentId")),
|
|
||||||
"code": xss_escape(req_json.get("powerCode")),
|
|
||||||
"name": xss_escape(req_json.get("powerName")),
|
|
||||||
"type": xss_escape(req_json.get("powerType")),
|
|
||||||
"url": xss_escape(req_json.get("powerUrl")),
|
|
||||||
"sort": xss_escape(req_json.get("sort"))
|
|
||||||
}
|
|
||||||
# print(data)
|
|
||||||
power = Power.query.filter_by(id=id).update(data)
|
|
||||||
db.session.commit()
|
|
||||||
# print(power)
|
|
||||||
return power
|
|
||||||
|
|
||||||
|
|
||||||
# 启动权限
|
|
||||||
def enable_status(id):
|
|
||||||
enable = 1
|
|
||||||
user = Power.query.filter_by(id=id).update({"enable": enable})
|
|
||||||
if user:
|
|
||||||
db.session.commit()
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
# 停用权限
|
|
||||||
def disable_status(id):
|
|
||||||
enable = 0
|
|
||||||
user = Power.query.filter_by(id=id).update({"enable": enable})
|
|
||||||
if user:
|
|
||||||
db.session.commit()
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
# 删除权限(目前没有判断父节点自动删除子节点)
|
|
||||||
def remove_power(id):
|
|
||||||
power = Power.query.filter_by(id=id).first()
|
|
||||||
role_id_list = []
|
|
||||||
roles = power.role
|
|
||||||
for role in roles:
|
|
||||||
role_id_list.append(role.id)
|
|
||||||
roles = Role.query.filter(Role.id.in_(role_id_list)).all()
|
|
||||||
for p in roles:
|
|
||||||
power.role.remove(p)
|
|
||||||
r = Power.query.filter_by(id=id).delete()
|
|
||||||
db.session.commit()
|
|
||||||
return r
|
|
||||||
|
|
||||||
|
|
||||||
# 批量删除权限
|
|
||||||
def batch_remove(ids):
|
|
||||||
for id in ids:
|
|
||||||
remove_power(id)
|
|
||||||
@@ -1,10 +1,15 @@
|
|||||||
from applications.extensions import db
|
from applications.extensions import db, ma
|
||||||
|
|
||||||
|
|
||||||
def model_to_dicts(Schema, model):
|
def model_to_dicts(schema: ma.Schema, data):
|
||||||
|
"""
|
||||||
|
:param schema: schema类
|
||||||
|
:param model: sqlalchemy查询结果
|
||||||
|
:return: 返回单个查询结果
|
||||||
|
"""
|
||||||
# 如果是分页器返回,需要传入model.items
|
# 如果是分页器返回,需要传入model.items
|
||||||
common_schema = Schema(many=True) # 用已继承ma.ModelSchema类的自定制类生成序列化类
|
common_schema = schema(many=True) # 用已继承ma.ModelSchema类的自定制类生成序列化类
|
||||||
output = common_schema.dump(model) # 生成可序列化对象
|
output = common_schema.dump(data) # 生成可序列化对象
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
#
|
|
||||||
MYSQL_HOST = '127.0.0.1'
|
|
||||||
MYSQL_PORT = '3306'
|
|
||||||
MYSQL_DATABASE = 'PearAdminFlask'
|
|
||||||
MYSQL_USERNAME = 'root'
|
|
||||||
MYSQL_PASSWORD = 'root'
|
|
||||||
|
|
||||||
MYSQL_DB_URI = "mysql+pymysql://{username}:{password}@{host}:{port}/{db}?charset=utf8".format(username=USERNAME,
|
|
||||||
password=PASSWORD,
|
|
||||||
host=HOST,
|
|
||||||
port=PORT,
|
|
||||||
db=DATABASE)
|
|
||||||
|
|
||||||
SQLALCHEMY_DATABASE_URI = MYSQL_DB_URI
|
|
||||||
SQLALCHEMY_TRACK_MODIFICATIONS = True
|
|
||||||
SQLALCHEMY_ECHO = False
|
|
||||||
SQLALCHEMY_POOL_RECYCLE = 8
|
|
||||||
@@ -2,3 +2,39 @@ from flask_uploads import UploadSet, IMAGES
|
|||||||
|
|
||||||
|
|
||||||
photos = UploadSet('photos', IMAGES)
|
photos = UploadSet('photos', IMAGES)
|
||||||
|
|
||||||
|
import os
|
||||||
|
from flask import current_app
|
||||||
|
from sqlalchemy import desc
|
||||||
|
from applications.extensions import db
|
||||||
|
from applications.models import Photo
|
||||||
|
from applications.schemas import PhotoSchema
|
||||||
|
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, data=photo.items)
|
||||||
|
return data, count
|
||||||
|
|
||||||
|
|
||||||
|
def upload_one(photo, mime):
|
||||||
|
filename = photos.save(photo)
|
||||||
|
file_url = photos.url(filename)
|
||||||
|
|
||||||
|
upload_url = current_app.config.get("UPLOADED_PHOTOS_DEST")
|
||||||
|
size = os.path.getsize(upload_url + '/' + filename)
|
||||||
|
photo = Photo(name=filename, href=file_url, mime=mime, size=size)
|
||||||
|
db.session.add(photo)
|
||||||
|
db.session.commit()
|
||||||
|
return file_url
|
||||||
|
|
||||||
|
|
||||||
|
def delete_photo_by_id(_id):
|
||||||
|
photo_name = Photo.query.filter_by(id=_id).first().name
|
||||||
|
photo = Photo.query.filter_by(id=_id).delete()
|
||||||
|
db.session.commit()
|
||||||
|
upload_url = current_app.config.get("UPLOADED_PHOTOS_DEST")
|
||||||
|
os.remove(upload_url + '/' + photo_name)
|
||||||
|
return photo
|
||||||
|
|||||||
@@ -9,46 +9,32 @@ from applications.common.curd import model_to_dicts
|
|||||||
admin_log = Blueprint('adminLog', __name__, url_prefix='/admin/log')
|
admin_log = Blueprint('adminLog', __name__, url_prefix='/admin/log')
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------
|
# 日志管理
|
||||||
# ------------------------- 日志管理 --------------------------
|
|
||||||
# ----------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
@admin_log.get('/')
|
@admin_log.get('/')
|
||||||
@authorize("admin:log:main")
|
@authorize("admin:log:main")
|
||||||
def index():
|
def index():
|
||||||
return render_template('admin/admin_log/main.html')
|
return render_template('admin/admin_log/main.html')
|
||||||
|
|
||||||
|
|
||||||
# ==========================================================
|
|
||||||
# 登录日志
|
# 登录日志
|
||||||
# ==========================================================
|
|
||||||
|
|
||||||
|
|
||||||
@admin_log.get('/loginLog')
|
@admin_log.get('/loginLog')
|
||||||
@authorize("admin:log:main")
|
@authorize("admin:log:main")
|
||||||
def login_log():
|
def login_log():
|
||||||
log = AdminLog.query.filter_by(url='/admin/login').order_by(desc(AdminLog.create_time)).layui_paginate()
|
# orm查询
|
||||||
count = AdminLog.query.filter_by(url='/admin/login').count()
|
# 使用分页获取data需要.items
|
||||||
data = model_to_dicts(Schema=LogSchema, model=log.items)
|
log = AdminLog.query.filter_by(url='/passport/login').order_by(desc(AdminLog.create_time)).layui_paginate()
|
||||||
|
count = AdminLog.query.filter_by(url='/passport/login').count()
|
||||||
return table_api(data=data, count=count)
|
return table_api(data= model_to_dicts(schema=LogSchema, data=log.items), count=count)
|
||||||
|
|
||||||
|
|
||||||
# ==========================================================
|
|
||||||
# 操作日志
|
# 操作日志
|
||||||
# ==========================================================
|
|
||||||
|
|
||||||
|
|
||||||
@admin_log.get('/operateLog')
|
@admin_log.get('/operateLog')
|
||||||
@authorize("admin:log:main")
|
@authorize("admin:log:main")
|
||||||
def operate_log():
|
def operate_log():
|
||||||
page = request.args.get('page', type=int)
|
# orm查询
|
||||||
limit = request.args.get('limit', type=int)
|
# 使用分页获取data需要.items
|
||||||
log = AdminLog.query.filter(
|
log = AdminLog.query.filter(
|
||||||
AdminLog.url != '/admin/login').order_by(
|
AdminLog.url != '/passport/login').order_by(
|
||||||
desc(AdminLog.create_time)).paginate(
|
desc(AdminLog.create_time)).layui_paginate()
|
||||||
page=page, per_page=limit, error_out=False)
|
count = AdminLog.query.filter(AdminLog.url != '/passport/login').count()
|
||||||
count = AdminLog.query.filter(AdminLog.url != '/admin/login').count()
|
return table_api(data=model_to_dicts(schema=LogSchema, data=log.items), count=count)
|
||||||
data = model_to_dicts(Schema=LogSchema, model=log.items)
|
|
||||||
return table_api(data=data, count=count)
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
from flask import Blueprint, render_template, request, jsonify
|
from flask import Blueprint, render_template, request, jsonify
|
||||||
|
|
||||||
from applications.common import curd
|
from applications.common import curd
|
||||||
|
from applications.common.helper import ModelFilter
|
||||||
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 applications.common.utils.validate import xss_escape
|
from applications.common.utils.validate import xss_escape
|
||||||
from applications.extensions import db
|
from applications.extensions import db
|
||||||
from applications.models import DictType, DictData
|
from applications.models import DictType, DictData
|
||||||
from applications.common.admin import dict_curd
|
|
||||||
from applications.schemas import DictTypeSchema, DictDataSchema
|
from applications.schemas import DictTypeSchema, DictDataSchema
|
||||||
|
|
||||||
admin_dict = Blueprint('adminDict', __name__, url_prefix='/admin/dict')
|
admin_dict = Blueprint('adminDict', __name__, url_prefix='/admin/dict')
|
||||||
@@ -22,13 +22,17 @@ def main():
|
|||||||
@admin_dict.get('/dictType/data')
|
@admin_dict.get('/dictType/data')
|
||||||
@authorize("admin:dict:main", log=True)
|
@authorize("admin:dict:main", log=True)
|
||||||
def dict_type_data():
|
def dict_type_data():
|
||||||
|
# 获取请求参数
|
||||||
type_name = xss_escape(request.args.get('typeName', type=str))
|
type_name = xss_escape(request.args.get('typeName', type=str))
|
||||||
dict_all = DictType.query
|
# 查询参数构造
|
||||||
|
mf = ModelFilter()
|
||||||
if type_name:
|
if type_name:
|
||||||
dict_all = dict_all.filter(DictType.type_name.like('%' + type_name + '%'))
|
mf.vague(field_name="type_name", value=type_name)
|
||||||
dict_all = dict_all.layui_paginate()
|
# orm查询
|
||||||
|
# 使用分页获取data需要.items
|
||||||
|
dict_all = DictType.query.filter(mf.get_filter(DictType)).layui_paginate()
|
||||||
count = DictType.query.count()
|
count = DictType.query.count()
|
||||||
data = curd.model_to_dicts(Schema=DictTypeSchema, model=dict_all.items)
|
data = curd.model_to_dicts(schema=DictTypeSchema, data=dict_all.items)
|
||||||
return table_api(data=data, count=count)
|
return table_api(data=data, count=count)
|
||||||
|
|
||||||
|
|
||||||
@@ -78,7 +82,7 @@ def dict_type_update():
|
|||||||
def dict_type_enable():
|
def dict_type_enable():
|
||||||
_id = request.json.get('id')
|
_id = request.json.get('id')
|
||||||
if id:
|
if id:
|
||||||
res = dict_curd.enable_dict_type_status(_id)
|
res = curd.enable_status(DictType,_id)
|
||||||
if not res:
|
if not res:
|
||||||
return fail_api(msg="出错啦")
|
return fail_api(msg="出错啦")
|
||||||
return success_api("启动成功")
|
return success_api("启动成功")
|
||||||
@@ -91,7 +95,7 @@ def dict_type_enable():
|
|||||||
def dict_type_dis_enable():
|
def dict_type_dis_enable():
|
||||||
_id = request.json.get('id')
|
_id = request.json.get('id')
|
||||||
if id:
|
if id:
|
||||||
res = dict_curd.disable_dict_type_status(_id)
|
res = curd.disable_status(DictType,_id)
|
||||||
if not res:
|
if not res:
|
||||||
return fail_api(msg="出错啦")
|
return fail_api(msg="出错啦")
|
||||||
return success_api("禁用成功")
|
return success_api("禁用成功")
|
||||||
@@ -102,7 +106,7 @@ def dict_type_dis_enable():
|
|||||||
@admin_dict.delete('/dictType/remove/<int:_id>')
|
@admin_dict.delete('/dictType/remove/<int:_id>')
|
||||||
@authorize("admin:dict:remove", log=True)
|
@authorize("admin:dict:remove", log=True)
|
||||||
def dict_type_delete(_id):
|
def dict_type_delete(_id):
|
||||||
res = dict_curd.delete_type_by_id(_id)
|
res = curd.delete_one_by_id(DictType,_id)
|
||||||
if not res:
|
if not res:
|
||||||
return fail_api(msg="删除失败")
|
return fail_api(msg="删除失败")
|
||||||
return success_api(msg="删除成功")
|
return success_api(msg="删除成功")
|
||||||
@@ -114,7 +118,7 @@ def dict_code_data():
|
|||||||
type_code = xss_escape(request.args.get('typeCode', type=str))
|
type_code = xss_escape(request.args.get('typeCode', type=str))
|
||||||
dict_data = DictData.query.filter_by(type_code=type_code).layui_paginate()
|
dict_data = DictData.query.filter_by(type_code=type_code).layui_paginate()
|
||||||
count = DictType.query.count()
|
count = DictType.query.count()
|
||||||
data = curd.model_to_dicts(Schema=DictDataSchema, model=dict_data.items)
|
data = curd.model_to_dicts(schema=DictDataSchema, data=dict_data.items)
|
||||||
return table_api(data=data, count=count)
|
return table_api(data=data, count=count)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ 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.common.admin import file_curd
|
from applications.common.utils import upload as upload_curd
|
||||||
|
|
||||||
admin_file = Blueprint('adminFile', __name__, url_prefix='/admin/file')
|
admin_file = Blueprint('adminFile', __name__, url_prefix='/admin/file')
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ 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)
|
data, count = upload_curd.get_photo(page=page, limit=limit)
|
||||||
return table_api(data=data, count=count)
|
return table_api(data=data, count=count)
|
||||||
|
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ def upload_api():
|
|||||||
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_curd.upload_one(photo=photo, mime=mime)
|
||||||
res = {
|
res = {
|
||||||
"msg": "上传成功",
|
"msg": "上传成功",
|
||||||
"code": 0,
|
"code": 0,
|
||||||
@@ -58,7 +58,7 @@ def upload_api():
|
|||||||
@authorize("admin:file:delete", log=True)
|
@authorize("admin:file:delete", log=True)
|
||||||
def delete():
|
def delete():
|
||||||
_id = request.form.get('id')
|
_id = request.form.get('id')
|
||||||
res = file_curd.delete_photo_by_id(_id)
|
res = upload_curd.delete_photo_by_id(_id)
|
||||||
if res:
|
if res:
|
||||||
return success_api(msg="删除成功")
|
return success_api(msg="删除成功")
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
from flask import Blueprint, render_template, request, jsonify
|
from flask import Blueprint, render_template, request, jsonify
|
||||||
|
|
||||||
from applications.common import curd
|
from applications.common import curd
|
||||||
from applications.common.admin import power_curd
|
|
||||||
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 xss_escape
|
from applications.common.utils.validate import xss_escape
|
||||||
from applications.extensions import db
|
from applications.extensions import db
|
||||||
from applications.models import Power
|
from applications.models import Power, Role
|
||||||
from applications.schemas import PowerSchema2
|
from applications.schemas import PowerSchema2
|
||||||
|
|
||||||
admin_power = Blueprint('adminPower', __name__, url_prefix='/admin/power')
|
admin_power = Blueprint('adminPower', __name__, url_prefix='/admin/power')
|
||||||
@@ -22,9 +21,8 @@ def index():
|
|||||||
@authorize("admin:power:main", log=True)
|
@authorize("admin:power:main", log=True)
|
||||||
def data():
|
def data():
|
||||||
power = Power.query.all()
|
power = Power.query.all()
|
||||||
res = curd.model_to_dicts(Schema=PowerSchema2, model=power)
|
|
||||||
res = {
|
res = {
|
||||||
"data": res
|
"data": curd.model_to_dicts(schema=PowerSchema2, data=power)
|
||||||
}
|
}
|
||||||
return jsonify(res)
|
return jsonify(res)
|
||||||
|
|
||||||
@@ -39,7 +37,7 @@ def add():
|
|||||||
@authorize("admin:power:main", log=True)
|
@authorize("admin:power:main", log=True)
|
||||||
def select_parent():
|
def select_parent():
|
||||||
power = Power.query.all()
|
power = Power.query.all()
|
||||||
res = curd.model_to_dicts(Schema=PowerSchema2, model=power)
|
res = curd.model_to_dicts(schema=PowerSchema2, data=power)
|
||||||
res.append({"powerId": 0, "powerName": "顶级权限", "parentId": -1})
|
res.append({"powerId": 0, "powerName": "顶级权限", "parentId": -1})
|
||||||
res = {
|
res = {
|
||||||
"status": {"code": 200, "message": "默认"},
|
"status": {"code": 200, "message": "默认"},
|
||||||
@@ -141,10 +139,19 @@ def dis_enable():
|
|||||||
|
|
||||||
|
|
||||||
# 权限删除
|
# 权限删除
|
||||||
@admin_power.delete('/remove/<int:_id>')
|
@admin_power.delete('/remove/<int:id>')
|
||||||
@authorize("admin:power:remove", log=True)
|
@authorize("admin:power:remove", log=True)
|
||||||
def remove(_id):
|
def remove(id):
|
||||||
r = power_curd.remove_power(_id)
|
power = Power.query.filter_by(id=id).first()
|
||||||
|
role_id_list = []
|
||||||
|
roles = power.role
|
||||||
|
for role in roles:
|
||||||
|
role_id_list.append(role.id)
|
||||||
|
roles = Role.query.filter(Role.id.in_(role_id_list)).all()
|
||||||
|
for p in roles:
|
||||||
|
power.role.remove(p)
|
||||||
|
r = Power.query.filter_by(id=id).delete()
|
||||||
|
db.session.commit()
|
||||||
if r:
|
if r:
|
||||||
return success_api(msg="删除成功")
|
return success_api(msg="删除成功")
|
||||||
else:
|
else:
|
||||||
@@ -156,5 +163,15 @@ def remove(_id):
|
|||||||
@authorize("admin:power:remove", log=True)
|
@authorize("admin:power:remove", log=True)
|
||||||
def batch_remove():
|
def batch_remove():
|
||||||
ids = request.form.getlist('ids[]')
|
ids = request.form.getlist('ids[]')
|
||||||
power_curd.batch_remove(ids)
|
for id in ids:
|
||||||
|
power = Power.query.filter_by(id=id).first()
|
||||||
|
role_id_list = []
|
||||||
|
roles = power.role
|
||||||
|
for role in roles:
|
||||||
|
role_id_list.append(role.id)
|
||||||
|
roles = Role.query.filter(Role.id.in_(role_id_list)).all()
|
||||||
|
for p in roles:
|
||||||
|
power.role.remove(p)
|
||||||
|
r = Power.query.filter_by(id=id).delete()
|
||||||
|
db.session.commit()
|
||||||
return success_api(msg="批量删除成功")
|
return success_api(msg="批量删除成功")
|
||||||
|
|||||||
@@ -23,17 +23,21 @@ def main():
|
|||||||
@admin_role.get('/data')
|
@admin_role.get('/data')
|
||||||
@authorize("admin:role:main", log=True)
|
@authorize("admin:role:main", log=True)
|
||||||
def table():
|
def table():
|
||||||
|
# 获取请求参数
|
||||||
role_name = xss_escape(request.args.get('roleName', type=str))
|
role_name = xss_escape(request.args.get('roleName', type=str))
|
||||||
role_code = xss_escape(request.args.get('roleCode', type=str))
|
role_code = xss_escape(request.args.get('roleCode', type=str))
|
||||||
|
# 查询参数构造
|
||||||
mf = ModelFilter()
|
mf = ModelFilter()
|
||||||
if role_name:
|
if role_name:
|
||||||
mf.vague(field_name="name", value=role_name)
|
mf.vague(field_name="name", value=role_name)
|
||||||
if role_code:
|
if role_code:
|
||||||
mf.vague(field_name="code", value=role_code)
|
mf.vague(field_name="code", value=role_code)
|
||||||
|
# orm查询
|
||||||
|
# 使用分页获取data需要.items
|
||||||
role = Role.query.filter(mf.get_filter(Role)).layui_paginate()
|
role = Role.query.filter(mf.get_filter(Role)).layui_paginate()
|
||||||
count = Role.query.count()
|
count = Role.query.count()
|
||||||
data = model_to_dicts(Schema=RoleSchema, model=role.items)
|
# 返回api
|
||||||
return table_api(data=data, count=count)
|
return table_api(data=model_to_dicts(schema=RoleSchema, data=role.items), count=count)
|
||||||
|
|
||||||
|
|
||||||
# 角色增加
|
# 角色增加
|
||||||
|
|||||||
@@ -27,9 +27,11 @@ def main():
|
|||||||
@admin_user.get('/data')
|
@admin_user.get('/data')
|
||||||
@authorize("admin:user:main", log=True)
|
@authorize("admin:user:main", log=True)
|
||||||
def data():
|
def data():
|
||||||
|
# 获取请求参数
|
||||||
real_name = xss_escape(request.args.get('realName', type=str))
|
real_name = xss_escape(request.args.get('realName', type=str))
|
||||||
username = xss_escape(request.args.get('username', type=str))
|
username = xss_escape(request.args.get('username', type=str))
|
||||||
dept_id = request.args.get('deptId', type=int)
|
dept_id = request.args.get('deptId', type=int)
|
||||||
|
# 查询参数构造
|
||||||
mf = ModelFilter()
|
mf = ModelFilter()
|
||||||
if real_name:
|
if real_name:
|
||||||
mf.vague(field_name="name", value=real_name)
|
mf.vague(field_name="name", value=real_name)
|
||||||
@@ -37,10 +39,12 @@ def data():
|
|||||||
mf.vague(field_name="username", value=username)
|
mf.vague(field_name="username", value=username)
|
||||||
if dept_id:
|
if dept_id:
|
||||||
mf.exact(field_name="dept_id", value=dept_id)
|
mf.exact(field_name="dept_id", value=dept_id)
|
||||||
|
# orm查询
|
||||||
|
# 使用分页获取data需要.items
|
||||||
user = User.query.filter(mf.get_filter(model=User)).layui_paginate()
|
user = User.query.filter(mf.get_filter(model=User)).layui_paginate()
|
||||||
count = User.query.count()
|
count = User.query.count()
|
||||||
data = model_to_dicts(Schema=UserSchema, model=user.items)
|
# 返回api
|
||||||
return table_api(data=data, count=count)
|
return table_api(data=model_to_dicts(schema=UserSchema, data=user.items), count=count)
|
||||||
|
|
||||||
|
|
||||||
# 用户增加
|
# 用户增加
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
from flask import Blueprint, render_template, request, jsonify
|
from flask import Blueprint, render_template, request, jsonify
|
||||||
from marshmallow import INCLUDE
|
from marshmallow import INCLUDE
|
||||||
|
|
||||||
|
from applications.common import curd
|
||||||
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.common.utils import validate
|
||||||
|
from applications.extensions import db
|
||||||
|
from applications.models import Dept, User
|
||||||
from applications.schemas import DeptSchema
|
from applications.schemas import DeptSchema
|
||||||
from applications.common.admin import dept_curd as dept_curd
|
|
||||||
|
|
||||||
dept_bp = Blueprint('dept', __name__, url_prefix='/dept')
|
dept_bp = Blueprint('dept', __name__, url_prefix='/dept')
|
||||||
|
|
||||||
@@ -23,7 +25,8 @@ 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 = Dept.query.order_by(Dept.sort).all()
|
||||||
|
power_data = curd.model_to_dicts(schema=DeptSchema, data=dept)
|
||||||
res = {
|
res = {
|
||||||
"data": power_data
|
"data": power_data
|
||||||
}
|
}
|
||||||
@@ -39,7 +42,8 @@ def add():
|
|||||||
@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 = Dept.query.order_by(Dept.sort).all()
|
||||||
|
power_data = curd.model_to_dicts(schema=DeptSchema, data=dept)
|
||||||
res = {
|
res = {
|
||||||
"status": {"code": 200, "message": "默认"},
|
"status": {"code": 200, "message": "默认"},
|
||||||
"data": power_data
|
"data": power_data
|
||||||
@@ -52,8 +56,27 @@ def tree():
|
|||||||
@authorize("admin:dept:add", log=True)
|
@authorize("admin:dept:add", log=True)
|
||||||
def save():
|
def save():
|
||||||
req = request.json
|
req = request.json
|
||||||
check_data(DeptSchema(unknown=INCLUDE), req)
|
validate.check_data(DeptSchema(unknown=INCLUDE), req)
|
||||||
dept_curd.save_dept(req)
|
address = validate.xss_escape(req.get("address"))
|
||||||
|
deptName = validate.xss_escape(req.get("deptName"))
|
||||||
|
email = validate.xss_escape(req.get("email"))
|
||||||
|
leader = validate.xss_escape(req.get("leader"))
|
||||||
|
parentId = validate.xss_escape(req.get("parentId"))
|
||||||
|
phone = validate.xss_escape(req.get("phone"))
|
||||||
|
sort = validate.xss_escape(req.get("sort"))
|
||||||
|
status = validate.xss_escape(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 success_api(msg="成功")
|
return success_api(msg="成功")
|
||||||
|
|
||||||
|
|
||||||
@@ -61,7 +84,7 @@ def save():
|
|||||||
@authorize("admin:dept:edit", log=True)
|
@authorize("admin:dept:edit", log=True)
|
||||||
def edit():
|
def edit():
|
||||||
_id = request.args.get("deptId")
|
_id = request.args.get("deptId")
|
||||||
dept = dept_curd.get_dept_by_id(_id)
|
dept = curd.get_one_by_id(model=Dept,id=_id)
|
||||||
return render_template('admin/dept/edit.html', dept=dept)
|
return render_template('admin/dept/edit.html', dept=dept)
|
||||||
|
|
||||||
|
|
||||||
@@ -71,10 +94,12 @@ def edit():
|
|||||||
def enable():
|
def enable():
|
||||||
_id = request.json.get('deptId')
|
_id = request.json.get('deptId')
|
||||||
if id:
|
if id:
|
||||||
res = dept_curd.enable_status(_id)
|
enable = 1
|
||||||
if not res:
|
d = Dept.query.filter_by(id=id).update({"status": enable})
|
||||||
return fail_api(msg="出错啦")
|
if d:
|
||||||
|
db.session.commit()
|
||||||
return success_api(msg="启用成功")
|
return success_api(msg="启用成功")
|
||||||
|
return fail_api(msg="出错啦")
|
||||||
return fail_api(msg="数据错误")
|
return fail_api(msg="数据错误")
|
||||||
|
|
||||||
|
|
||||||
@@ -82,30 +107,47 @@ def enable():
|
|||||||
@dept_bp.put('/disable')
|
@dept_bp.put('/disable')
|
||||||
@authorize("admin:dept:edit", log=True)
|
@authorize("admin:dept:edit", log=True)
|
||||||
def dis_enable():
|
def dis_enable():
|
||||||
_id = request.json.get('deptId')
|
id = request.json.get('deptId')
|
||||||
if id:
|
if id:
|
||||||
res = dept_curd.disable_status(_id)
|
enable = 0
|
||||||
if not res:
|
d = Dept.query.filter_by(id=id).update({"status": enable})
|
||||||
return fail_api(msg="出错啦")
|
if d:
|
||||||
|
db.session.commit()
|
||||||
return success_api(msg="禁用成功")
|
return success_api(msg="禁用成功")
|
||||||
|
return fail_api(msg="出错啦")
|
||||||
return fail_api(msg="数据错误")
|
return fail_api(msg="数据错误")
|
||||||
|
|
||||||
|
|
||||||
@dept_bp.put('/update')
|
@dept_bp.put('/update')
|
||||||
@authorize("admin:dept:edit", log=True)
|
@authorize("admin:dept:edit", log=True)
|
||||||
def update():
|
def update():
|
||||||
req = request.json
|
json = request.json
|
||||||
check_data(DeptSchema(unknown=INCLUDE), req)
|
validate.check_data(DeptSchema(unknown=INCLUDE), json)
|
||||||
res = dept_curd.update_dept(req)
|
id = json.get("deptId"),
|
||||||
if not res:
|
data = {
|
||||||
|
"dept_name": validate.xss_escape(json.get("deptName")),
|
||||||
|
"sort": validate.xss_escape(json.get("sort")),
|
||||||
|
"leader": validate.xss_escape(json.get("leader")),
|
||||||
|
"phone": validate.xss_escape(json.get("phone")),
|
||||||
|
"email": validate.xss_escape(json.get("email")),
|
||||||
|
"status": validate.xss_escape(json.get("status")),
|
||||||
|
"address": validate.xss_escape(json.get("address"))
|
||||||
|
}
|
||||||
|
d = Dept.query.filter_by(id=id).update(data)
|
||||||
|
if not d:
|
||||||
return fail_api(msg="更新失败")
|
return fail_api(msg="更新失败")
|
||||||
|
db.session.commit()
|
||||||
return success_api(msg="更新成功")
|
return success_api(msg="更新成功")
|
||||||
|
|
||||||
|
|
||||||
@dept_bp.delete('/remove/<int:_id>')
|
@dept_bp.delete('/remove/<int:_id>')
|
||||||
@authorize("admin:dept:remove", log=True)
|
@authorize("admin:dept:remove", log=True)
|
||||||
def remove(_id):
|
def remove(_id):
|
||||||
res = dept_curd.remove_dept(_id)
|
d = Dept.query.filter_by(id=_id).delete()
|
||||||
|
if not d:
|
||||||
|
return fail_api(msg="删除失败")
|
||||||
|
res = User.query.filter_by(dept_id=_id).update({"dept_id": None})
|
||||||
|
db.session.commit()
|
||||||
if res:
|
if res:
|
||||||
return success_api(msg="删除成功")
|
return success_api(msg="删除成功")
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from flask import Blueprint, session, redirect, url_for, render_template, request
|
from flask import Blueprint, session, redirect, url_for, render_template, request
|
||||||
from flask_login import current_user, login_user, login_required, logout_user
|
from flask_login import current_user, login_user, login_required, logout_user
|
||||||
|
|
||||||
from applications.common.admin import index_curd
|
from applications.common import admin as index_curd
|
||||||
from applications.common.admin_log import login_log
|
from applications.common.admin_log import login_log
|
||||||
from applications.common.utils.http import fail_api, success_api
|
from applications.common.utils.http import fail_api, success_api
|
||||||
from applications.models import User
|
from applications.models import User
|
||||||
|
|||||||
@@ -3,18 +3,18 @@ from flask import jsonify
|
|||||||
from flask_login import login_required
|
from flask_login import login_required
|
||||||
|
|
||||||
from . import rights_bp
|
from . import rights_bp
|
||||||
from ...common.admin import index_curd
|
from ...common import admin
|
||||||
|
|
||||||
|
|
||||||
@rights_bp.get('/configs')
|
@rights_bp.get('/configs')
|
||||||
@login_required
|
@login_required
|
||||||
def configs():
|
def configs():
|
||||||
return index_curd.get_render_config()
|
return admin.get_render_config()
|
||||||
|
|
||||||
|
|
||||||
# 菜单
|
# 菜单
|
||||||
@rights_bp.get('/menu')
|
@rights_bp.get('/menu')
|
||||||
@login_required
|
@login_required
|
||||||
def menu():
|
def menu():
|
||||||
menu_tree = index_curd.make_menu_tree()
|
menu_tree = admin.make_menu_tree()
|
||||||
return jsonify(menu_tree)
|
return jsonify(menu_tree)
|
||||||
|
|||||||
Reference in New Issue
Block a user