Skip to content

Instantly share code, notes, and snippets.

@aliwo
Created March 16, 2022 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aliwo/1742a2b0bf8cddfac071234c2d059429 to your computer and use it in GitHub Desktop.
Save aliwo/1742a2b0bf8cddfac071234c2d059429 to your computer and use it in GitHub Desktop.
class MyModel:
user_id: int = None
article_id: int = None
comment_id: int = None
def __init__(self, user_id, article_id=None, comment_id=None):
self.user_id = user_id
self.article_id = article_id
self.comment_id = comment_id
class LikeArticleRequest:
user_id: int = None
article_id: int = None
def __init__(self, user_id, article_id):
self.user_id = user_id
self.article_id = article_id
def my_like_article_view_function(client_data: LikeArticleRequest):
model = MyModel(
client_data.user_id,
article_id=client_data.article_id,
)
print(f"{model.user_id}{model.article_id}{model.comment_id}")
class LikeCommentRequest:
user_id: int = None
comment_id: int = None
def __init__(self, user_id, comment_id):
self.user_id = user_id
self.comment_id = comment_id
def my_like_comment_view_function(client_data: LikeCommentRequest):
model = MyModel(
client_data.user_id,
comment_id=client_data.comment_id,
)
print(f"{model.user_id}{model.article_id}{model.comment_id}")
my_like_article_view_function(LikeArticleRequest(1, 2))
my_like_comment_view_function(LikeCommentRequest(3, 4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment