|
@@ -104,7 +104,7 @@ async def getRouters(request: Request, db: Session = Depends(get_db),
|
|
|
children=[] # 初始化 children 列表,即使没有子菜单
|
|
|
)
|
|
|
# 如果菜单有子菜单,则递归构建子菜单
|
|
|
- if menu.menu_type == 'M': # 假设 'M' 表示目录类型
|
|
|
+ if menu.menu_type == 'D' or menu.menu_type == 'Z': # 假设 'M' 表示目录类型
|
|
|
query = db.query(SysMenuLayer)
|
|
|
query = query.filter_by(parent_id=menu.menu_id)
|
|
|
query = query.filter(SysMenuLayer.del_flag != '2')
|
|
@@ -125,6 +125,7 @@ async def getRouters(request: Request, db: Session = Depends(get_db),
|
|
|
routers_dict = []
|
|
|
for router in routers:
|
|
|
router_info = router.dict()
|
|
|
+ print(router_info)
|
|
|
if len(router_info['children'])==0:
|
|
|
del router_info['children']
|
|
|
del router_info['redirect']
|
|
@@ -140,6 +141,7 @@ async def getRouters(request: Request, db: Session = Depends(get_db),
|
|
|
}
|
|
|
except Exception as e:
|
|
|
# 处理异常,返回错误信息
|
|
|
+ traceback.print_exc()
|
|
|
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
|
|
|
|
@@ -157,8 +159,9 @@ async def get_list(
|
|
|
query = query.filter(SysMenuLayer.del_flag != '2')
|
|
|
if menuName:
|
|
|
query = query.filter(SysMenuLayer.menu_name.like(f'%{menuName}%'))
|
|
|
+ query = query.filter(SysMenuLayer.menu_type=='T')
|
|
|
if status:
|
|
|
- query = query.filter(SysMenuLayer.status.like(f'%{status}%'))
|
|
|
+ query = query.filter(SysMenuLayer.status==status)
|
|
|
# 应用查询
|
|
|
# menu_list = db.query(SysMenu).filter(
|
|
|
# (SysMenu.menu_name.like(f'%{menu_name}%')) ,
|
|
@@ -177,7 +180,7 @@ async def get_list(
|
|
|
"isFrame": str(menu.is_frame),
|
|
|
"isCache": str(menu.is_cache),
|
|
|
"menuType": menu.menu_type,
|
|
|
- "layer_visible": menu.layer_visible,
|
|
|
+ "layerVisible": menu.layer_visible,
|
|
|
"status": menu.status,
|
|
|
"perms": menu.perms,
|
|
|
"icon": menu.icon,
|
|
@@ -187,28 +190,11 @@ async def get_list(
|
|
|
"children": [] # 递归调用以获取子菜单
|
|
|
} for menu in menu_list]
|
|
|
|
|
|
- # 构建分页响应
|
|
|
- # pagination_info = {
|
|
|
- # "total": total_count,
|
|
|
- # "page_num": page_num,
|
|
|
- # "page_size": page_size,
|
|
|
- # "total_pages": (total_count + page_size - 1) // page_size # 计算总页数
|
|
|
- # }
|
|
|
+
|
|
|
|
|
|
return {
|
|
|
"code": 200,
|
|
|
"data": menu_list_dict,
|
|
|
- # 'pages': page_num, # 总页数
|
|
|
- # 'currentPage': page_num, # 当前页数
|
|
|
- # # 'current':current,
|
|
|
- # # 'total' : total,
|
|
|
- # 'total': total_count, # 总数据量
|
|
|
- # # 'size':size,
|
|
|
- # 'pageSize': page_size, # 页码
|
|
|
- # {
|
|
|
- # "items": menu_list_dict,
|
|
|
- # "pagination": pagination_info
|
|
|
- # },
|
|
|
"msg": "操作成功"
|
|
|
}
|
|
|
|
|
@@ -224,7 +210,7 @@ async def get_list(
|
|
|
query = db.query(SysMenuLayer)
|
|
|
query = query.filter(SysMenuLayer.del_flag != '2')
|
|
|
if menuid:
|
|
|
- query = query.filter(SysMenuLayer.menu_id.like(f'{menuid}'))
|
|
|
+ query = query.filter(SysMenuLayer.menu_id==menuid)
|
|
|
|
|
|
|
|
|
menu= query.first()
|
|
@@ -240,7 +226,7 @@ async def get_list(
|
|
|
"isFrame": str(menu.is_frame),
|
|
|
"isCache": str(menu.is_cache),
|
|
|
"menuType": menu.menu_type,
|
|
|
- "layer_visible": menu.layer_visible,
|
|
|
+ "layerVisible": menu.layer_visible,
|
|
|
"status": menu.status,
|
|
|
"perms": menu.perms,
|
|
|
"icon": menu.icon,
|
|
@@ -282,7 +268,7 @@ async def create(
|
|
|
is_frame=int(body['isFrame']),
|
|
|
is_cache=int(body['isCache']),
|
|
|
menu_type=body['menuType'],
|
|
|
- layer_visible=body['layer_visible'],
|
|
|
+ layer_visible=body['layerVisible'],
|
|
|
status=body['status'],
|
|
|
icon=body['icon'],
|
|
|
component=body['component'],
|
|
@@ -361,7 +347,7 @@ async def update(
|
|
|
if 'status' in body:
|
|
|
menu.status = body['status']
|
|
|
if 'layer_visible' in body:
|
|
|
- menu.layer_visible = body['layer_visible']
|
|
|
+ menu.layer_visible = body['layerVisible']
|
|
|
if 'layer_template' in body:
|
|
|
menu.layer_template = body['layer_template']
|
|
|
|