update
This commit is contained in:
parent
62fe13c5e8
commit
3823af638d
@ -61,12 +61,16 @@ async def get_clothing(db: AsyncSession, clothing_id: int):
|
||||
result = await db.execute(select(Clothing).filter(Clothing.id == clothing_id))
|
||||
return result.scalars().first()
|
||||
|
||||
async def get_clothes(db: AsyncSession, skip: int = 0, limit: int = 100, user_id: int = None):
|
||||
async def get_clothes(db: AsyncSession, skip: int = 0, limit: int = 100, user_id: int = None, category_id: int = None):
|
||||
"""获取所有衣服"""
|
||||
query = select(Clothing).order_by(Clothing.create_time.desc())
|
||||
if user_id:
|
||||
query = query.filter(Clothing.user_id == user_id)
|
||||
if category_id:
|
||||
query = query.filter(Clothing.clothing_category_id == category_id)
|
||||
|
||||
result = await db.execute(
|
||||
select(Clothing)
|
||||
.filter(Clothing.user_id == user_id)
|
||||
.order_by(Clothing.create_time.desc())
|
||||
query
|
||||
.offset(skip)
|
||||
.limit(limit)
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user