Commit 744236c3 authored by ZZH's avatar ZZH

fix anshiu 2023-7-31

parent eda99d09
......@@ -66,36 +66,33 @@ async def get_search_scope(cid, pid, start, end, limit, offset):
return data, total
async def query_search_scope(cid, pid, page_num, page_size,
async def query_search_scope(cid, pids, page_num, page_size,
start_time, end_time, scope_g):
"""
查询录波列表
"""
if len(pid) > 1:
mtid = await get_mtids_by_pids_dao(pid)
else:
mtid = await get_mtid_by_pid_dao(pid)
where = ""
if cid:
if len(pids) == 0:
where += f" and pe.cid={cid} "
else:
mtids = await get_mtids_by_pids_dao(pids)
if len(mtids) == 1:
where += f" and pe.mtid={mtids[0]} "
else:
where += f" and pe.mtid in {tuple(mtids)} "
if start_time:
where += f" and pt.event_datetime >= '{start_time}' "
if end_time:
where += f" and pe.create_time <= '{end_time}' "
if mtid:
if len(mtid) == 1:
where += f" and pe.mtid = {mtid['mtid']} "
else:
where += f" and pe.mtid in {tuple(mtid)} "
if scope_g:
if len(scope_g) == 1:
where += f" AND pe.scope_g = {scope_g[0]} "
else:
where += f" AND pe.scope_g in {tuple(scope_g)} "
sql = f"""
SELECT
pt.event_id doc_id,
......@@ -113,7 +110,7 @@ async def query_search_scope(cid, pid, page_num, page_size,
ORDER BY
pe.create_time DESC
LIMIT {page_num} , {page_size} """
total_sql = f"""
SELECT
count(*) total
......@@ -126,10 +123,9 @@ async def query_search_scope(cid, pid, page_num, page_size,
{where}
"""
async with MysqlUtil() as conn:
data = await conn.fetchall(sql, )
total = await conn.fetchone(total_sql)
return data, total
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment