增加数据字典
This commit is contained in:
@@ -93,3 +93,27 @@ class Photo(db.Model):
|
||||
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,176 @@
|
||||
# 字典管理
|
||||
# 查询字典类型
|
||||
|
||||
from flask_marshmallow import Marshmallow
|
||||
from marshmallow import fields
|
||||
|
||||
from applications.models import db
|
||||
from applications.models.admin import DictType, DictData
|
||||
|
||||
ma = Marshmallow()
|
||||
|
||||
|
||||
# 通过type_code获取字典dict
|
||||
# 例:get_dict('user_sex')
|
||||
# [{'key': '男', 'value': 'boy'}, {'key': '女', 'value': 'girl'}]
|
||||
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
|
||||
|
||||
|
||||
class DictTypeSchema(ma.Schema): # 序列化类
|
||||
id = fields.Str(attribute="id")
|
||||
typeName = fields.Str(attribute="type_name")
|
||||
typeCode = fields.Str(attribute="type_code")
|
||||
description = fields.Str(attribute="description")
|
||||
createTime = fields.Str(attribute="create_time")
|
||||
updateName = fields.Str(attribute="update_time")
|
||||
remark = fields.Str()
|
||||
enable = fields.Str()
|
||||
|
||||
|
||||
class DictDataSchema(ma.Schema): # 序列化类
|
||||
dataId = fields.Str(attribute="id")
|
||||
dataLabel = fields.Str(attribute="data_label")
|
||||
dataValue = fields.Str(attribute="data_value")
|
||||
remark = fields.Str()
|
||||
enable = fields.Str()
|
||||
|
||||
|
||||
def get_dict_type(page, limit, type_name):
|
||||
dict_all = DictType.query
|
||||
if type_name:
|
||||
print('收到了')
|
||||
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()
|
||||
dict_schema = DictTypeSchema(many=True)
|
||||
dict_dict = dict_schema.dump(dict_all.items)
|
||||
return dict_dict, 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_schema = DictDataSchema(many=True)
|
||||
dict_dict = dict_schema.dump(dict_all.items)
|
||||
return dict_dict, count
|
||||
|
||||
|
||||
# 增加dicttype
|
||||
def save_dict_type(req_json):
|
||||
description = req_json.get("description")
|
||||
enable = req_json.get("enable")
|
||||
type_code = req_json.get("typeCode")
|
||||
type_name = 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 = req_json.get("id")
|
||||
description = req_json.get("description")
|
||||
enable = req_json.get("enable")
|
||||
type_code = req_json.get("typeCode")
|
||||
type_name = 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 = req_json.get("dataLabel")
|
||||
data_value = req_json.get("dataValue")
|
||||
enable = req_json.get("enable")
|
||||
remark = req_json.get("remark")
|
||||
type_code = 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": req_json.get("dataLabel"),
|
||||
"data_value": req_json.get("dataValue"),
|
||||
"enable": req_json.get("enable"),
|
||||
"remark": req_json.get("remark"),
|
||||
"type_code": 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
|
||||
@@ -5,6 +5,7 @@ from applications.views.admin.monitor import admin_Monitor
|
||||
from applications.views.admin.admin_log import admin_log
|
||||
from applications.views.admin.power import admin_power
|
||||
from applications.views.admin.role import admin_role
|
||||
from applications.views.admin.dict import admin_dict
|
||||
"""
|
||||
初始化蓝图
|
||||
|
||||
@@ -20,3 +21,5 @@ def init_adminViews(app):
|
||||
app.register_blueprint(admin_log)
|
||||
app.register_blueprint(admin_power)
|
||||
app.register_blueprint(admin_role)
|
||||
app.register_blueprint(admin_dict)
|
||||
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
from flask import Blueprint, render_template, request, jsonify
|
||||
|
||||
from applications.models.admin import DictType, DictData
|
||||
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, \
|
||||
enable_dict_data_status, disable_dict_data_status, update_dict_data
|
||||
from applications.service.route_auth import authorize_and_log
|
||||
|
||||
admin_dict = Blueprint('adminDict', __name__, url_prefix='/admin/dict')
|
||||
|
||||
|
||||
# 数据字典
|
||||
@admin_dict.route('/')
|
||||
@authorize_and_log("admin:dict:main")
|
||||
def main():
|
||||
return render_template('admin/dict/main.html')
|
||||
|
||||
|
||||
@admin_dict.route('/dictType/data')
|
||||
@authorize_and_log("admin:dict:main")
|
||||
def dictType_data():
|
||||
page = request.args.get('page', type=int)
|
||||
limit = request.args.get('limit', type=int)
|
||||
type_name = request.args.get('typeName', type=str)
|
||||
dict_data, count = get_dict_type(page=page, limit=limit, type_name=type_name)
|
||||
res = {
|
||||
"data": dict_data,
|
||||
"count": count,
|
||||
"code": 0,
|
||||
}
|
||||
return jsonify(res)
|
||||
|
||||
|
||||
@admin_dict.route('/dictType/add')
|
||||
@authorize_and_log("admin:dict:add")
|
||||
def dictType_add():
|
||||
return render_template('admin/dict/add.html')
|
||||
|
||||
|
||||
@admin_dict.route('/dictType/save', methods=['POST'])
|
||||
@authorize_and_log("admin:power:add")
|
||||
def dictType_save():
|
||||
req_json = request.json
|
||||
res = save_dict_type(req_json=req_json)
|
||||
if res == None:
|
||||
return jsonify(success=False, msg="增加失败")
|
||||
return jsonify(success=True, msg="增加成功")
|
||||
|
||||
|
||||
# 编辑字典类型
|
||||
@admin_dict.route('/dictType/edit', methods=['GET', 'POST'])
|
||||
@authorize_and_log("admin:dict:edit")
|
||||
def dictType_edit():
|
||||
id = request.args.get('dictTypeId', type=str)
|
||||
dict_type = DictType.query.filter_by(id=id).first()
|
||||
return render_template('admin/dict/edit.html', dict_type=dict_type)
|
||||
|
||||
|
||||
# 编辑字典类型
|
||||
@admin_dict.route('/dictType/update', methods=['PUT'])
|
||||
@authorize_and_log("admin:dict:edit")
|
||||
def dictType_update():
|
||||
req_json = request.json
|
||||
update_dict_type(req_json)
|
||||
return jsonify(success=True, msg="更新成功")
|
||||
|
||||
|
||||
# 启用字典
|
||||
@admin_dict.route('/dictType/enable', methods=['PUT'])
|
||||
@authorize_and_log("admin:dict:edit")
|
||||
def dictType_enable():
|
||||
id = request.json.get('id')
|
||||
print(id)
|
||||
if id:
|
||||
res = enable_dict_type_status(id)
|
||||
if not res:
|
||||
return jsonify(msg="出错啦", success=False)
|
||||
return jsonify(msg="启动成功", success=True)
|
||||
return jsonify(msg="数据错误", success=False)
|
||||
|
||||
|
||||
# 禁用字典
|
||||
@admin_dict.route('/dictType/disable', methods=['PUT'])
|
||||
@authorize_and_log("admin:dict:edit")
|
||||
def dictType_disenable():
|
||||
id = request.json.get('id')
|
||||
print(id)
|
||||
if id:
|
||||
res = disable_dict_type_status(id)
|
||||
if not res:
|
||||
return jsonify(msg="出错啦", success=False)
|
||||
return jsonify(msg="禁用成功", success=True)
|
||||
return jsonify(msg="数据错误", success=False)
|
||||
|
||||
|
||||
# 删除字典类型
|
||||
@admin_dict.route('/dictType/remove/<int:id>', methods=['DELETE'])
|
||||
@authorize_and_log("admin:dict:remove")
|
||||
def dictType_delete(id):
|
||||
res = delete_type_by_id(id)
|
||||
if not res:
|
||||
return jsonify(msg="删除失败", success=False)
|
||||
return jsonify(msg="删除成功", success=True)
|
||||
|
||||
|
||||
@admin_dict.route('/dictData/data')
|
||||
@authorize_and_log("admin:dict:main")
|
||||
def dictCode_data():
|
||||
page = request.args.get('page', type=int)
|
||||
limit = request.args.get('limit', type=int)
|
||||
type_code = request.args.get('typeCode', type=str)
|
||||
dict_data, count = get_dict_data(page=page, limit=limit, type_code=type_code)
|
||||
res = {
|
||||
"data": dict_data,
|
||||
"count": count,
|
||||
"code": 0,
|
||||
}
|
||||
return jsonify(res)
|
||||
|
||||
|
||||
# 增加字典数据
|
||||
@admin_dict.route('/dictData/add')
|
||||
# @authorize_and_log("admin:power:add")
|
||||
def dictData_add():
|
||||
type_code = request.args.get('typeCode', type=str)
|
||||
return render_template('admin/dict/data/add.html', type_code=type_code)
|
||||
|
||||
|
||||
# 增加字典数据
|
||||
@admin_dict.route('/dictData/save', methods=['POST'])
|
||||
# @authorize_and_log("admin:power:main")
|
||||
def dictData_save():
|
||||
req_json = request.json
|
||||
res = save_dict_data(req_json=req_json)
|
||||
if res == None:
|
||||
return jsonify(success=False, msg="增加失败")
|
||||
return jsonify(success=True, msg="增加成功")
|
||||
|
||||
|
||||
# 编辑字典数据
|
||||
@admin_dict.route('/dictData/edit', methods=['GET', 'POST'])
|
||||
@authorize_and_log("admin:dict:edit")
|
||||
def dictData_edit():
|
||||
id = request.args.get('dataId', type=str)
|
||||
dict_data = DictData.query.filter_by(id=id).first()
|
||||
return render_template('admin/dict/data/edit.html', dict_data=dict_data)
|
||||
|
||||
|
||||
# 编辑字典数据
|
||||
@admin_dict.route('/dictData/update', methods=['PUT'])
|
||||
@authorize_and_log("admin:dict:edit")
|
||||
def dictData_update():
|
||||
req_json = request.json
|
||||
update_dict_data(req_json)
|
||||
return jsonify(success=True, msg="更新成功")
|
||||
|
||||
|
||||
# 启用字典数据
|
||||
@admin_dict.route('/dictData/enable', methods=['PUT'])
|
||||
@authorize_and_log("admin:dict:edit")
|
||||
def dictData_enable():
|
||||
id = request.json.get('dataId')
|
||||
print(id)
|
||||
if id:
|
||||
res = enable_dict_data_status(id)
|
||||
if not res:
|
||||
return jsonify(msg="出错啦", success=False)
|
||||
return jsonify(msg="启动成功", success=True)
|
||||
return jsonify(msg="数据错误", success=False)
|
||||
|
||||
|
||||
# 禁用字典数据
|
||||
@admin_dict.route('/dictData/disable', methods=['PUT'])
|
||||
@authorize_and_log("admin:dict:edit")
|
||||
def dictData_disenable():
|
||||
id = request.json.get('dataId')
|
||||
if id:
|
||||
res = disable_dict_data_status(id)
|
||||
if not res:
|
||||
return jsonify(msg="出错啦", success=False)
|
||||
return jsonify(msg="禁用成功", success=True)
|
||||
return jsonify(msg="数据错误", success=False)
|
||||
|
||||
|
||||
# 删除字典类型
|
||||
@admin_dict.route('dictData/remove/<int:id>', methods=['DELETE'])
|
||||
@authorize_and_log("admin:dict:remove")
|
||||
def dictData_delete(id):
|
||||
res = delete_data_by_id(id)
|
||||
if not res:
|
||||
return jsonify(msg="删除失败", success=False)
|
||||
return jsonify(msg="删除成功", success=True)
|
||||
+84
-24
@@ -11,7 +11,7 @@
|
||||
Target Server Version : 50726
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 01/04/2021 23:46:07
|
||||
Date: 16/04/2021 14:06:40
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
@@ -32,11 +32,63 @@ CREATE TABLE `admin_admin_log` (
|
||||
`create_time` datetime(0) NULL DEFAULT NULL,
|
||||
`success` int(11) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1146 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = DYNAMIC;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1267 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- 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
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `admin_dict_data`;
|
||||
CREATE TABLE `admin_dict_data` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`data_label` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '字典类型名称',
|
||||
`data_value` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '字典类型标识',
|
||||
`type_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '字典类型描述',
|
||||
`is_default` int(11) NULL DEFAULT NULL COMMENT '是否默认',
|
||||
`enable` int(11) NULL DEFAULT NULL COMMENT '是否开启',
|
||||
`remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of admin_dict_data
|
||||
-- ----------------------------
|
||||
INSERT INTO `admin_dict_data` VALUES (8, '男', 'boy', 'user_sex', NULL, 1, '男 : body', '2021-04-16 13:36:34', '2021-04-16 14:05:06');
|
||||
INSERT INTO `admin_dict_data` VALUES (9, '女', 'girl', 'user_sex', NULL, 1, '女 : girl', '2021-04-16 13:36:55', '2021-04-16 13:36:55');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for admin_dict_type
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `admin_dict_type`;
|
||||
CREATE TABLE `admin_dict_type` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`type_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '字典类型名称',
|
||||
`type_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '字典类型标识',
|
||||
`description` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '字典类型描述',
|
||||
`enable` int(11) NULL DEFAULT NULL COMMENT '是否开启',
|
||||
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of admin_dict_type
|
||||
-- ----------------------------
|
||||
INSERT INTO `admin_dict_type` VALUES (1, '用户性别', 'user_sex', '用户性别', 1, NULL, '2021-04-16 13:37:11');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for admin_photo
|
||||
@@ -76,7 +128,7 @@ CREATE TABLE `admin_power` (
|
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`enable` int(11) NULL DEFAULT NULL COMMENT '是否开启',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 44 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = DYNAMIC;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 48 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of admin_power
|
||||
@@ -101,6 +153,10 @@ INSERT INTO `admin_power` VALUES (29, '角色删除', '2', 'admin:role:remove',
|
||||
INSERT INTO `admin_power` VALUES (30, '角色授权', '2', 'admin:role:power', '', '', '9', 'layui-icon layui-icon-component', 4, '2021-03-22 19:50:54', '2021-03-25 19:15:26', 1);
|
||||
INSERT INTO `admin_power` VALUES (31, '图片增加', '2', 'admin:file:add', '', '', '18', 'layui-icon layui-icon-add-circle', 1, '2021-03-22 19:58:05', '2021-03-25 19:15:28', 1);
|
||||
INSERT INTO `admin_power` VALUES (32, '图片删除', '2', 'admin:file:delete', '', '', '18', 'layui-icon layui-icon-delete', 2, '2021-03-22 19:58:45', '2021-03-25 19:15:29', 1);
|
||||
INSERT INTO `admin_power` VALUES (44, '数据字典', '1', 'admin:dict:main', '/admin/dict', '_iframe', '1', 'layui-icon layui-icon-console', 6, '2021-04-16 13:59:49', '2021-04-16 13:59:49', 1);
|
||||
INSERT INTO `admin_power` VALUES (45, '字典增加', '2', 'admin:dict:add', '', '', '44', 'layui-icon ', 1, '2021-04-16 14:00:59', '2021-04-16 14:00:59', 1);
|
||||
INSERT INTO `admin_power` VALUES (46, '字典修改', '2', 'admin:dict:edit', '', '', '44', 'layui-icon ', 2, '2021-04-16 14:01:33', '2021-04-16 14:01:33', 1);
|
||||
INSERT INTO `admin_power` VALUES (47, '字典删除', '2', 'admin:dict:remove', '', '', '44', 'layui-icon ', 3, '2021-04-16 14:02:06', '2021-04-16 14:02:06', 1);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for admin_role
|
||||
@@ -138,31 +194,11 @@ CREATE TABLE `admin_role_power` (
|
||||
INDEX `role_id`(`role_id`) USING BTREE,
|
||||
CONSTRAINT `admin_role_power_ibfk_1` FOREIGN KEY (`power_id`) REFERENCES `admin_power` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
CONSTRAINT `admin_role_power_ibfk_2` FOREIGN KEY (`role_id`) REFERENCES `admin_role` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 167 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = DYNAMIC;
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 212 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of admin_role_power
|
||||
-- ----------------------------
|
||||
INSERT INTO `admin_role_power` VALUES (132, 1, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (133, 3, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (134, 4, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (135, 9, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (136, 12, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (137, 13, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (138, 17, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (139, 18, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (140, 21, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (141, 22, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (142, 23, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (143, 24, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (144, 25, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (145, 26, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (146, 27, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (147, 28, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (148, 29, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (149, 30, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (150, 31, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (151, 32, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (159, 1, 2);
|
||||
INSERT INTO `admin_role_power` VALUES (160, 3, 2);
|
||||
INSERT INTO `admin_role_power` VALUES (161, 4, 2);
|
||||
@@ -171,6 +207,30 @@ INSERT INTO `admin_role_power` VALUES (163, 12, 2);
|
||||
INSERT INTO `admin_role_power` VALUES (164, 13, 2);
|
||||
INSERT INTO `admin_role_power` VALUES (165, 17, 2);
|
||||
INSERT INTO `admin_role_power` VALUES (166, 18, 2);
|
||||
INSERT INTO `admin_role_power` VALUES (188, 1, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (189, 3, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (190, 4, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (191, 9, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (192, 12, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (193, 13, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (194, 17, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (195, 18, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (196, 21, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (197, 22, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (198, 23, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (199, 24, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (200, 25, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (201, 26, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (202, 27, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (203, 28, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (204, 29, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (205, 30, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (206, 31, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (207, 32, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (208, 44, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (209, 45, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (210, 46, 1);
|
||||
INSERT INTO `admin_role_power` VALUES (211, 47, 1);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for admin_user
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Generic single-database configuration.
|
||||
@@ -1,45 +0,0 @@
|
||||
# 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
|
||||
@@ -1,96 +0,0 @@
|
||||
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()
|
||||
@@ -1,24 +0,0 @@
|
||||
"""${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,28 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 58fc2c4c30a5
|
||||
Revises: 715a8ecc5856
|
||||
Create Date: 2021-03-19 21:31:06.761526
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '58fc2c4c30a5'
|
||||
down_revision = '715a8ecc5856'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('admin_role', sa.Column('enable', sa.Integer(), nullable=True, comment='是否启用'))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('admin_role', 'enable')
|
||||
# ### end Alembic commands ###
|
||||
@@ -1,28 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 64de3323bc01
|
||||
Revises: 95b59a101b26
|
||||
Create Date: 2021-03-18 20:54:17.724297
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '64de3323bc01'
|
||||
down_revision = '95b59a101b26'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('admin_user', sa.Column('realname', sa.String(length=20), nullable=True, comment='真实名字'))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('admin_user', 'realname')
|
||||
# ### end Alembic commands ###
|
||||
@@ -1,28 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 715a8ecc5856
|
||||
Revises: 64de3323bc01
|
||||
Create Date: 2021-03-19 21:30:52.200812
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '715a8ecc5856'
|
||||
down_revision = '64de3323bc01'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('admin_role', 'enable')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('admin_role', sa.Column('enable', mysql.CHAR(collation='utf8_unicode_ci', length=1), nullable=True, comment='是否启用'))
|
||||
# ### end Alembic commands ###
|
||||
@@ -1,28 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 816f66c2def4
|
||||
Revises: ce8825111f8f
|
||||
Create Date: 2021-03-14 22:57:37.092157
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '816f66c2def4'
|
||||
down_revision = 'ce8825111f8f'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('admin_admin_log', sa.Column('success', sa.Integer(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('admin_admin_log', 'success')
|
||||
# ### end Alembic commands ###
|
||||
@@ -1,28 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 85fcf9a09800
|
||||
Revises: e187b65f7f1b
|
||||
Create Date: 2021-04-01 21:03:40.387739
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '85fcf9a09800'
|
||||
down_revision = 'e187b65f7f1b'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('admin_user', sa.Column('avatar', sa.String(length=255), nullable=True, comment='头像'))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('admin_user', 'avatar')
|
||||
# ### end Alembic commands ###
|
||||
@@ -1,30 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 95b59a101b26
|
||||
Revises: 816f66c2def4
|
||||
Create Date: 2021-03-17 22:28:41.595865
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '95b59a101b26'
|
||||
down_revision = '816f66c2def4'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('admin_user', sa.Column('enable', sa.Integer(), nullable=True, comment='启用'))
|
||||
op.drop_column('admin_user', 'status')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('admin_user', sa.Column('status', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True, comment='启用'))
|
||||
op.drop_column('admin_user', 'enable')
|
||||
# ### end Alembic commands ###
|
||||
@@ -1,8 +1,8 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 59add0790978
|
||||
Revision ID: 9a591b224cc7
|
||||
Revises:
|
||||
Create Date: 2021-03-11 22:39:09.829159
|
||||
Create Date: 2021-04-16 10:13:27.930524
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
@@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '59add0790978'
|
||||
revision = '9a591b224cc7'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
@@ -25,10 +25,33 @@ def upgrade():
|
||||
sa.Column('url', sa.String(length=255), nullable=True),
|
||||
sa.Column('desc', sa.Text(), nullable=True),
|
||||
sa.Column('ip', sa.String(length=255), nullable=True),
|
||||
sa.Column('success', sa.Integer(), nullable=True),
|
||||
sa.Column('user_agent', sa.Text(), nullable=True),
|
||||
sa.Column('create_time', sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('admin_dict_data',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('data_label', sa.String(length=255), nullable=True, comment='字典类型名称'),
|
||||
sa.Column('data_value', sa.String(length=255), nullable=True, comment='字典类型标识'),
|
||||
sa.Column('type_code', sa.String(length=255), nullable=True, comment='字典类型描述'),
|
||||
sa.Column('is_default', sa.Integer(), nullable=True, comment='是否默认'),
|
||||
sa.Column('enable', sa.Integer(), nullable=True, comment='是否开启'),
|
||||
sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'),
|
||||
sa.Column('create_time', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('update_time', sa.DateTime(), nullable=True, comment='更新时间'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('admin_dict_type',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('type_name', sa.String(length=255), nullable=True, comment='字典类型名称'),
|
||||
sa.Column('type_code', sa.String(length=255), nullable=True, comment='字典类型标识'),
|
||||
sa.Column('description', sa.String(length=255), nullable=True, comment='字典类型描述'),
|
||||
sa.Column('enable', sa.Integer(), nullable=True, comment='是否开启'),
|
||||
sa.Column('create_time', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('update_time', sa.DateTime(), nullable=True, comment='更新时间'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('admin_photo',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=False),
|
||||
@@ -45,7 +68,7 @@ def upgrade():
|
||||
sa.Column('code', sa.String(length=30), nullable=True, comment='权限标识'),
|
||||
sa.Column('url', sa.String(length=255), nullable=True, comment='权限路径'),
|
||||
sa.Column('open_type', sa.String(length=10), nullable=True, comment='打开方式'),
|
||||
sa.Column('parent_id', sa.String(length=19), nullable=True, comment='父类编号'),
|
||||
sa.Column('parent_id', sa.Integer(), nullable=True, comment='父类编号'),
|
||||
sa.Column('icon', sa.String(length=128), nullable=True, comment='图标'),
|
||||
sa.Column('sort', sa.Integer(), nullable=True, comment='排序'),
|
||||
sa.Column('create_time', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
@@ -57,7 +80,7 @@ def upgrade():
|
||||
sa.Column('id', sa.Integer(), nullable=False, comment='角色ID'),
|
||||
sa.Column('name', sa.String(length=255), nullable=True, comment='角色名称'),
|
||||
sa.Column('code', sa.String(length=255), nullable=True, comment='角色标识'),
|
||||
sa.Column('enable', sa.CHAR(length=1), nullable=True, comment='是否启用'),
|
||||
sa.Column('enable', sa.Integer(), nullable=True, comment='是否启用'),
|
||||
sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'),
|
||||
sa.Column('details', sa.String(length=255), nullable=True, comment='详情'),
|
||||
sa.Column('sort', sa.Integer(), nullable=True, comment='排序'),
|
||||
@@ -68,12 +91,23 @@ def upgrade():
|
||||
op.create_table('admin_user',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='用户ID'),
|
||||
sa.Column('username', sa.String(length=20), nullable=True, comment='用户名'),
|
||||
sa.Column('realname', sa.String(length=20), nullable=True, comment='真实名字'),
|
||||
sa.Column('avatar', sa.String(length=255), nullable=True, comment='头像'),
|
||||
sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'),
|
||||
sa.Column('password_hash', sa.String(length=128), nullable=True, comment='哈希密码'),
|
||||
sa.Column('status', sa.Integer(), nullable=True, comment='启用'),
|
||||
sa.Column('enable', sa.Integer(), nullable=True, comment='启用'),
|
||||
sa.Column('create_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.Column('update_at', sa.DateTime(), nullable=True, comment='创建时间'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('admin_role_power',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='标识'),
|
||||
sa.Column('power_id', sa.Integer(), nullable=True, comment='用户编号'),
|
||||
sa.Column('role_id', sa.Integer(), nullable=True, comment='角色编号'),
|
||||
sa.ForeignKeyConstraint(['power_id'], ['admin_power.id'], ),
|
||||
sa.ForeignKeyConstraint(['role_id'], ['admin_role.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('admin_user_role',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='标识'),
|
||||
sa.Column('user_id', sa.Integer(), nullable=True, comment='用户编号'),
|
||||
@@ -88,9 +122,12 @@ def upgrade():
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('admin_user_role')
|
||||
op.drop_table('admin_role_power')
|
||||
op.drop_table('admin_user')
|
||||
op.drop_table('admin_role')
|
||||
op.drop_table('admin_power')
|
||||
op.drop_table('admin_photo')
|
||||
op.drop_table('admin_dict_type')
|
||||
op.drop_table('admin_dict_data')
|
||||
op.drop_table('admin_admin_log')
|
||||
# ### end Alembic commands ###
|
||||
@@ -1,35 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: ce8825111f8f
|
||||
Revises: 59add0790978
|
||||
Create Date: 2021-03-11 22:41:25.156430
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'ce8825111f8f'
|
||||
down_revision = '59add0790978'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('admin_role_power',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='标识'),
|
||||
sa.Column('power_id', sa.Integer(), nullable=True, comment='用户编号'),
|
||||
sa.Column('role_id', sa.Integer(), nullable=True, comment='角色编号'),
|
||||
sa.ForeignKeyConstraint(['power_id'], ['admin_power.id'], ),
|
||||
sa.ForeignKeyConstraint(['role_id'], ['admin_role.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('admin_role_power')
|
||||
# ### end Alembic commands ###
|
||||
@@ -1,28 +0,0 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: e187b65f7f1b
|
||||
Revises: 58fc2c4c30a5
|
||||
Create Date: 2021-04-01 21:03:04.872235
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'e187b65f7f1b'
|
||||
down_revision = '58fc2c4c30a5'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('admin_user', sa.Column('remark', sa.String(length=255), nullable=True, comment='备注'))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('admin_user', 'remark')
|
||||
# ### end Alembic commands ###
|
||||
@@ -0,0 +1,93 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>字典增加</title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='/admin/component/pear/css/pear.css') }}" />
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
<div class="mainBox">
|
||||
<div class="main-container">
|
||||
<div class="main-container">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="typeName" lay-verify="title" autocomplete="off" placeholder="请输入名称"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">标识</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="typeCode" lay-verify="title" autocomplete="off" placeholder="请输入标识"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="enable" value="1" title="开启">
|
||||
<input type="radio" name="enable" value="0" title="关闭" checked>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea placeholder="请输入描述" name="description" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
|
||||
lay-filter="dict-type-save">
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-sm">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="{{ url_for('static', filename='/admin/component/layui/layui.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='/admin/component/pear/pear.js') }}"></script>
|
||||
|
||||
<script>
|
||||
layui.use(['form', 'jquery'], function () {
|
||||
let form = layui.form;
|
||||
let $ = layui.jquery;
|
||||
|
||||
form.on('submit(dict-type-save)', function (data) {
|
||||
$.ajax({
|
||||
url: '/admin/dict/dictType/save',
|
||||
data: JSON.stringify(data.field),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'post',
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, {icon: 1, time: 1000}, function () {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
|
||||
parent.layui.table.reload("dict-type-table");
|
||||
});
|
||||
} else {
|
||||
layer.msg(result.msg, {icon: 2, time: 1000});
|
||||
}
|
||||
}
|
||||
})
|
||||
return false;
|
||||
});
|
||||
})
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,99 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>字典增加</title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='/admin/component/pear/css/pear.css') }}" />
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
<div class="mainBox">
|
||||
<div class="main-container">
|
||||
<div class="main-container">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">标签</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="dataLabel" lay-verify="title" autocomplete="off" placeholder="请输入标签"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">值</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="dataValue" lay-verify="title" autocomplete="off" placeholder="请输入值"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">标识</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{type_code}}" readonly="readonly" name="typeCode" lay-verify="title"
|
||||
autocomplete="off" placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="enable" value="1" title="开启">
|
||||
<input type="radio" name="enable" value="0" title="关闭" checked>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea placeholder="请输入描述" name="remark" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
|
||||
lay-filter="dict-data-save">
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-sm">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="{{ url_for('static', filename='/admin/component/layui/layui.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='/admin/component/pear/pear.js') }}"></script>
|
||||
<script>
|
||||
layui.use(['form', 'jquery'], function () {
|
||||
let form = layui.form;
|
||||
let $ = layui.jquery;
|
||||
|
||||
form.on('submit(dict-data-save)', function (data) {
|
||||
$.ajax({
|
||||
url: '/admin/dict/dictData/save',
|
||||
data: JSON.stringify(data.field),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'post',
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, {icon: 1, time: 1000}, function () {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
|
||||
parent.layui.table.reload("dict-data-table");
|
||||
});
|
||||
} else {
|
||||
layer.msg(result.msg, {icon: 2, time: 1000});
|
||||
}
|
||||
}
|
||||
})
|
||||
return false;
|
||||
});
|
||||
})
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,109 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>字典增加</title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='/admin/component/pear/css/pear.css') }}" />
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
<div class="mainBox">
|
||||
<div class="main-container">
|
||||
<div class="main-container">
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label">编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ dict_data.id }}" name="dataId" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">标签</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ dict_data.data_label }}" name="dataLabel" lay-verify="title"
|
||||
autocomplete="off" placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">值</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ dict_data.data_value }}" name="dataValue" lay-verify="title"
|
||||
autocomplete="off" placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">标识</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{dict_data.type_code}}" readonly="readonly" name="typeCode"
|
||||
lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" {% if dict_data.enable == 1 %} } checked{% endif %} name="enable" value="1"
|
||||
title="开启">
|
||||
<input type="radio" {% if dict_data.enable == 0 %} } checked{% endif %} name="enable" value="0"
|
||||
title="关闭">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea placeholder="请输入描述" name="remark"
|
||||
class="layui-textarea">{{ dict_data.remark }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
|
||||
lay-filter="dict-data-save">
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-sm">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="{{ url_for('static', filename='/admin/component/layui/layui.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='/admin/component/pear/pear.js') }}"></script>
|
||||
|
||||
<script>
|
||||
layui.use(['form', 'jquery'], function () {
|
||||
let form = layui.form;
|
||||
let $ = layui.jquery;
|
||||
|
||||
form.on('submit(dict-data-save)', function (data) {
|
||||
$.ajax({
|
||||
url: '/admin/dict/dictData/update',
|
||||
data: JSON.stringify(data.field),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'put',
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, {icon: 1, time: 1000}, function () {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
|
||||
parent.layui.table.reload("dict-data-table");
|
||||
});
|
||||
} else {
|
||||
layer.msg(result.msg, {icon: 2, time: 1000});
|
||||
}
|
||||
}
|
||||
})
|
||||
return false;
|
||||
});
|
||||
})
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,103 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>字典增加</title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='/admin/component/pear/css/pear.css') }}" />
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
<div class="mainBox">
|
||||
<div class="main-container">
|
||||
<div class="main-container">
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label">编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{dict_type.id}}" name="id" lay-verify="title" autocomplete="off"
|
||||
placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{dict_type.type_name}}" name="typeName" lay-verify="title"
|
||||
autocomplete="off" placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">标识</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{dict_type.type_code}}" readonly name="typeCode"
|
||||
lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" {% if dict_type.enable == 1 %} } checked{% endif %} name="enable" value="1"
|
||||
title="开启">
|
||||
<input type="radio" {% if dict_type.enable == 0 %} } checked{% endif %} name="enable" value="0"
|
||||
title="关闭">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">描述</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea placeholder="请输入描述" name="description"
|
||||
class="layui-textarea">{{dict_type.description}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
|
||||
lay-filter="dict-type-update">
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-sm">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="{{ url_for('static', filename='/admin/component/layui/layui.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='/admin/component/pear/pear.js') }}"></script>
|
||||
|
||||
<script>
|
||||
layui.use(['form', 'jquery'], function () {
|
||||
let form = layui.form;
|
||||
let $ = layui.jquery;
|
||||
|
||||
form.on('submit(dict-type-update)', function (data) {
|
||||
$.ajax({
|
||||
url: '/admin/dict/dictType/update',
|
||||
data: JSON.stringify(data.field),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'put',
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, {icon: 1, time: 1000}, function () {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
|
||||
parent.layui.table.reload("dict-type-table");
|
||||
});
|
||||
} else {
|
||||
layer.msg(result.msg, {icon: 2, time: 1000});
|
||||
}
|
||||
}
|
||||
})
|
||||
return false;
|
||||
});
|
||||
})
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,357 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>字典管理</title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='/admin/component/pear/css/pear.css') }}" />
|
||||
</head>
|
||||
<body class="pear-container">
|
||||
<div class="layui-row layui-col-space10">
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<form class="layui-form" action="">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">字典名称</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="typeName" placeholder="" class="layui-input">
|
||||
</div>
|
||||
<button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="dict-type-query">
|
||||
<i class="layui-icon layui-icon-search"></i>
|
||||
查询
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-md">
|
||||
<i class="layui-icon layui-icon-refresh"></i>
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md6">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<table id="dict-type-table" lay-filter="dict-type-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md6">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<svg class="empty" style="margin-top: 50px;margin-left: 220px;margin-bottom: 80px;" width="184" height="152" viewBox="0 0 184 152" xmlns="http://www.w3.org/2000/svg"><g fill="none" fillRule="evenodd"><g transform="translate(24 31.67)"><ellipse fillOpacity=".8" fill="#F5F5F7" cx="67.797" cy="106.89" rx="67.797" ry="12.668"></ellipse><path d="M122.034 69.674L98.109 40.229c-1.148-1.386-2.826-2.225-4.593-2.225h-51.44c-1.766 0-3.444.839-4.592 2.225L13.56 69.674v15.383h108.475V69.674z" fill="#AEB8C2"></path><path d="M101.537 86.214L80.63 61.102c-1.001-1.207-2.507-1.867-4.048-1.867H31.724c-1.54 0-3.047.66-4.048 1.867L6.769 86.214v13.792h94.768V86.214z" fill="url(#linearGradient-1)" transform="translate(13.56)"></path><path d="M33.83 0h67.933a4 4 0 0 1 4 4v93.344a4 4 0 0 1-4 4H33.83a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4z" fill="#F5F5F7"></path><path d="M42.678 9.953h50.237a2 2 0 0 1 2 2V36.91a2 2 0 0 1-2 2H42.678a2 2 0 0 1-2-2V11.953a2 2 0 0 1 2-2zM42.94 49.767h49.713a2.262 2.262 0 1 1 0 4.524H42.94a2.262 2.262 0 0 1 0-4.524zM42.94 61.53h49.713a2.262 2.262 0 1 1 0 4.525H42.94a2.262 2.262 0 0 1 0-4.525zM121.813 105.032c-.775 3.071-3.497 5.36-6.735 5.36H20.515c-3.238 0-5.96-2.29-6.734-5.36a7.309 7.309 0 0 1-.222-1.79V69.675h26.318c2.907 0 5.25 2.448 5.25 5.42v.04c0 2.971 2.37 5.37 5.277 5.37h34.785c2.907 0 5.277-2.421 5.277-5.393V75.1c0-2.972 2.343-5.426 5.25-5.426h26.318v33.569c0 .617-.077 1.216-.221 1.789z" fill="#DCE0E6"></path></g><path d="M149.121 33.292l-6.83 2.65a1 1 0 0 1-1.317-1.23l1.937-6.207c-2.589-2.944-4.109-6.534-4.109-10.408C138.802 8.102 148.92 0 161.402 0 173.881 0 184 8.102 184 18.097c0 9.995-10.118 18.097-22.599 18.097-4.528 0-8.744-1.066-12.28-2.902z" fill="#DCE0E6"></path><g transform="translate(149.65 15.383)" fill="#FFF"><ellipse cx="20.654" cy="3.167" rx="2.849" ry="2.815"></ellipse><path d="M5.698 5.63H0L2.898.704zM9.259.704h4.985V5.63H9.259z"></path></g></g></svg>
|
||||
<table id="dict-data-table" lay-filter="dict-data-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
<script type="text/html" id="dict-type-toolbar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
|
||||
<i class="layui-icon layui-icon-add-1"></i>
|
||||
新增
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-md" lay-event="batchRemove">
|
||||
<i class="layui-icon layui-icon-delete"></i>
|
||||
删除
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="dict-type-bar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit">
|
||||
<i class="layui-icon layui-icon-edit"></i>
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-warming pear-btn-sm" lay-event="details">
|
||||
<i class="layui-icon layui-icon-transfer"></i>
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove">
|
||||
<i class="layui-icon layui-icon-delete"></i>
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="dict-type-enable">
|
||||
<input type="checkbox" value="{{"{{ d.id }}"}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="dict-type-enable"
|
||||
{{"{{# if(d.enable==1){ }} checked {{# } }}"}}>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="dict-data-toolbar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
|
||||
<i class="layui-icon layui-icon-add-1"></i>
|
||||
新增
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-md" lay-event="batchRemove">
|
||||
<i class="layui-icon layui-icon-delete"></i>
|
||||
删除
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="dict-data-bar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i>
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="dict-data-enable">
|
||||
<input type="checkbox" value="{{"{{ d.dataId }}"}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="dict-data-enable"
|
||||
{{"{{# if(d.enable==1){ }} checked {{# } }}"}}>
|
||||
</script>
|
||||
|
||||
<script src="{{ url_for('static', filename='/admin/component/layui/layui.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='/admin/component/pear/pear.js') }}"></script>
|
||||
<script>
|
||||
layui.use(['table', 'form', 'jquery','popup'], function () {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let $ = layui.jquery;
|
||||
let popup = layui.popup;
|
||||
|
||||
let typeCode;
|
||||
|
||||
let cols = [
|
||||
[
|
||||
{type: 'checkbox'},
|
||||
{title: '字典名称', field: 'typeName', align: 'center', width: 120},
|
||||
{title: '描述', field: 'description', align: 'center'},
|
||||
{title: '字典状态', field: 'enable', align: 'center', templet: '#dict-type-enable'},
|
||||
{title: '操作', toolbar: '#dict-type-bar', align: 'center', width: 180}
|
||||
]
|
||||
];
|
||||
|
||||
let dataCols = [
|
||||
[
|
||||
{type: 'checkbox'},
|
||||
{title: '标签', field: 'dataLabel', align: 'center', width: 120},
|
||||
{title: '对应值', field: 'dataValue', align: 'center'},
|
||||
{title: '状态', field: 'enable', align: 'center', templet: '#dict-data-enable'},
|
||||
{title: '操作', toolbar: '#dict-data-bar', align: 'center', width: 180}
|
||||
]
|
||||
];
|
||||
|
||||
table.render({
|
||||
elem: '#dict-type-table',
|
||||
url: '/admin/dict/dictType/data',
|
||||
page: true,
|
||||
cols: cols,
|
||||
skin: 'line',
|
||||
height: 'full-148',
|
||||
toolbar: '#dict-type-toolbar',
|
||||
defaultToolbar: [{
|
||||
layEvent: 'refresh',
|
||||
icon: 'layui-icon-refresh',
|
||||
}, 'filter', 'print', 'exports']
|
||||
});
|
||||
|
||||
window.renderData = function(code){
|
||||
typeCode = code;
|
||||
$(".empty").hide();
|
||||
table.render({
|
||||
elem: '#dict-data-table',
|
||||
url: '/admin/dict/dictData/data?typeCode=' + typeCode,
|
||||
page: true,
|
||||
height: 'full-148',
|
||||
cols: dataCols,
|
||||
skin: 'line',
|
||||
toolbar: '#dict-data-toolbar'
|
||||
});
|
||||
}
|
||||
|
||||
table.on('tool(dict-type-table)', function (obj) {
|
||||
if (obj.event === 'remove') {
|
||||
window.removeType(obj);
|
||||
} else if (obj.event === 'edit') {
|
||||
window.editType(obj);
|
||||
} else if (obj.event === 'details') {
|
||||
window.renderData(obj.data['typeCode'])
|
||||
}
|
||||
});
|
||||
|
||||
table.on('toolbar(dict-type-table)', function (obj) {
|
||||
if (obj.event === 'add') {
|
||||
window.addType();
|
||||
} else if (obj.event === 'refresh') {
|
||||
window.refreshType();
|
||||
}
|
||||
});
|
||||
|
||||
form.on('submit(dict-type-query)', function (data) {
|
||||
table.reload('dict-type-table', {where: data.field});
|
||||
return false;
|
||||
});
|
||||
|
||||
form.on('switch(dict-type-enable)', function (obj) {
|
||||
let operate;
|
||||
if (obj.elem.checked) {
|
||||
operate = "enable";
|
||||
} else {
|
||||
operate = "disable";
|
||||
}
|
||||
let loading = layer.load()
|
||||
$.ajax({
|
||||
url: '/admin/dict/dictType/' + operate,
|
||||
data: JSON.stringify({id: this.value}),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'put',
|
||||
success: function (result) {
|
||||
layer.close(loading);
|
||||
if (result.success) {
|
||||
popup.success(result.msg);
|
||||
} else {
|
||||
popup.failure(result.msg);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
window.addType = function () {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
shade: 0.1,
|
||||
area: ['500px', '400px'],
|
||||
content: '/admin/dict/dictType/add'
|
||||
});
|
||||
}
|
||||
|
||||
window.editType = function (obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
shade: 0.1,
|
||||
area: ['500px', '400px'],
|
||||
content: '/admin/dict/dictType/edit?dictTypeId=' + obj.data['id']
|
||||
});
|
||||
}
|
||||
|
||||
window.removeType = function (obj) {
|
||||
layer.confirm('确定要删除该字典分类', {icon: 3, title: '提示'}, function (index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: "/admin/dict/dictType/remove/" + obj.data['id'],
|
||||
dataType: 'json',
|
||||
type: 'delete',
|
||||
success: function (result) {
|
||||
layer.close(loading);
|
||||
if (result.success) {
|
||||
popup.success(result.msg, function(){
|
||||
if(typeCode == obj.data['typeCode']){
|
||||
$("[lay-id='dict-data-table']").remove();
|
||||
$(".empty").show();
|
||||
}
|
||||
obj.del();
|
||||
})
|
||||
} else {
|
||||
popup.failure(result.msg);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
window.refreshType = function () {
|
||||
table.reload('dict-type-table');
|
||||
}
|
||||
|
||||
window.addData = function () {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
shade: 0.1,
|
||||
area: ['500px', '450px'],
|
||||
content: '/admin/dict/dictData/add?typeCode='+typeCode
|
||||
});
|
||||
}
|
||||
|
||||
window.editData = function (obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
shade: 0.1,
|
||||
area: ['500px', '450px'],
|
||||
content: '/admin/dict/dictData/edit?dataId=' + obj.data['dataId']
|
||||
});
|
||||
}
|
||||
|
||||
window.removeData = function (obj) {
|
||||
layer.confirm('确定要删除该字典值', {icon: 3, title: '提示'}, function (index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: "/admin/dict/dictData/remove/" + obj.data['dataId'],
|
||||
dataType: 'json',
|
||||
type: 'delete',
|
||||
success: function (result) {
|
||||
layer.close(loading);
|
||||
if (result.success) {
|
||||
popup.success(result.msg,function(){
|
||||
obj.del();
|
||||
})
|
||||
} else {
|
||||
popup.failure(result.msg);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
table.on('tool(dict-data-table)', function (obj) {
|
||||
if (obj.event === 'remove') {
|
||||
window.removeData(obj);
|
||||
} else if (obj.event === 'edit') {
|
||||
window.editData(obj);
|
||||
} else if (obj.event === 'details') {
|
||||
window.details(obj);
|
||||
}
|
||||
});
|
||||
|
||||
table.on('toolbar(dict-data-table)', function (obj) {
|
||||
if (obj.event === 'add') {
|
||||
window.addData();
|
||||
} else if (obj.event === 'refresh') {
|
||||
window.refreshData();
|
||||
}
|
||||
});
|
||||
|
||||
form.on('submit(dict-data-query)', function (data) {
|
||||
data.field.typeCode = typeCode;
|
||||
table.reload('dict-data-table', {where: data.field})
|
||||
return false;
|
||||
});
|
||||
|
||||
form.on('switch(dict-data-enable)', function (obj) {
|
||||
let operate;
|
||||
if (obj.elem.checked) {
|
||||
operate = "enable";
|
||||
} else {
|
||||
operate = "disable";
|
||||
}
|
||||
let loading = layer.load()
|
||||
$.ajax({
|
||||
url: '/admin/dict/dictData/' + operate,
|
||||
data: JSON.stringify({dataId: this.value}),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
type: 'put',
|
||||
success: function (result) {
|
||||
layer.close(loading);
|
||||
if (result.success) {
|
||||
popup.success(result.msg);
|
||||
} else {
|
||||
popup.failure(result.msg);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
window.refreshData = function () {
|
||||
table.reload('dict-data-table');
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>权限</title>
|
||||
@@ -7,7 +7,6 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='/admin/component/pear/css/pear.css') }}" />
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='/admin/admin/css/other/console2.css') }}" />
|
||||
</head>
|
||||
<body class="pear-container">
|
||||
<div class="layui-card">
|
||||
|
||||
Reference in New Issue
Block a user