feature: 权限列表-2

This commit is contained in:
zhengxinonly
2023-10-10 22:55:15 +08:00
parent f95ae54fd5
commit 607cbc94ba
5 changed files with 254 additions and 29 deletions
+22
View File
@@ -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/<int:rid>")
@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": "修改权限数据成功"}
+4 -4
View File
@@ -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,
}