瀏覽代碼

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()


Loading…
取消
儲存