fix db_model bug

This commit is contained in:
BryantHe 2023-06-27 03:11:22 +08:00
parent ef6713374e
commit ffeadeea51
1 changed files with 10 additions and 8 deletions

View File

@ -26,10 +26,11 @@ class BaseCrud(BaseModel):
@classmethod
def filtered_query(cls, session, filter_args=None, filter_kwargs=None) -> Query:
if filter_args:
if not filter_args:
filter_args = []
if not filter_kwargs:
filter_kwargs = {}
return session.query(cls).filter(*filter_args).filter_by(**filter_kwargs)
else:
return session.query(cls).filter().filter_by(**filter_kwargs)
# 增
@classmethod
@ -90,10 +91,11 @@ class InfoCrud(BaseModel):
@classmethod
def filtered_query(cls, session, filter_args=None, filter_kwargs=None) -> Query:
if filter_args:
if not filter_args:
filter_args = []
if not filter_kwargs:
filter_kwargs = {}
return session.query(cls).filter(*filter_args).filter_by(**filter_kwargs)
else:
return session.query(cls).filter().filter_by(**filter_kwargs)
# 增
@classmethod