Skip to content

Commit

Permalink
chaineye api logic change
Browse files Browse the repository at this point in the history
  • Loading branch information
guoshijiang committed Oct 3, 2022
1 parent eb73b47 commit c849959
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 56 deletions.
10 changes: 7 additions & 3 deletions api/circle/api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_arcticle_list(request):
type = params.get('type')
cat_id = params.get('cat_id', 0)
page = params.get('page', 1)
page_size = params.get('page_size', 10)
page_size = params.get('pageSize', 10)
wallet_client = ChaineyeClient()
result = wallet_client.get_arcticle_list(
type=type,
Expand All @@ -51,8 +51,12 @@ def get_arcticle_list(request):
article_list_ret = []
for item in result.articles:
arctle = Article(item)
article_list_ret.append(arctle.as_json())
return ok_json(article_list_ret)
article_list_ret.append(arctle.as_json(type))
data = {
"total": result.total,
"gds_lst": article_list_ret,
}
return ok_json(data)
else:
return error_json("get chaineye arcticle list fail", 400)

Expand Down
5 changes: 4 additions & 1 deletion api/circle/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ class Article:
def __init__(self, article):
self.article = article

def as_json(self)-> Dict[str, Any]:
def as_json(self, type)-> Dict[str, Any]:
return {
"id": self.article.id,
"title": self.article.title,
"type": type,
"image": self.article.cover,
"abstract": self.article.abstract,
"author": self.article.author,
"add_time": self.article.add_time,
"upd_time": self.article.upd_time,
Expand Down
118 changes: 66 additions & 52 deletions services/savour_rpc/chaineye_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c849959

Please sign in to comment.