diff --git a/pear_admin/apis/rights.py b/pear_admin/apis/rights.py index 7c6fd95..9e7354f 100644 --- a/pear_admin/apis/rights.py +++ b/pear_admin/apis/rights.py @@ -33,3 +33,25 @@ def rights_list(): data["isParent"] = True ret.append(data) return {"code": 0, "message": "请求权限数据成功", "count": pages.total, "data": ret} + + +@rights_api.post("/rights") +@jwt_required() +def create_rights(): + data = request.get_json() + rights_obj = RightsORM(**data) + rights_obj.save() + return {"code": 0, "message": "新增权限数据成功"} + + +@rights_api.put("/rights/") +@jwt_required() +def change_rights(rid): + data = request.get_json() + del data["id"] + + rights_obj = RightsORM.query.get(rid) + for key, value in data.items(): + setattr(rights_obj, key, value) + rights_obj.save() + return {"code": 0, "message": "修改权限数据成功"} diff --git a/pear_admin/orms/rights.py b/pear_admin/orms/rights.py index cd60eca..f06f0c0 100644 --- a/pear_admin/orms/rights.py +++ b/pear_admin/orms/rights.py @@ -14,9 +14,9 @@ class RightsORM(BaseORM): type = db.Column(db.String(30), comment="权限类型") url = db.Column(db.String(30), comment="路径地址") - icon = db.Column(db.String(128), comment="图标") + icon_sign = db.Column(db.String(128), comment="图标") status = db.Column(db.Boolean, default=True, comment="是否开启") - sort = db.Column(db.Integer, default=1) + sort = db.Column(db.Integer, default=0) open_type = db.Column(db.String(128), comment="打开方式") pid = db.Column( db.Integer, @@ -37,7 +37,7 @@ class RightsORM(BaseORM): "code": self.code, "type": self.type, "url": self.url, - "icon_sign": self.icon, + "icon_sign": self.icon_sign, "status": self.status, "sort": self.sort, "open_type": self.open_type, @@ -53,7 +53,7 @@ class RightsORM(BaseORM): "title": self.name, "type": type_map_dict[self.type], "href": self.url, - "icon": self.icon, + "icon": self.icon_sign, "sort": self.sort, "openType": self.open_type, } diff --git a/static/data/ums_rights.csv b/static/data/ums_rights.csv index 8249d70..249a728 100644 --- a/static/data/ums_rights.csv +++ b/static/data/ums_rights.csv @@ -1,4 +1,4 @@ -id,name,code,type,url,icon,status,sort,open_type,pid +id,name,code,type,url,icon_sign,status,sort,open_type,pid 100,系统管理,ums:rights,menu,,layui-icon layui-icon-set-fill,,2,,0 101,权限管理,ums:rights:list,path,/views/rights,layui-icon layui-icon-console,,1,,100 102,新增权限,ums:rights:create,auth,,,,0,,101 diff --git a/templates/includes/script.html b/templates/includes/script.html index d8f7175..1da6642 100644 --- a/templates/includes/script.html +++ b/templates/includes/script.html @@ -6,3 +6,15 @@ + diff --git a/templates/views/rights/index.html b/templates/views/rights/index.html index 2ecddff..f58cf20 100644 --- a/templates/views/rights/index.html +++ b/templates/views/rights/index.html @@ -25,7 +25,7 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + +
+
+