From 6b8bb0d715a1d18646be1f3cae9584a216f2caab Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Sun, 7 Jan 2024 13:37:31 +0800 Subject: [PATCH 1/7] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=A0=B9=E9=83=A8=E9=97=A8=E6=97=B6=E8=8E=B7=E5=8F=96=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E6=A0=91=E6=95=B0=E6=8D=AE=E5=BC=82=E5=B8=B8=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dash-fastapi-backend/module_admin/dao/dept_dao.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dash-fastapi-backend/module_admin/dao/dept_dao.py b/dash-fastapi-backend/module_admin/dao/dept_dao.py index 1686d09..70503d9 100644 --- a/dash-fastapi-backend/module_admin/dao/dept_dao.py +++ b/dash-fastapi-backend/module_admin/dao/dept_dao.py @@ -86,12 +86,14 @@ class DeptDao: SysDept.parent_id != dept_info.dept_id, SysDept.del_flag == 0, SysDept.status == 0, eval(data_scope_sql)) \ - .all() + .order_by(SysDept.order_num) \ + .distinct().all() dept = cls.get_dept_by_id(db, dept_info.dept_id) parent = cls.get_dept_by_id(db, dept.parent_id) - dept_result.insert(0, parent) + if parent: + dept_result.insert(-1, parent) - return list_format_datetime(list(set(dept_result))) + return list_format_datetime(sorted(set(dept_result), key=dept_result.index)) @classmethod def get_children_dept(cls, db: Session, dept_id: int): -- Gitee From df8e54ef35367086f15ec436ed9b3a4edf8a9450 Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Sun, 7 Jan 2024 13:37:31 +0800 Subject: [PATCH 2/7] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=A0=B9=E9=83=A8=E9=97=A8=E6=97=B6=E8=8E=B7=E5=8F=96=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E6=A0=91=E6=95=B0=E6=8D=AE=E5=BC=82=E5=B8=B8=E7=9A=84?= =?UTF-8?q?bug=20#I8U660?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dash-fastapi-backend/module_admin/dao/dept_dao.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dash-fastapi-backend/module_admin/dao/dept_dao.py b/dash-fastapi-backend/module_admin/dao/dept_dao.py index 1686d09..70503d9 100644 --- a/dash-fastapi-backend/module_admin/dao/dept_dao.py +++ b/dash-fastapi-backend/module_admin/dao/dept_dao.py @@ -86,12 +86,14 @@ class DeptDao: SysDept.parent_id != dept_info.dept_id, SysDept.del_flag == 0, SysDept.status == 0, eval(data_scope_sql)) \ - .all() + .order_by(SysDept.order_num) \ + .distinct().all() dept = cls.get_dept_by_id(db, dept_info.dept_id) parent = cls.get_dept_by_id(db, dept.parent_id) - dept_result.insert(0, parent) + if parent: + dept_result.insert(-1, parent) - return list_format_datetime(list(set(dept_result))) + return list_format_datetime(sorted(set(dept_result), key=dept_result.index)) @classmethod def get_children_dept(cls, db: Session, dept_id: int): -- Gitee From 0337ed64a5a1516c58576139b11b967e97279ff4 Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Sun, 7 Jan 2024 14:04:27 +0800 Subject: [PATCH 3/7] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E9=83=A8=E9=97=A8=E6=97=B6=E8=8E=B7=E5=8F=96=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E6=A0=91=E6=95=B0=E6=8D=AE=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dash-fastapi-backend/module_admin/dao/dept_dao.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/dash-fastapi-backend/module_admin/dao/dept_dao.py b/dash-fastapi-backend/module_admin/dao/dept_dao.py index 70503d9..32d85ab 100644 --- a/dash-fastapi-backend/module_admin/dao/dept_dao.py +++ b/dash-fastapi-backend/module_admin/dao/dept_dao.py @@ -88,12 +88,8 @@ class DeptDao: eval(data_scope_sql)) \ .order_by(SysDept.order_num) \ .distinct().all() - dept = cls.get_dept_by_id(db, dept_info.dept_id) - parent = cls.get_dept_by_id(db, dept.parent_id) - if parent: - dept_result.insert(-1, parent) - return list_format_datetime(sorted(set(dept_result), key=dept_result.index)) + return list_format_datetime(dept_result) @classmethod def get_children_dept(cls, db: Session, dept_id: int): -- Gitee From 94e9b47076d644c00ed3ccec2fbc16279419473c Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Sun, 7 Jan 2024 21:23:55 +0800 Subject: [PATCH 4/7] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E5=90=84?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E8=A1=A8=E5=8D=95=E6=A0=A1=E9=AA=8C=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dash-fastapi-frontend/callbacks/forget_c.py | 19 ++++++++++--------- dash-fastapi-frontend/callbacks/login_c.py | 15 ++++++++------- .../callbacks/monitor_c/job_c/job_c.py | 7 ++++--- .../callbacks/system_c/config_c.py | 9 +++++---- .../callbacks/system_c/dept_c.py | 7 ++++--- .../callbacks/system_c/dict_c/dict_c.py | 7 ++++--- .../callbacks/system_c/dict_c/dict_data_c.py | 7 ++++--- .../menu_c/components_c/button_type_c.py | 15 ++++++++------- .../menu_c/components_c/content_type_c.py | 19 ++++++++++--------- .../menu_c/components_c/menu_type_c.py | 19 ++++++++++--------- .../callbacks/system_c/notice_c.py | 11 ++++++----- .../callbacks/system_c/post_c.py | 7 ++++--- .../callbacks/system_c/role_c/role_c.py | 7 ++++--- .../callbacks/system_c/user_c/user_c.py | 13 +++++++------ dash-fastapi-frontend/utils/common.py | 7 +++++++ 15 files changed, 95 insertions(+), 74 deletions(-) create mode 100644 dash-fastapi-frontend/utils/common.py diff --git a/dash-fastapi-frontend/callbacks/forget_c.py b/dash-fastapi-frontend/callbacks/forget_c.py index 7b12a2b..9c3ac5f 100644 --- a/dash-fastapi-frontend/callbacks/forget_c.py +++ b/dash-fastapi-frontend/callbacks/forget_c.py @@ -5,6 +5,7 @@ from dash.dependencies import Input, Output, State from dash.exceptions import PreventUpdate from server import app +from utils.common import validate_data_not_empty from api.user import forget_user_pwd_api from api.message import send_message_api @@ -38,7 +39,7 @@ from api.message import send_message_api def forget_auth(nClicks, username, password, password_again, input_captcha, session_id): if nClicks: # 校验全部输入值是否不为空 - if all([username, password, password_again, input_captcha]): + if all(validate_data_not_empty(item) for item in [username, password, password_again, input_captcha]): if password == password_again: try: @@ -107,14 +108,14 @@ def forget_auth(nClicks, username, password, password_again, input_captcha, sess ) return dict( - username_form_status=None if username else 'error', - password_form_status=None if password else 'error', - password_again_form_status=None if password_again else 'error', - captcha_form_status=None if input_captcha else 'error', - username_form_help=None if username else '请输入用户名!', - password_form_help=None if password else '请输入新密码!', - password_again_form_help=None if password_again else '请再次输入新密码!', - captcha_form_help=None if input_captcha else '请输入短信验证码!', + username_form_status=None if validate_data_not_empty(username) else 'error', + password_form_status=None if validate_data_not_empty(password) else 'error', + password_again_form_status=None if validate_data_not_empty(password_again) else 'error', + captcha_form_status=None if validate_data_not_empty(input_captcha) else 'error', + username_form_help=None if validate_data_not_empty(username) else '请输入用户名!', + password_form_help=None if validate_data_not_empty(password) else '请输入新密码!', + password_again_form_help=None if validate_data_not_empty(password_again) else '请再次输入新密码!', + captcha_form_help=None if validate_data_not_empty(input_captcha) else '请输入短信验证码!', submit_loading=False, redirect_container=None, global_message_container=None diff --git a/dash-fastapi-frontend/callbacks/login_c.py b/dash-fastapi-frontend/callbacks/login_c.py index d423bd0..e3b2059 100644 --- a/dash-fastapi-frontend/callbacks/login_c.py +++ b/dash-fastapi-frontend/callbacks/login_c.py @@ -6,6 +6,7 @@ from flask import session import time from server import app +from utils.common import validate_data_not_empty from api.login import login_api, get_captcha_image_api @@ -41,7 +42,7 @@ def login_auth(nClicks, username, password, input_captcha, session_id, image_cli if captcha_hidden: input_captcha = 'hidden' # 校验全部输入值是否不为空 - if all([username, password, input_captcha]): + if all(validate_data_not_empty(item) for item in [username, password, input_captcha]): try: user_params = dict(username=username, password=password, captcha=input_captcha, session_id=session_id) @@ -95,12 +96,12 @@ def login_auth(nClicks, username, password, input_captcha, session_id, image_cli ) return dict( - username_form_status=None if username else 'error', - password_form_status=None if password else 'error', - captcha_form_status=None if input_captcha else 'error', - username_form_help=None if username else '请输入用户名!', - password_form_help=None if password else '请输入密码!', - captcha_form_help=None if input_captcha else '请输入验证码!', + username_form_status=None if validate_data_not_empty(username) else 'error', + password_form_status=None if validate_data_not_empty(password) else 'error', + captcha_form_status=None if validate_data_not_empty(input_captcha) else 'error', + username_form_help=None if validate_data_not_empty(username) else '请输入用户名!', + password_form_help=None if validate_data_not_empty(password) else '请输入密码!', + captcha_form_help=None if validate_data_not_empty(input_captcha) else '请输入验证码!', image_click=dash.no_update, submit_loading=False, token=None, diff --git a/dash-fastapi-frontend/callbacks/monitor_c/job_c/job_c.py b/dash-fastapi-frontend/callbacks/monitor_c/job_c/job_c.py index a7aa458..2421013 100644 --- a/dash-fastapi-frontend/callbacks/monitor_c/job_c/job_c.py +++ b/dash-fastapi-frontend/callbacks/monitor_c/job_c/job_c.py @@ -8,6 +8,7 @@ from dash.exceptions import PreventUpdate import feffery_utils_components as fuc from server import app +from utils.common import validate_data_not_empty from api.job import get_job_list_api, get_job_detail_api, add_job_api, edit_job_api, execute_job_api, delete_job_api, export_job_list_api from api.dict import query_dict_data_list_api @@ -334,7 +335,7 @@ def job_confirm(confirm_trigger, modal_type, edit_row_info, form_value, form_lab # 获取所有输入表单项对应的value及label form_value_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-2]} form_label_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-1]} - if all([form_value_state.get(k) for k in form_label_output_list]): + if all(validate_data_not_empty(item) for item in [form_value_state.get(k) for k in form_label_output_list]): params_add = form_value_state params_edit = params_add.copy() params_edit['job_id'] = edit_row_info.get('job_id') if edit_row_info else None @@ -374,8 +375,8 @@ def job_confirm(confirm_trigger, modal_type, edit_row_info, form_value, form_lab ) return dict( - form_label_validate_status=[None if form_value_state.get(k) else 'error' for k in form_label_output_list], - form_label_validate_info=[None if form_value_state.get(k) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], + form_label_validate_status=[None if validate_data_not_empty(form_value_state.get(k)) else 'error' for k in form_label_output_list], + form_label_validate_info=[None if validate_data_not_empty(form_value_state.get(k)) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], modal_visible=dash.no_update, operations=dash.no_update, api_check_token_trigger=dash.no_update, diff --git a/dash-fastapi-frontend/callbacks/system_c/config_c.py b/dash-fastapi-frontend/callbacks/system_c/config_c.py index b133059..99a25ac 100644 --- a/dash-fastapi-frontend/callbacks/system_c/config_c.py +++ b/dash-fastapi-frontend/callbacks/system_c/config_c.py @@ -7,6 +7,7 @@ from dash.exceptions import PreventUpdate import feffery_utils_components as fuc from server import app +from utils.common import validate_data_not_empty from api.config import get_config_list_api, get_config_detail_api, add_config_api, edit_config_api, delete_config_api, export_config_list_api, refresh_config_api @@ -297,7 +298,7 @@ def add_edit_config_modal(operation_click, button_click, selected_row_keys, clic ), prevent_initial_call=True ) -def dict_type_confirm(confirm_trigger, modal_type, edit_row_info, form_value, form_label): +def config_confirm(confirm_trigger, modal_type, edit_row_info, form_value, form_label): """ 新增或编辑参数设置弹窗确认回调,实现新增或编辑操作 """ @@ -307,7 +308,7 @@ def dict_type_confirm(confirm_trigger, modal_type, edit_row_info, form_value, fo # 获取所有输入表单项对应的value及label form_value_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-2]} form_label_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-1]} - if all([form_value_state.get(k) for k in form_label_output_list]): + if all(validate_data_not_empty(item) for item in [form_value_state.get(k) for k in form_label_output_list]): params_add = form_value_state params_edit = params_add.copy() params_edit['config_id'] = edit_row_info.get('config_id') if edit_row_info else None @@ -347,8 +348,8 @@ def dict_type_confirm(confirm_trigger, modal_type, edit_row_info, form_value, fo ) return dict( - form_label_validate_status=[None if form_value_state.get(k) else 'error' for k in form_label_output_list], - form_label_validate_info=[None if form_value_state.get(k) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], + form_label_validate_status=[None if validate_data_not_empty(form_value_state.get(k)) else 'error' for k in form_label_output_list], + form_label_validate_info=[None if validate_data_not_empty(form_value_state.get(k)) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], modal_visible=dash.no_update, operations=dash.no_update, api_check_token_trigger=dash.no_update, diff --git a/dash-fastapi-frontend/callbacks/system_c/dept_c.py b/dash-fastapi-frontend/callbacks/system_c/dept_c.py index 57eb787..877f587 100644 --- a/dash-fastapi-frontend/callbacks/system_c/dept_c.py +++ b/dash-fastapi-frontend/callbacks/system_c/dept_c.py @@ -6,6 +6,7 @@ from dash.exceptions import PreventUpdate import feffery_utils_components as fuc from server import app +from utils.common import validate_data_not_empty from utils.tree_tool import list_to_tree from api.dept import get_dept_tree_api, get_dept_list_api, add_dept_api, edit_dept_api, delete_dept_api, \ get_dept_detail_api, get_dept_tree_for_edit_option_api @@ -304,7 +305,7 @@ def dept_confirm(confirm_trigger, modal_type, edit_row_info, form_value, form_la # 获取所有输入表单项对应的value及label form_value_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-2]} form_label_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-1]} - if all([form_value_state.get(k) for k in form_label_output_list]): + if all(validate_data_not_empty(item) for item in [form_value_state.get(k) for k in form_label_output_list]): params_add = form_value_state params_edit = params_add.copy() params_edit['dept_id'] = edit_row_info.get('dept_id') if edit_row_info else None @@ -344,8 +345,8 @@ def dept_confirm(confirm_trigger, modal_type, edit_row_info, form_value, form_la ) return dict( - form_label_validate_status=[None if form_value_state.get(k) else 'error' for k in form_label_output_list], - form_label_validate_info=[None if form_value_state.get(k) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], + form_label_validate_status=[None if validate_data_not_empty(form_value_state.get(k)) else 'error' for k in form_label_output_list], + form_label_validate_info=[None if validate_data_not_empty(form_value_state.get(k)) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], modal_visible=dash.no_update, operations=dash.no_update, api_check_token_trigger=dash.no_update, diff --git a/dash-fastapi-frontend/callbacks/system_c/dict_c/dict_c.py b/dash-fastapi-frontend/callbacks/system_c/dict_c/dict_c.py index b557feb..a4698f1 100644 --- a/dash-fastapi-frontend/callbacks/system_c/dict_c/dict_c.py +++ b/dash-fastapi-frontend/callbacks/system_c/dict_c/dict_c.py @@ -7,6 +7,7 @@ from dash.exceptions import PreventUpdate import feffery_utils_components as fuc from server import app +from utils.common import validate_data_not_empty from api.dict import get_dict_type_list_api, get_all_dict_type_api, get_dict_type_detail_api, add_dict_type_api, edit_dict_type_api, delete_dict_type_api, export_dict_type_list_api, refresh_dict_api @@ -311,7 +312,7 @@ def dict_type_confirm(confirm_trigger, modal_type, edit_row_info, form_value, fo # 获取所有输入表单项对应的value及label form_value_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-2]} form_label_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-1]} - if all([form_value_state.get(k) for k in form_label_output_list]): + if all(validate_data_not_empty(item) for item in [form_value_state.get(k) for k in form_label_output_list]): params_add = form_value_state params_edit = params_add.copy() params_edit['dict_id'] = edit_row_info.get('dict_id') if edit_row_info else None @@ -351,8 +352,8 @@ def dict_type_confirm(confirm_trigger, modal_type, edit_row_info, form_value, fo ) return dict( - form_label_validate_status=[None if form_value_state.get(k) else 'error' for k in form_label_output_list], - form_label_validate_info=[None if form_value_state.get(k) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], + form_label_validate_status=[None if validate_data_not_empty(form_value_state.get(k)) else 'error' for k in form_label_output_list], + form_label_validate_info=[None if validate_data_not_empty(form_value_state.get(k)) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], modal_visible=dash.no_update, operations=dash.no_update, api_check_token_trigger=dash.no_update, diff --git a/dash-fastapi-frontend/callbacks/system_c/dict_c/dict_data_c.py b/dash-fastapi-frontend/callbacks/system_c/dict_c/dict_data_c.py index 795cf07..cf4ae9d 100644 --- a/dash-fastapi-frontend/callbacks/system_c/dict_c/dict_data_c.py +++ b/dash-fastapi-frontend/callbacks/system_c/dict_c/dict_data_c.py @@ -7,6 +7,7 @@ from dash.exceptions import PreventUpdate import feffery_utils_components as fuc from server import app +from utils.common import validate_data_not_empty from api.dict import get_dict_data_list_api, get_dict_data_detail_api, add_dict_data_api, edit_dict_data_api, delete_dict_data_api, export_dict_data_list_api @@ -306,7 +307,7 @@ def dict_data_confirm(confirm_trigger, modal_type, edit_row_info, form_value, fo # 获取所有输入表单项对应的value及label form_value_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-2]} form_label_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-1]} - if all([form_value_state.get(k) for k in form_label_output_list]): + if all(validate_data_not_empty(item) for item in [form_value_state.get(k) for k in form_label_output_list]): params_add = form_value_state params_edit = params_add.copy() params_edit['dict_code'] = edit_row_info.get('dict_code') if edit_row_info else None @@ -346,8 +347,8 @@ def dict_data_confirm(confirm_trigger, modal_type, edit_row_info, form_value, fo ) return dict( - form_label_validate_status=[None if form_value_state.get(k) else 'error' for k in form_label_output_list], - form_label_validate_info=[None if form_value_state.get(k) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], + form_label_validate_status=[None if validate_data_not_empty(form_value_state.get(k)) else 'error' for k in form_label_output_list], + form_label_validate_info=[None if validate_data_not_empty(form_value_state.get(k)) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], modal_visible=dash.no_update, operations=dash.no_update, api_check_token_trigger=dash.no_update, diff --git a/dash-fastapi-frontend/callbacks/system_c/menu_c/components_c/button_type_c.py b/dash-fastapi-frontend/callbacks/system_c/menu_c/components_c/button_type_c.py index 7116953..a39764c 100644 --- a/dash-fastapi-frontend/callbacks/system_c/menu_c/components_c/button_type_c.py +++ b/dash-fastapi-frontend/callbacks/system_c/menu_c/components_c/button_type_c.py @@ -5,6 +5,7 @@ from dash.exceptions import PreventUpdate import feffery_utils_components as fuc from server import app +from utils.common import validate_data_not_empty from api.menu import add_menu_api, edit_menu_api @@ -43,7 +44,7 @@ def menu_confirm_button(confirm_trigger, modal_type, edit_row_info, parent_id, m 菜单类型为按钮时新增或编辑弹窗确认回调,实现新增或编辑操作 """ if confirm_trigger: - if all([parent_id, menu_name, order_num]): + if all(validate_data_not_empty(item) for item in [parent_id, menu_name, order_num]): params_add = dict(parent_id=parent_id, menu_type=menu_type, icon=icon, menu_name=menu_name, order_num=order_num, perms=perms) params_edit = dict(menu_id=edit_row_info.get('menu_id') if edit_row_info else None, parent_id=parent_id, menu_type=menu_type, icon=icon, menu_name=menu_name, order_num=order_num, perms=perms) @@ -81,12 +82,12 @@ def menu_confirm_button(confirm_trigger, modal_type, edit_row_info, parent_id, m return dict( form_validate=[ - None if parent_id else 'error', - None if menu_name else 'error', - None if order_num else 'error', - None if parent_id else '请选择上级菜单!', - None if menu_name else '请输入菜单名称!', - None if order_num else '请输入显示排序!' + None if validate_data_not_empty(parent_id) else 'error', + None if validate_data_not_empty(menu_name) else 'error', + None if validate_data_not_empty(order_num) else 'error', + None if validate_data_not_empty(parent_id) else '请选择上级菜单!', + None if validate_data_not_empty(menu_name) else '请输入菜单名称!', + None if validate_data_not_empty(order_num) else '请输入显示排序!' ], modal_visible=dash.no_update, operations=dash.no_update, diff --git a/dash-fastapi-frontend/callbacks/system_c/menu_c/components_c/content_type_c.py b/dash-fastapi-frontend/callbacks/system_c/menu_c/components_c/content_type_c.py index 967ba75..c1404ae 100644 --- a/dash-fastapi-frontend/callbacks/system_c/menu_c/components_c/content_type_c.py +++ b/dash-fastapi-frontend/callbacks/system_c/menu_c/components_c/content_type_c.py @@ -5,6 +5,7 @@ from dash.exceptions import PreventUpdate import feffery_utils_components as fuc from server import app +from utils.common import validate_data_not_empty from api.menu import add_menu_api, edit_menu_api @@ -48,7 +49,7 @@ def menu_confirm_content(confirm_trigger, modal_type, edit_row_info, parent_id, 菜单类型为目录时新增或编辑弹窗确认回调,实现新增或编辑操作 """ if confirm_trigger: - if all([parent_id, menu_name, order_num, path]): + if all(validate_data_not_empty(item) for item in [parent_id, menu_name, order_num, path]): params_add = dict(parent_id=parent_id, menu_type=menu_type, icon=icon, menu_name=menu_name, order_num=order_num, is_frame=is_frame, path=path, visible=visible, status=status) params_edit = dict(menu_id=edit_row_info.get('menu_id') if edit_row_info else None, parent_id=parent_id, menu_type=menu_type, icon=icon, @@ -87,14 +88,14 @@ def menu_confirm_content(confirm_trigger, modal_type, edit_row_info, parent_id, return dict( form_validate=[ - None if parent_id else 'error', - None if menu_name else 'error', - None if order_num else 'error', - None if path else 'error', - None if parent_id else '请选择上级菜单!', - None if menu_name else '请输入菜单名称!', - None if order_num else '请输入显示排序!', - None if path else '请输入路由地址!', + None if validate_data_not_empty(parent_id) else 'error', + None if validate_data_not_empty(menu_name) else 'error', + None if validate_data_not_empty(order_num) else 'error', + None if validate_data_not_empty(path) else 'error', + None if validate_data_not_empty(parent_id) else '请选择上级菜单!', + None if validate_data_not_empty(menu_name) else '请输入菜单名称!', + None if validate_data_not_empty(order_num) else '请输入显示排序!', + None if validate_data_not_empty(path) else '请输入路由地址!', ], modal_visible=dash.no_update, operations=dash.no_update, diff --git a/dash-fastapi-frontend/callbacks/system_c/menu_c/components_c/menu_type_c.py b/dash-fastapi-frontend/callbacks/system_c/menu_c/components_c/menu_type_c.py index 8242bb2..2fcb149 100644 --- a/dash-fastapi-frontend/callbacks/system_c/menu_c/components_c/menu_type_c.py +++ b/dash-fastapi-frontend/callbacks/system_c/menu_c/components_c/menu_type_c.py @@ -5,6 +5,7 @@ from dash.exceptions import PreventUpdate import feffery_utils_components as fuc from server import app +from utils.common import validate_data_not_empty from api.menu import add_menu_api, edit_menu_api @@ -53,7 +54,7 @@ def menu_confirm_menu(confirm_trigger, modal_type, edit_row_info, parent_id, men 菜单类型为菜单时新增或编辑弹窗确认回调,实现新增或编辑操作 """ if confirm_trigger: - if all([parent_id, menu_name, order_num, path]): + if all(validate_data_not_empty(item) for item in [parent_id, menu_name, order_num, path]): params_add = dict(parent_id=parent_id, menu_type=menu_type, icon=icon, menu_name=menu_name, order_num=order_num, is_frame=is_frame, path=path, component=component, perms=perms, query=query, is_cache=is_cache, visible=visible, status=status) params_edit = dict(menu_id=edit_row_info.get('menu_id') if edit_row_info else None, parent_id=parent_id, menu_type=menu_type, icon=icon, @@ -93,14 +94,14 @@ def menu_confirm_menu(confirm_trigger, modal_type, edit_row_info, parent_id, men return dict( form_validate=[ - None if parent_id else 'error', - None if menu_name else 'error', - None if order_num else 'error', - None if path else 'error', - None if parent_id else '请选择上级菜单!', - None if menu_name else '请输入菜单名称!', - None if order_num else '请输入显示排序!', - None if path else '请输入路由地址!' + None if validate_data_not_empty(parent_id) else 'error', + None if validate_data_not_empty(menu_name) else 'error', + None if validate_data_not_empty(order_num) else 'error', + None if validate_data_not_empty(path) else 'error', + None if validate_data_not_empty(parent_id) else '请选择上级菜单!', + None if validate_data_not_empty(menu_name) else '请输入菜单名称!', + None if validate_data_not_empty(order_num) else '请输入显示排序!', + None if validate_data_not_empty(path) else '请输入路由地址!' ], modal_visible=dash.no_update, operations=dash.no_update, diff --git a/dash-fastapi-frontend/callbacks/system_c/notice_c.py b/dash-fastapi-frontend/callbacks/system_c/notice_c.py index 79bb7d6..74b3bb9 100644 --- a/dash-fastapi-frontend/callbacks/system_c/notice_c.py +++ b/dash-fastapi-frontend/callbacks/system_c/notice_c.py @@ -7,6 +7,7 @@ from dash.exceptions import PreventUpdate import feffery_utils_components as fuc from server import app +from utils.common import validate_data_not_empty from api.notice import get_notice_list_api, add_notice_api, edit_notice_api, delete_notice_api, get_notice_detail_api from api.dict import query_dict_data_list_api @@ -340,7 +341,7 @@ def notice_confirm(confirm_trigger, modal_type, edit_row_info, notice_title, not 新增或编辑通知公告弹窗确认回调,实现新增或编辑操作 """ if confirm_trigger: - if all([notice_title, notice_type]): + if all(validate_data_not_empty(item) for item in [notice_title, notice_type]): params_add = dict(notice_title=notice_title, notice_type=notice_type, status=status, notice_content=notice_content) params_edit = dict(notice_id=edit_row_info.get('notice_id') if edit_row_info else None, @@ -388,10 +389,10 @@ def notice_confirm(confirm_trigger, modal_type, edit_row_info, notice_title, not ) return dict( - notice_title_form_status=None if notice_title else 'error', - notice_type_form_status=None if notice_type else 'error', - notice_title_form_help=None if notice_title else '请输入公告标题!', - notice_type_form_help=None if notice_type else '请输入公告类型!', + notice_title_form_status=None if validate_data_not_empty(notice_title) else 'error', + notice_type_form_status=None if validate_data_not_empty(notice_type) else 'error', + notice_title_form_help=None if validate_data_not_empty(notice_title) else '请输入公告标题!', + notice_type_form_help=None if validate_data_not_empty(notice_type) else '请输入公告类型!', modal_visible=dash.no_update, operations=dash.no_update, api_check_token_trigger=dash.no_update, diff --git a/dash-fastapi-frontend/callbacks/system_c/post_c.py b/dash-fastapi-frontend/callbacks/system_c/post_c.py index 07712ab..fa0fd27 100644 --- a/dash-fastapi-frontend/callbacks/system_c/post_c.py +++ b/dash-fastapi-frontend/callbacks/system_c/post_c.py @@ -7,6 +7,7 @@ from dash.exceptions import PreventUpdate import feffery_utils_components as fuc from server import app +from utils.common import validate_data_not_empty from api.post import get_post_list_api, get_post_detail_api, add_post_api, edit_post_api, delete_post_api, export_post_list_api @@ -295,7 +296,7 @@ def post_confirm(confirm_trigger, modal_type, edit_row_info, form_value, form_la # 获取所有输入表单项对应的value及label form_value_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-2]} form_label_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-1]} - if all([form_value_state.get(k) for k in form_label_output_list]): + if all(validate_data_not_empty(item) for item in [form_value_state.get(k) for k in form_label_output_list]): params_add = form_value_state params_edit = params_add.copy() params_edit['post_id'] = edit_row_info.get('post_id') if edit_row_info else None @@ -335,8 +336,8 @@ def post_confirm(confirm_trigger, modal_type, edit_row_info, form_value, form_la ) return dict( - form_label_validate_status=[None if form_value_state.get(k) else 'error' for k in form_label_output_list], - form_label_validate_info=[None if form_value_state.get(k) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], + form_label_validate_status=[None if validate_data_not_empty(form_value_state.get(k)) else 'error' for k in form_label_output_list], + form_label_validate_info=[None if validate_data_not_empty(form_value_state.get(k)) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], modal_visible=dash.no_update, operations=dash.no_update, api_check_token_trigger=dash.no_update, diff --git a/dash-fastapi-frontend/callbacks/system_c/role_c/role_c.py b/dash-fastapi-frontend/callbacks/system_c/role_c/role_c.py index 1d75146..11a9757 100644 --- a/dash-fastapi-frontend/callbacks/system_c/role_c/role_c.py +++ b/dash-fastapi-frontend/callbacks/system_c/role_c/role_c.py @@ -8,6 +8,7 @@ import feffery_antd_components as fac import feffery_utils_components as fuc from server import app +from utils.common import validate_data_not_empty from api.role import get_role_list_api, get_role_detail_api, add_role_api, edit_role_api, delete_role_api, export_role_list_api from api.menu import get_menu_tree_api @@ -503,7 +504,7 @@ def role_confirm(confirm_trigger, modal_type, edit_row_info, form_value, form_la # 获取所有输入表单项对应的value及label form_value_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[2]} form_label_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[3]} - if all([form_value_state.get(k) for k in form_label_output_list]): + if all(validate_data_not_empty(item) for item in [form_value_state.get(k) for k in form_label_output_list]): menu_half_checked_keys = menu_half_checked_keys if menu_half_checked_keys else [] menu_checked_keys = menu_checked_keys if menu_checked_keys else [] if parent_checked: @@ -550,8 +551,8 @@ def role_confirm(confirm_trigger, modal_type, edit_row_info, form_value, form_la ) return dict( - form_label_validate_status=[None if form_value_state.get(k) else 'error' for k in form_label_output_list], - form_label_validate_info=[None if form_value_state.get(k) else form_label_state.get(k) for k in form_label_output_list], + form_label_validate_status=[None if validate_data_not_empty(form_value_state.get(k)) else 'error' for k in form_label_output_list], + form_label_validate_info=[None if validate_data_not_empty(form_value_state.get(k)) else form_label_state.get(k) for k in form_label_output_list], modal_visible=dash.no_update, operations=dash.no_update, api_check_token_trigger=dash.no_update, diff --git a/dash-fastapi-frontend/callbacks/system_c/user_c/user_c.py b/dash-fastapi-frontend/callbacks/system_c/user_c/user_c.py index d521334..d2c6e36 100644 --- a/dash-fastapi-frontend/callbacks/system_c/user_c/user_c.py +++ b/dash-fastapi-frontend/callbacks/system_c/user_c/user_c.py @@ -7,6 +7,7 @@ from dash.exceptions import PreventUpdate import feffery_utils_components as fuc from server import app +from utils.common import validate_data_not_empty from api.dept import get_dept_tree_api from api.user import get_user_list_api, get_user_detail_api, add_user_api, edit_user_api, delete_user_api, reset_user_password_api, batch_import_user_api, download_user_import_template_api, export_user_list_api from api.role import get_role_select_option_api @@ -328,7 +329,7 @@ def usr_add_confirm(add_confirm, post, role, form_value, form_label): form_value_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-2]} form_label_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-1]} - if all([form_value_state.get(k) for k in form_label_output_list]): + if all(validate_data_not_empty(item) for item in [form_value_state.get(k) for k in form_label_output_list]): params = form_value_state params['post_id'] = ','.join(map(str, post)) if post else '' params['role_id'] = ','.join(map(str, role)) if role else '' @@ -354,8 +355,8 @@ def usr_add_confirm(add_confirm, post, role, form_value, form_label): ) return dict( - form_label_validate_status=[None if form_value_state.get(k) else 'error' for k in form_label_output_list], - form_label_validate_info=[None if form_value_state.get(k) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], + form_label_validate_status=[None if validate_data_not_empty(form_value_state.get(k)) else 'error' for k in form_label_output_list], + form_label_validate_info=[None if validate_data_not_empty(form_value_state.get(k)) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], modal_visible=dash.no_update, operations=dash.no_update, api_check_token_trigger=dash.no_update, @@ -482,7 +483,7 @@ def usr_edit_confirm(edit_confirm, edit_row_info, post, role, form_value, form_l form_value_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-2]} form_label_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-1]} - if all([form_value_state.get(k) for k in form_label_output_list]): + if all(validate_data_not_empty(item) for item in [form_value_state.get(k) for k in form_label_output_list]): params = form_value_state params['user_id'] = edit_row_info.get('user_id') if edit_row_info else None params['post_id'] = ','.join(map(str, post)) if post else '' @@ -509,8 +510,8 @@ def usr_edit_confirm(edit_confirm, edit_row_info, post, role, form_value, form_l ) return dict( - form_label_validate_status=[None if form_value_state.get(k) else 'error' for k in form_label_output_list], - form_label_validate_info=[None if form_value_state.get(k) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], + form_label_validate_status=[None if validate_data_not_empty(form_value_state.get(k)) else 'error' for k in form_label_output_list], + form_label_validate_info=[None if validate_data_not_empty(form_value_state.get(k)) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], modal_visible=dash.no_update, operations=dash.no_update, api_check_token_trigger=dash.no_update, diff --git a/dash-fastapi-frontend/utils/common.py b/dash-fastapi-frontend/utils/common.py new file mode 100644 index 0000000..dd4e84b --- /dev/null +++ b/dash-fastapi-frontend/utils/common.py @@ -0,0 +1,7 @@ +def validate_data_not_empty(input_data): + """ + 工具方法:根据输入数据校验数据是否不为None和'' + :param input_data: 输入数据 + :return: 校验结果 + """ + return input_data is not None and input_data != '' -- Gitee From 19ff14ec5c73309968789eb16b6592dd2bf379dc Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Wed, 31 Jan 2024 10:30:27 +0800 Subject: [PATCH 5/7] =?UTF-8?q?chore:=20=E6=96=B0=E7=89=88redis=E5=BA=93?= =?UTF-8?q?=E5=B7=B2=E6=94=AF=E6=8C=81=E5=BC=82=E6=AD=A5=EF=BC=8C=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2aioredis=E4=B8=BAredis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dash-fastapi-backend/config/get_redis.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/dash-fastapi-backend/config/get_redis.py b/dash-fastapi-backend/config/get_redis.py index c7bc8ec..2890d63 100644 --- a/dash-fastapi-backend/config/get_redis.py +++ b/dash-fastapi-backend/config/get_redis.py @@ -1,4 +1,5 @@ -import aioredis +from redis import asyncio as aioredis +from redis.exceptions import AuthenticationError, TimeoutError, RedisError from module_admin.service.dict_service import DictDataService from module_admin.service.config_service import ConfigService from config.env import RedisConfig @@ -27,7 +28,18 @@ class RedisUtil: encoding="utf-8", decode_responses=True ) - logger.info("redis连接成功") + try: + connection = await redis.ping() + if connection: + logger.info("redis连接成功") + else: + logger.error("redis连接失败") + except AuthenticationError as e: + logger.error(f"redis用户名或密码错误,详细错误信息:{e}") + except TimeoutError as e: + logger.error(f"redis连接超时,详细错误信息:{e}") + except RedisError as e: + logger.error(f"redis连接错误,详细错误信息:{e}") return redis @classmethod -- Gitee From 73e6d1046784a1a878708aebb16c6865f999d9c9 Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Wed, 31 Jan 2024 10:30:53 +0800 Subject: [PATCH 6/7] =?UTF-8?q?chore:=20=E8=B0=83=E6=95=B4=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E9=A1=B9=E7=9B=AE=E4=BE=9D=E8=B5=96=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 73 ++++-------------------------------------------- 1 file changed, 5 insertions(+), 68 deletions(-) diff --git a/requirements.txt b/requirements.txt index 469418a..41f8638 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,86 +1,23 @@ -aioredis==2.0.1 -anyio==3.6.2 APScheduler==3.10.4 -async-timeout==4.0.2 -bcrypt==4.0.1 -blinker==1.6.2 -Brotli==1.0.9 -certifi==2023.5.7 -cffi==1.15.1 -charset-normalizer==3.1.0 -click==8.1.3 -colorama==0.4.6 -cryptography==40.0.2 dash==2.10.2 -dash-core-components==2.0.0 -dash-html-components==2.0.0 -dash-table==5.0.0 DateTime==5.1 -decorator==5.1.1 -dnspython==2.3.0 -ecdsa==0.18.0 -email-validator==2.0.0.post2 -et-xmlfile==1.1.0 -fastapi==0.95.1 +fastapi[all]==0.95.1 feffery-antd-charts==0.0.1rc17 feffery-antd-components==0.2.11 feffery-markdown-components==0.2.10 feffery-utils-components==0.2.0b12 -Flask==2.2.5 Flask-Compress==1.13 -greenlet==2.0.2 -h11==0.14.0 -httpcore==0.17.0 -httptools==0.5.0 -httpx==0.24.0 -idna==3.4 -importlib-metadata==6.6.0 -itsdangerous==2.1.2 -Jinja2==3.1.2 jsonpath-ng==1.5.3 loguru==0.7.0 -MarkupSafe==2.1.2 -numpy==1.24.3 openpyxl==3.1.2 -orjson==3.8.12 -packaging==23.1 pandas==1.5.3 -passlib==1.7.4 -Pillow==10.0.0 -plotly==5.14.1 -ply==3.11 +passlib[bcrypt]==1.7.4 +Pillow==10.2.0 psutil==5.9.5 -pyasn1==0.5.0 -pycparser==2.21 -pydantic==1.10.7 PyMySQL==1.0.3 -python-dateutil==2.8.2 -python-dotenv==1.0.0 -python-jose==3.3.0 -python-multipart==0.0.6 -pytz==2023.3 -PyYAML==6.0 -redis==4.5.5 +python-jose[cryptography]==3.3.0 +redis==5.0.1 requests==2.30.0 -rsa==4.9 -six==1.16.0 -sniffio==1.3.0 SQLAlchemy==1.4.48 -starlette==0.26.1 -tenacity==8.2.2 -typing_extensions==4.5.0 -tzdata==2023.3 -tzlocal==5.0.1 -ua-parser==0.16.1 -ujson==5.7.0 -urllib3==2.0.2 user-agents==2.2.0 -uvicorn==0.22.0 waitress==2.1.2 -watchfiles==0.19.0 -websockets==11.0.3 -Werkzeug==2.2.3 -win32-setctime==1.1.0 -WTForms==3.0.1 -zipp==3.15.0 -zope.interface==6.0 -- Gitee From f3dc961b18b7c175d768fd7aff65535723bea12b Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Wed, 31 Jan 2024 10:31:12 +0800 Subject: [PATCH 7/7] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0README=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 108aed0..bf347a4 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@
-
+
@@ -20,6 +20,12 @@ Dash-FastAPI-Admin是一套全部开源的快速开发平台,毫无保留给
* 后端采用FastAPI、sqlalchemy、MySQL、Redis、OAuth2 & Jwt。
* 权限认证使用OAuth2 & Jwt,支持多终端认证系统。
* 支持加载动态权限菜单,多方式轻松权限控制。
+* Vue2版本:
+ - Gitte仓库地址:https://gitee.com/insistence2022/RuoYi-Vue-FastAPI
+ - GitHub仓库地址:https://github.com/insistence/RuoYi-Vue-FastAPI
+* Vue3版本:
+ - Gitte仓库地址:https://gitee.com/insistence2022/RuoYi-Vue3-FastAPI
+ - GitHub仓库地址:https://github.com/insistence/RuoYi-Vue3-FastAPI
* 特别鸣谢:[RuoYi-Vue](https://gitee.com/y_project/RuoYi-Vue) ,[feffery-antd-components](https://github.com/CNFeffery/feffery-antd-components),[feffery-utils-components](https://github.com/CNFeffery/feffery-utils-components)。
## 内置功能
--
Gitee