Add query users by department ID (#175)

* Add query users by department ID

* fix dept parent id schema field

* fix dept get all select

* update the test sql
This commit is contained in:
Wu Clan
2023-07-09 16:39:37 +08:00
committed by GitHub
parent 865dfccf08
commit 44befcc79f
8 changed files with 39 additions and 18 deletions

View File

@ -69,7 +69,7 @@ class CRUDUser(CRUDBase[User, CreateUser, UpdateUser]):
)
return user.rowcount
async def get_all(self, username: str = None, phone: str = None, status: int = None) -> Select:
async def get_all(self, dept: int = None, username: str = None, phone: str = None, status: int = None) -> Select:
se = (
select(self.model)
.options(selectinload(self.model.dept))
@ -77,6 +77,8 @@ class CRUDUser(CRUDBase[User, CreateUser, UpdateUser]):
.order_by(desc(self.model.join_time))
)
where_list = []
if dept:
where_list.append(self.model.dept_id == dept)
if username:
where_list.append(self.model.username.like(f'%{username}%'))
if phone: