Skip to content

Commit e9ad084

Browse files
insistencegitee-org
authored andcommitted
!5 RuoYi-Vue3-FastAPI v1.0.2
Merge pull request !5 from insistence/develop
2 parents b109d5a + 2e6c648 commit e9ad084

File tree

14 files changed

+64
-22
lines changed

14 files changed

+64
-22
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
<p align="center">
22
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-d3d0a9303e11d522a06cd263f3079027715.png">
33
</p>
4-
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi-Vue3-FastAPI v1.0.1</h1>
4+
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi-Vue3-FastAPI v1.0.2</h1>
55
<h4 align="center">基于RuoYi-Vue3+FastAPI前后端分离的快速开发框架</h4>
66
<p align="center">
77
<a href="https://gitee.com/insistence2022/RuoYi-Vue3-FastAPI/stargazers"><img src="https://gitee.com/insistence2022/RuoYi-Vue3-FastAPI/badge/star.svg?theme=dark"></a>
88
<a href="https://github.com/insistence/RuoYi-Vue3-FastAPI"><img src="https://img.shields.io/github/stars/insistence/RuoYi-Vue3-FastAPI?style=social"></a>
9-
<a href="https://gitee.com/insistence2022/RuoYi-Vue3-FastAPI"><img src="https://img.shields.io/badge/RuoYiVue3FastAPI-v1.0.1-brightgreen.svg"></a>
9+
<a href="https://gitee.com/insistence2022/RuoYi-Vue3-FastAPI"><img src="https://img.shields.io/badge/RuoYiVue3FastAPI-v1.0.2-brightgreen.svg"></a>
1010
<a href="https://gitee.com/insistence2022/RuoYi-Vue3-FastAPI/blob/master/LICENSE"><img src="https://img.shields.io/github/license/mashape/apistatus.svg"></a>
1111
<img src="https://img.shields.io/badge/python-≥3.8-blue">
1212
<img src="https://img.shields.io/badge/MySQL-≥5.7-blue">
1313
</p>
1414

1515

16+
1617
## 平台简介
1718

1819
RuoYi-Vue-FastAPI是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。

ruoyi-fastapi-backend/.env.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ APP_HOST = '0.0.0.0'
1010
# 应用端口
1111
APP_PORT = 9099
1212
# 应用版本
13-
APP_VERSION= '1.0.0'
13+
APP_VERSION= '1.0.2'
1414
# 应用是否开启热重载
1515
APP_RELOAD = true
1616

ruoyi-fastapi-backend/.env.prod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ APP_HOST = '0.0.0.0'
1010
# 应用端口
1111
APP_PORT = 9099
1212
# 应用版本
13-
APP_VERSION= '1.0.0'
13+
APP_VERSION= '1.0.2'
1414
# 应用是否开启热重载
1515
APP_RELOAD = false
1616

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from fastapi import Depends
2+
from typing import Union, List
23
from module_admin.entity.vo.user_vo import CurrentUserModel
34
from module_admin.service.login_service import LoginService
45
from exceptions.exception import PermissionException
@@ -7,13 +8,52 @@
78
class CheckUserInterfaceAuth:
89
"""
910
校验当前用户是否具有相应的接口权限
11+
:param perm: 权限标识
12+
:param is_strict: 当传入的权限标识是list类型时,是否开启严格模式,开启表示会校验列表中的每一个权限标识,所有的校验结果都需要为True才会通过
1013
"""
11-
def __init__(self, perm_str: str = 'common'):
12-
self.perm_str = perm_str
14+
def __init__(self, perm: Union[str, List], is_strict: bool = False):
15+
self.perm = perm
16+
self.is_strict = is_strict
1317

1418
def __call__(self, current_user: CurrentUserModel = Depends(LoginService.get_current_user)):
1519
user_auth_list = current_user.permissions
16-
user_auth_list.append('common')
17-
if '*:*:*' in user_auth_list or self.perm_str in user_auth_list:
20+
if '*:*:*' in user_auth_list:
1821
return True
22+
if isinstance(self.perm, str):
23+
if self.perm in user_auth_list:
24+
return True
25+
if isinstance(self.perm, list):
26+
if self.is_strict:
27+
if all([perm_str in user_auth_list for perm_str in self.perm]):
28+
return True
29+
else:
30+
if any([perm_str in user_auth_list for perm_str in self.perm]):
31+
return True
1932
raise PermissionException(data="", message="该用户无此接口权限")
33+
34+
35+
class CheckRoleInterfaceAuth:
36+
"""
37+
根据角色校验当前用户是否具有相应的接口权限
38+
:param role_key: 角色标识
39+
:param is_strict: 当传入的角色标识是list类型时,是否开启严格模式,开启表示会校验列表中的每一个角色标识,所有的校验结果都需要为True才会通过
40+
"""
41+
def __init__(self, role_key: Union[str, List], is_strict: bool = False):
42+
self.role_key = role_key
43+
self.is_strict = is_strict
44+
45+
def __call__(self, current_user: CurrentUserModel = Depends(LoginService.get_current_user)):
46+
user_role_list = current_user.user.role
47+
user_role_key_list = [role.role_key for role in user_role_list]
48+
if isinstance(self.role_key, str):
49+
if self.role_key in user_role_key_list:
50+
return True
51+
if isinstance(self.role_key, list):
52+
if self.is_strict:
53+
if all([role_key_str in user_role_key_list for role_key_str in self.role_key]):
54+
return True
55+
else:
56+
if any([role_key_str in user_role_key_list for role_key_str in self.role_key]):
57+
return True
58+
raise PermissionException(data="", message="该用户无此接口权限")
59+

ruoyi-fastapi-backend/module_admin/controller/config_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async def edit_system_config(request: Request, edit_config: ConfigModel, query_d
6262
return ResponseUtil.error(msg=str(e))
6363

6464

65-
@configController.delete("/refreshCache", dependencies=[Depends(CheckUserInterfaceAuth('system:config:edit'))])
65+
@configController.delete("/refreshCache", dependencies=[Depends(CheckUserInterfaceAuth('system:config:remove'))])
6666
@log_decorator(title='参数管理', business_type=2)
6767
async def refresh_system_config(request: Request, query_db: Session = Depends(get_db)):
6868
try:

ruoyi-fastapi-backend/module_admin/controller/dept_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
deptController = APIRouter(prefix='/system/dept', dependencies=[Depends(LoginService.get_current_user)])
1414

1515

16-
@deptController.get("/list/exclude/{dept_id}", response_model=List[DeptModel], dependencies=[Depends(CheckUserInterfaceAuth('common'))])
16+
@deptController.get("/list/exclude/{dept_id}", response_model=List[DeptModel], dependencies=[Depends(CheckUserInterfaceAuth('system:dept:list'))])
1717
async def get_system_dept_tree_for_edit_option(request: Request, dept_id: int, query_db: Session = Depends(get_db), data_scope_sql: str = Depends(GetDataScope('SysDept'))):
1818
try:
1919
dept_query = DeptModel(deptId=dept_id)

ruoyi-fastapi-backend/module_admin/controller/dict_controller.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async def edit_system_dict_type(request: Request, edit_dict_type: DictTypeModel,
6262
return ResponseUtil.error(msg=str(e))
6363

6464

65-
@dictController.delete("/type/refreshCache", dependencies=[Depends(CheckUserInterfaceAuth('system:dict:edit'))])
65+
@dictController.delete("/type/refreshCache", dependencies=[Depends(CheckUserInterfaceAuth('system:dict:remove'))])
6666
@log_decorator(title='字典管理', business_type=2)
6767
async def refresh_system_dict(request: Request, query_db: Session = Depends(get_db)):
6868
try:
@@ -95,7 +95,7 @@ async def delete_system_dict_type(request: Request, dict_ids: str, query_db: Ses
9595
return ResponseUtil.error(msg=str(e))
9696

9797

98-
@dictController.get("/type/optionselect", response_model=List[DictTypeModel], dependencies=[Depends(CheckUserInterfaceAuth('system:dict:query'))])
98+
@dictController.get("/type/optionselect", response_model=List[DictTypeModel])
9999
async def query_system_dict_type_options(request: Request, query_db: Session = Depends(get_db)):
100100
try:
101101
dict_type_query_result = DictTypeService.get_dict_type_list_services(query_db, DictTypePageQueryModel(**dict()), is_page=False)
@@ -131,7 +131,7 @@ async def export_system_dict_type_list(request: Request, dict_type_page_query: D
131131
return ResponseUtil.error(msg=str(e))
132132

133133

134-
@dictController.get("/data/type/{dict_type}", dependencies=[Depends(CheckUserInterfaceAuth('system:dict:list'))])
134+
@dictController.get("/data/type/{dict_type}")
135135
async def query_system_dict_type_data(request: Request, dict_type: str, query_db: Session = Depends(get_db)):
136136
try:
137137
# 获取全量数据

ruoyi-fastapi-backend/module_admin/controller/job_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async def edit_system_job(request: Request, edit_job: EditJobModel, query_db: Se
6363
return ResponseUtil.error(msg=str(e))
6464

6565

66-
@jobController.put("/job/changeStatus", dependencies=[Depends(CheckUserInterfaceAuth('monitor:job:edit'))])
66+
@jobController.put("/job/changeStatus", dependencies=[Depends(CheckUserInterfaceAuth('monitor:job:changeStatus'))])
6767
@log_decorator(title='定时任务管理', business_type=2)
6868
async def edit_system_job(request: Request, edit_job: EditJobModel, query_db: Session = Depends(get_db), current_user: CurrentUserModel = Depends(LoginService.get_current_user)):
6969
try:

ruoyi-fastapi-backend/module_admin/controller/log_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async def export_system_operation_log_list(request: Request, operation_log_page_
7070
return ResponseUtil.streaming(data=bytes2file_response(operation_log_export_result))
7171
except Exception as e:
7272
logger.exception(e)
73-
return response_500(data="", message=str(e))
73+
return ResponseUtil.error(msg=str(e))
7474

7575

7676
@logController.get("/logininfor/list", response_model=PageResponseModel, dependencies=[Depends(CheckUserInterfaceAuth('monitor:logininfor:list'))])

ruoyi-fastapi-backend/module_admin/controller/menu_controller.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
menuController = APIRouter(prefix='/system/menu', dependencies=[Depends(LoginService.get_current_user)])
1313

1414

15-
@menuController.get("/treeselect", dependencies=[Depends(CheckUserInterfaceAuth('common'))])
15+
@menuController.get("/treeselect")
1616
async def get_system_menu_tree(request: Request, query_db: Session = Depends(get_db), current_user: CurrentUserModel = Depends(LoginService.get_current_user)):
1717
try:
1818
menu_query_result = MenuService.get_menu_tree_services(query_db, current_user)
@@ -23,7 +23,7 @@ async def get_system_menu_tree(request: Request, query_db: Session = Depends(get
2323
return ResponseUtil.error(msg=str(e))
2424

2525

26-
@menuController.get("/roleMenuTreeselect/{role_id}", dependencies=[Depends(CheckUserInterfaceAuth('common'))])
26+
@menuController.get("/roleMenuTreeselect/{role_id}")
2727
async def get_system_role_menu_tree(request: Request, role_id: int, query_db: Session = Depends(get_db), current_user: CurrentUserModel = Depends(LoginService.get_current_user)):
2828
try:
2929
role_menu_query_result = MenuService.get_role_menu_tree_services(query_db, role_id, current_user)

0 commit comments

Comments
 (0)