From 2248a61936434bb3e05bf005988d1d81e4fd059d Mon Sep 17 00:00:00 2001 From: XingQue Date: Wed, 8 Jul 2026 21:47:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=B8=8D=E5=86=8D=E7=A1=AC=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E5=AE=A2=E6=9C=8D=E8=A7=92=E8=89=B2=EF=BC=8C?= =?UTF-8?q?=E6=8C=89=E6=89=80=E9=80=89=E4=BF=B1=E4=B9=90=E9=83=A8=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E5=88=86=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- backend/views/roles.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/views/roles.py b/backend/views/roles.py index a6b0da4..c2a4a42 100644 --- a/backend/views/roles.py +++ b/backend/views/roles.py @@ -870,11 +870,13 @@ class AddAdminUserView(APIView): if not isinstance(role_codes, list): return Response({'code': 400, 'msg': 'role_codes 格式错误'}) + if not role_codes: + return Response({'code': 400, 'msg': '请至少选择一个角色'}) - # 分配角色(默认客服 + 所选角色,去重;任一角色找不到则整单拒绝) + # 仅绑定前端所选角色(各俱乐部角色名不同,勿硬编码「客服」) role_names_to_bind = [] seen_names = set() - for name in (['客服'] if '客服' not in role_codes else []) + list(role_codes): + for name in role_codes: n = (name or '').strip() if n and n not in seen_names: seen_names.add(n)