浏览代码

Fixed user search

main
Madiwka 1年前
父节点
当前提交
cd9397bfa1
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. +4
    -1
      app/db/repository/user.py

+ 4
- 1
app/db/repository/user.py 查看文件

@@ -131,7 +131,10 @@ def delete_user_data(id: int, db: Session):
def user_search_query(
db: Session, name: str = "", role: str = None, page: int = 1, per_page: int = 20
):
query = db.query(User).filter(User.Name.like(f"{name}%"))
if name == "" or name is None:
query = db.query(User)
else:
query = db.query(User).filter(User.Name.like(f"{name}%"))
if role is not None and role != "Admin":
query = query.filter(User.Role == role)
total_users = query.count()


正在加载...
取消
保存