diff --git a/domain_admin/api/user_api.py b/domain_admin/api/user_api.py index 4f8d436fe9..18276dfe0f 100644 --- a/domain_admin/api/user_api.py +++ b/domain_admin/api/user_api.py @@ -85,6 +85,32 @@ def update_user_password(): ).execute() +@auth_service.permission(role=RoleEnum.USER) +def get_user_list_by_name(): + """ + 精确搜索,普通用户端可用 + """ + username = request.json.get('keyword') + + query = UserModel.select().where( + UserModel.username == username + ) + total = query.count() + + lst = list(map(lambda m: model_to_dict( + model=m, + only=[ + UserModel.id, + UserModel.username, + ], + ), query)) + + return { + 'list': lst, + 'total': total + } + + @auth_service.permission(role=RoleEnum.ADMIN) def get_user_list(): """ diff --git a/domain_admin/router/api_map.py b/domain_admin/router/api_map.py index 0b51734d2a..a431d17738 100644 --- a/domain_admin/router/api_map.py +++ b/domain_admin/router/api_map.py @@ -89,6 +89,7 @@ # 用户管理 (管理员权限) '/api/getUserList': user_api.get_user_list, + '/api/getUserListByName': user_api.get_user_list_by_name, '/api/addUser': user_api.add_user, '/api/updateUserStatus': user_api.update_user_status, '/api/deleteUser': user_api.delete_user,