Created
March 16, 2022 11:53
-
-
Save aliwo/1742a2b0bf8cddfac071234c2d059429 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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