feat: 动态菜单

This commit is contained in:
zy7y
2022-09-13 16:53:31 +08:00
parent 9ce271d691
commit 0417ceb6d4
28 changed files with 807 additions and 824 deletions

View File

@@ -1,6 +1,6 @@
from fastapi import Query
from dbhelper.menu import del_menu, get_menus, insert_menu
from dbhelper.menu import del_menu, get_menus, insert_menu, put_menu
from schemas import ListAll, MenuIn, MenuRead, Response
@@ -21,3 +21,11 @@ async def menu_del(pk: int) -> Response:
if await del_menu(pk) == 0:
return Response(code=400, msg="菜单不存在")
return Response()
async def menu_put(pk: int, data: MenuIn) -> Response:
"""更新菜单"""
if await put_menu(pk, data) == 0:
return Response(code=400, msg="菜单不存在")
return Response()

View File

@@ -67,3 +67,8 @@ async def get_apis(pk: int):
AND srm.rid = (?) and m.status != 9""",
[pk],
)
async def put_menu(pk: int, data):
"""更新菜单"""
return await MenuModel.filter(id=pk).update(**data.dict())

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -3,7 +3,7 @@ from typing import Any, Callable, get_type_hints
from fastapi import Depends, routing
from controller.common import about, login
from controller.menu import menu_add, menu_arr, menu_del
from controller.menu import menu_add, menu_arr, menu_del, menu_put
from controller.role import (assigned_menu, role_add, role_arr, role_del,
role_has_menu, role_put, role_query)
from controller.user import (user_add, user_arr, user_del, user_info,
@@ -107,7 +107,9 @@ class Route(routing.APIRoute):
)
has_perm = {"dependencies": [Depends(check_permissions)]}
has_perm = {
# "dependencies": [Depends(check_permissions)]
}
routes = [
Route.post("/login", endpoint=login, tags=["公共"], summary="登录"),
@@ -157,6 +159,9 @@ routes = [
Route.delete(
"/menu/{pk}", endpoint=menu_del, tags=["菜单管理"], summary="菜单删除", **has_perm
),
Route.put(
"/menu/{pk}", endpoint=menu_put, tags=["菜单管理"], summary="菜单更新", **has_perm
),
]
__all__ = [routes]

View File

@@ -43,7 +43,7 @@ params = [
"/menu",
MenuIn( # id 1
name="系统管理",
meta={"icon": "Group"},
meta={"icon": "AppstoreOutlined"},
path="/system",
type=0,
component=None,
@@ -57,7 +57,7 @@ params = [
"/menu",
MenuIn( # id 2
name="系统设置",
meta={"icon": "setting"},
meta={"icon": "SettingOutlined"},
path="/system",
type=0,
component=None,
@@ -72,7 +72,7 @@ params = [
"/menu",
MenuIn( # id 3
name="用户管理",
meta={"icon": "User"},
meta={"icon": "TeamOutlined"},
path="/system/user",
type=1,
component="/system/user.vue",
@@ -86,7 +86,7 @@ params = [
"/menu",
MenuIn( # id 4
name="角色管理",
meta={"icon": "Role"},
meta={"icon": "UserOutlined"},
path="/system/role",
type=1,
component="/system/role.vue",
@@ -100,7 +100,7 @@ params = [
"/menu",
MenuIn( # id 5
name="菜单管理",
meta={"icon": "Menu"},
meta={"icon": "MenuOutlined"},
path="/system/menu",
type=1,
component="/system/menu.vue",
@@ -114,7 +114,7 @@ params = [
"/menu",
MenuIn( # id 6
name="关于",
meta={"icon": "Menu"},
meta={"icon": "DashboardOutlined"},
path="/setting/about",
type=1,
component="/setting/about.vue",
@@ -309,6 +309,20 @@ params = [
method="DELETE",
).dict(),
),
(
"/menu",
MenuIn(
name="修改菜单",
meta={"icon": "Update"},
path=None,
type=2,
component=None,
pid=5,
identifier="menu:update",
api="/menu/{pk}",
method="PUT",
).dict(),
),
# 分配权限
(
"/role/assigned/menu",