Skip to content

Commit

Permalink
修复普通用户分组关联无法搜索的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
mouday committed Oct 27, 2024
1 parent 439c899 commit a22d329
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions domain_admin/api/user_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
"""
Expand Down
1 change: 1 addition & 0 deletions domain_admin/router/api_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a22d329

Please sign in to comment.