查看门禁设备列表接口,实现关键字模糊查询
This commit is contained in:
parent
05c8891a5a
commit
08bd15a504
@ -1,4 +1,4 @@
|
||||
from sqlalchemy import delete, select, update
|
||||
from sqlalchemy import delete, select, update, or_
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from module_admin.entity.do.door_do import Door
|
||||
from module_admin.entity.vo.door_vo import DoorModel, DoorPageQueryModel
|
||||
@ -70,10 +70,24 @@ class DoorDao:
|
||||
select(Door)
|
||||
.where(
|
||||
# Door.index_code == query_object.index_code if query_object.index_code else True,
|
||||
Door.name.like(f'%{query_object.name}%') if query_object.name else True,
|
||||
Door.install_location.like(f'%{query_object.install_location}%') if query_object.install_location else True,
|
||||
or_(
|
||||
(
|
||||
Door.name.like(f"%{query_object.key_word}%")
|
||||
if query_object.key_word
|
||||
else True
|
||||
),
|
||||
(
|
||||
Door.install_location.like(f"%{query_object.key_word}%")
|
||||
if query_object.key_word
|
||||
else True
|
||||
),
|
||||
),
|
||||
# Door.status == query_object.status if query_object.status else True,
|
||||
Door.permission == query_object.permission if query_object.permission else True,
|
||||
(
|
||||
Door.permission == query_object.permission
|
||||
if query_object.permission
|
||||
else True
|
||||
),
|
||||
)
|
||||
.order_by(Door.id)
|
||||
.distinct()
|
||||
@ -118,4 +132,3 @@ class DoorDao:
|
||||
:return:
|
||||
"""
|
||||
await db.execute(delete(Door).where(Door.id.in_([door.id])))
|
||||
|
||||
|
||||
@ -33,7 +33,8 @@ class DoorQueryModel(DoorModel):
|
||||
"""
|
||||
门禁设备不分页查询模型
|
||||
"""
|
||||
pass
|
||||
key_word : Optional[str] = Field(default=None, description='模糊查询字段')
|
||||
|
||||
|
||||
|
||||
@as_query
|
||||
|
||||
Loading…
Reference in New Issue
Block a user