feat: api visit auth
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from tortoise import connections
|
||||
|
||||
from models import MenuModel
|
||||
from schemas.menu import MenuIn
|
||||
|
||||
@@ -41,3 +43,27 @@ async def get_menu(kwargs):
|
||||
async def del_menu(mid: int):
|
||||
"""删除用户"""
|
||||
return await MenuModel.filter(id=mid).update(status=9)
|
||||
|
||||
|
||||
async def get_has_api(pk: int, api: str, method: str):
|
||||
"""获取角色接口权限 每次来查数据库"""
|
||||
db = connections.get("default")
|
||||
return await db.execute_query_dict(
|
||||
"""
|
||||
select m.api, m.method
|
||||
FROM sys_menu as m, sys_role_menu as srm WHERE m.id = srm.mid
|
||||
AND srm.rid = (?) and m.api = (?) and m.method = (?) and m.status != 9""",
|
||||
[pk, api, method],
|
||||
)
|
||||
|
||||
|
||||
async def get_apis(pk: int):
|
||||
"""返回当前角色拥有的接口权限列表"""
|
||||
db = connections.get("default")
|
||||
return await db.execute_query_dict(
|
||||
"""
|
||||
select m.api, m.method
|
||||
FROM sys_menu as m, sys_role_menu as srm WHERE m.id = srm.mid
|
||||
AND srm.rid = (?) and m.status != 9""",
|
||||
[pk],
|
||||
)
|
||||
|
@@ -11,7 +11,7 @@ async def get_role_menus(rid: int):
|
||||
db = connections.get("default")
|
||||
return await db.execute_query_dict(
|
||||
"""
|
||||
select m.id, m.name, m.meta, m.path, m.type, m.component, m.pid, m.identifier, m.regx,m.api, m.method
|
||||
select m.id, m.name, m.meta, m.path, m.type, m.component, m.pid, m.identifier
|
||||
FROM sys_menu as m, sys_role_menu WHERE m.id = sys_role_menu.mid
|
||||
AND sys_role_menu.rid = (?) AND m.`status` = 1""",
|
||||
[rid],
|
||||
|
Reference in New Issue
Block a user