修复pagetype列表页排序无效的问题
This commit is contained in:
parent
41650bc912
commit
0c24e60d04
@ -106,10 +106,10 @@ def delete_pg(pagetype: str, name: str) -> bool:
|
||||
return bool(isinstance(res, dict) and res.get('success'))
|
||||
|
||||
|
||||
def get_list(pagetype: str, filters: List[List[Any]] = None, fields: List[str] = None, limit: int = None):
|
||||
def get_list(pagetype: str, filters: List[List[Any]] = None, fields: List[str] = None, limit: int = None, order_by: str = None):
|
||||
"""获取记录列表,返回对象列表;失败返回空列表。"""
|
||||
pg = get_page_instance(pagetype)
|
||||
res = pg.list(filters=filters, fields=fields, limit=limit)
|
||||
res = pg.list(filters=filters, fields=fields, limit=limit, order_by=order_by)
|
||||
if not isinstance(res, dict) or not res.get('success'):
|
||||
return []
|
||||
items = res.get('data') or []
|
||||
|
||||
@ -45,7 +45,8 @@ async def get_records(
|
||||
pagetype=pagetype,
|
||||
filters=filters_list,
|
||||
fields=fields_list,
|
||||
limit=limit
|
||||
limit=limit,
|
||||
order_by=order_by
|
||||
)
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
@ -262,7 +262,8 @@ class ApiAdapter:
|
||||
|
||||
|
||||
def get_pg_list(self, pagetype: str, filters: Optional[List[List[Any]]] = None,
|
||||
fields: Optional[List[str]] = None, limit: Optional[int] = None) -> Dict[str, Any]:
|
||||
fields: Optional[List[str]] = None, limit: Optional[int] = None,
|
||||
order_by: Optional[str] = None) -> Dict[str, Any]:
|
||||
try:
|
||||
base_url = f"{self.api_url}/api/data/{pagetype}"
|
||||
params: Dict[str, str] = {}
|
||||
@ -272,6 +273,8 @@ class ApiAdapter:
|
||||
params['fields'] = json.dumps(fields, ensure_ascii=False)
|
||||
if isinstance(limit, int) and limit > 0:
|
||||
params['limit'] = str(limit)
|
||||
if order_by:
|
||||
params['order_by'] = order_by
|
||||
|
||||
# PageType 列表也应该使用 API Key 获取
|
||||
if pagetype == 'PageType':
|
||||
|
||||
@ -101,8 +101,9 @@ class Page:
|
||||
|
||||
def list(self, filters: Optional[List[List[Any]]] = None,
|
||||
fields: Optional[List[str]] = None,
|
||||
limit: Optional[int] = None) -> Dict[str, Any]:
|
||||
return self.adapter.get_pg_list(self.pagetype, filters=filters, fields=fields, limit=limit)
|
||||
limit: Optional[int] = None,
|
||||
order_by: Optional[str] = None) -> Dict[str, Any]:
|
||||
return self.adapter.get_pg_list(self.pagetype, filters=filters, fields=fields, limit=limit, order_by=order_by)
|
||||
|
||||
def create(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
||||
result = self.adapter.create_pg(self.pagetype, data)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user