fix: llm_list.dspy用JOIN查询返回upappid_text和providerid_text供前端code列显示
This commit is contained in:
parent
57d77dc819
commit
5c021b81cb
@ -41,12 +41,27 @@ try:
|
|||||||
count_rows = await sor.sqlExe(count_sql, filterdic)
|
count_rows = await sor.sqlExe(count_sql, filterdic)
|
||||||
total = count_rows[0]['cnt'] if count_rows else 0
|
total = count_rows[0]['cnt'] if count_rows else 0
|
||||||
|
|
||||||
# Paginated data
|
# Paginated data - JOIN with organization and upapp to get display names
|
||||||
|
# Prefix field references in WHERE clause with table alias 'l.'
|
||||||
|
join_where = ''
|
||||||
|
if where_clause:
|
||||||
|
import re
|
||||||
|
conds_text = where_clause.replace(' WHERE ', '', 1)
|
||||||
|
# Add l. prefix to field names (name, model, providerid, upappid, status)
|
||||||
|
conds_text = re.sub(r'\b(name|model|description|providerid|upappid|status|ownerid)\b', r'l.\1', conds_text)
|
||||||
|
join_where = f' WHERE {conds_text}'
|
||||||
|
|
||||||
data_sql = f"""
|
data_sql = f"""
|
||||||
select id, name, model, description, iconid, upappid, providerid,
|
select l.id, l.name, l.model, l.description, l.iconid,
|
||||||
ownerid, enabled_date, expired_date, min_balance, status
|
l.upappid, l.providerid, l.ownerid, l.enabled_date,
|
||||||
from llm{where_clause}
|
l.expired_date, l.min_balance, l.status,
|
||||||
order by model
|
u.name as upappid_text,
|
||||||
|
o.orgname as providerid_text
|
||||||
|
from llm l
|
||||||
|
left join uapi.upapp u on l.upappid = u.id
|
||||||
|
left join rbac.organization o on l.providerid = o.id
|
||||||
|
{join_where}
|
||||||
|
order by l.model
|
||||||
limit ${limit}$ offset ${offset}$
|
limit ${limit}$ offset ${offset}$
|
||||||
"""
|
"""
|
||||||
rows = await sor.sqlExe(data_sql, {**filterdic, 'limit': rows_per_page, 'offset': offset})
|
rows = await sor.sqlExe(data_sql, {**filterdic, 'limit': rows_per_page, 'offset': offset})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user