移除表plugin_setting
This commit is contained in:
@@ -5,6 +5,13 @@ from applications.common.admin_log import admin_log
|
|||||||
|
|
||||||
|
|
||||||
def authorize(power: str, log: bool = False):
|
def authorize(power: str, log: bool = False):
|
||||||
|
"""用户权限判断,用于判断目前会话用户是否拥有访问权限
|
||||||
|
|
||||||
|
:param power: 权限标识
|
||||||
|
:type power: str
|
||||||
|
:param log: 是否记录日志, defaults to False
|
||||||
|
:type log: bool, optional
|
||||||
|
"""
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
@login_required
|
@login_required
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ from applications.dev import role
|
|||||||
from applications.dev import power
|
from applications.dev import power
|
||||||
from applications.dev import department
|
from applications.dev import department
|
||||||
from applications.dev import console
|
from applications.dev import console
|
||||||
from applications.dev import setting
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
|
||||||
# 获取app应用实例,会被初始化插件时重新赋值
|
# 获取app应用实例,会被初始化插件时重新赋值
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
from applications.common import curd
|
|
||||||
from applications.models import pluginSetting
|
|
||||||
from applications.schemas import pluginSettingOutSchema
|
|
||||||
from applications.extensions import db
|
|
||||||
|
|
||||||
def get(key):
|
|
||||||
"""
|
|
||||||
获取设置数据库中保存的值。
|
|
||||||
|
|
||||||
:param key: 查询的键(最长长度 255)
|
|
||||||
|
|
||||||
:return: value
|
|
||||||
"""
|
|
||||||
query = pluginSetting.query.filter_by(key=key).all()
|
|
||||||
data = curd.model_to_dicts(schema=pluginSettingOutSchema, data=query)
|
|
||||||
if len(data) == 0:
|
|
||||||
return None
|
|
||||||
return data[0]['value']
|
|
||||||
|
|
||||||
def set(key, value):
|
|
||||||
"""
|
|
||||||
设置数据库的值。
|
|
||||||
|
|
||||||
:param key: 设置的键(最长长度 255)
|
|
||||||
:param value: 设置的值(最长长度 65525)
|
|
||||||
|
|
||||||
:return: bool
|
|
||||||
"""
|
|
||||||
if len(pluginSetting.query.filter_by(key=key).all()) != 0:
|
|
||||||
d = pluginSetting.query.filter_by(key=key).update({"value": value})
|
|
||||||
if d:
|
|
||||||
db.session.commit()
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
setting = pluginSetting(
|
|
||||||
key=key,
|
|
||||||
value=value
|
|
||||||
)
|
|
||||||
r = db.session.add(setting)
|
|
||||||
db.session.commit()
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
@@ -8,4 +8,3 @@ from .admin_role_power import role_power
|
|||||||
from .admin_user import User
|
from .admin_user import User
|
||||||
from .admin_user_role import user_role
|
from .admin_user_role import user_role
|
||||||
from .admin_mail import Mail
|
from .admin_mail import Mail
|
||||||
from .plugin_setting import pluginSetting
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
from applications.extensions import db
|
|
||||||
|
|
||||||
|
|
||||||
class pluginSetting(db.Model):
|
|
||||||
__tablename__ = 'plugin_setting'
|
|
||||||
id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment="设置项ID")
|
|
||||||
key = db.Column(db.String(255), comment="设置键")
|
|
||||||
value = db.Column(db.String(65535), comment="设置值")
|
|
||||||
|
|
||||||
|
|
||||||
@@ -6,4 +6,3 @@ from .admin_dept import DeptOutSchema
|
|||||||
from .admin_log import LogOutSchema
|
from .admin_log import LogOutSchema
|
||||||
from .admin_photo import PhotoOutSchema
|
from .admin_photo import PhotoOutSchema
|
||||||
from .admin_mail import MailOutSchema
|
from .admin_mail import MailOutSchema
|
||||||
from .plugin_setting import pluginSettingOutSchema
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
from applications.extensions import ma
|
|
||||||
from marshmallow import fields, validate
|
|
||||||
|
|
||||||
|
|
||||||
class pluginSettingInSchema(ma.Schema):
|
|
||||||
key = fields.Str(required=True)
|
|
||||||
value = fields.Str(required=True)
|
|
||||||
|
|
||||||
class pluginSettingOutSchema(ma.Schema):
|
|
||||||
key = fields.Str(attribute="key")
|
|
||||||
value = fields.Str(rattribute="value")
|
|
||||||
@@ -370,14 +370,3 @@ CREATE TABLE `alembic_version` (
|
|||||||
INSERT INTO `alembic_version` VALUES ('7634e028e338');
|
INSERT INTO `alembic_version` VALUES ('7634e028e338');
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS = 1;
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- Table structure for plugin_setting
|
|
||||||
-- ----------------------------
|
|
||||||
DROP TABLE IF EXISTS `plugin_setting`;
|
|
||||||
CREATE TABLE `plugin_setting` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '标识',
|
|
||||||
`key` mediumtext COLLATE utf8_unicode_ci COMMENT '键',
|
|
||||||
`value` mediumtext COLLATE utf8_unicode_ci COMMENT '值',
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE = InnoDB AUTO_INCREMENT = 25 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = DYNAMIC;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user