From 92f559cb4fabbf8b06755d4c05bb2937303dc2ce Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 19 Dec 2025 14:13:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20base=20userfilter=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=BD=92=E5=B1=9E=E4=BA=8E=E8=AF=A5=E9=83=A8=E9=97=A8=E5=8F=8A?= =?UTF-8?q?=E4=BB=A5=E4=B8=8B=E9=83=A8=E9=97=A8=E7=9A=84=E4=BA=BA2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/system/filters.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/system/filters.py b/apps/system/filters.py index b68d5ca..d3f10c9 100755 --- a/apps/system/filters.py +++ b/apps/system/filters.py @@ -1,6 +1,6 @@ from django_filters import rest_framework as filters from .models import Dept, User -from apps.utils.queryset import get_child_queryset_u +from apps.utils.queryset import get_child_queryset2 from rest_framework.exceptions import ParseError @@ -25,11 +25,17 @@ class UserFilterSet(filters.FilterSet): } def filter_ubelong_dept__name(self, queryset, name, value): - depts = get_child_queryset_u(Dept.objects.filter(name=value)) + try: + depts = get_child_queryset2(Dept.objects.get(name=value)) + except Exception as e: + raise ParseError(f"部门名称错误: {value} {str(e)}") return queryset.filter(belong_dept__in=depts) def filter_ubelong_dept(self, queryset, name, value): - depts = get_child_queryset_u(Dept.objects.filter(id=value)) + try: + depts = get_child_queryset2(Dept.objects.get(id=value)) + except Exception as e: + raise ParseError(f"部门ID错误: {value} {str(e)}") return queryset.filter(belong_dept__in=depts)