Explorar el Código

Fixed user search

main
Madiwka hace 1 año
padre
commit
cd9397bfa1
Se han modificado 1 ficheros con 4 adiciones y 1 borrados
  1. +4
    -1
      app/db/repository/user.py

+ 4
- 1
app/db/repository/user.py Ver fichero

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


Cargando…
Cancelar
Guardar