Skip to content

Commit

Permalink
추가: 유저 좋아요 api 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
Sahayana committed Nov 8, 2023
1 parent 87cdbea commit 71ef389
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 33 deletions.
9 changes: 3 additions & 6 deletions apps/friend/services/friend_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,10 @@ def friend_like_recommend(cls, target_user_id: int) -> List[str]:
return recommend_keywords

@classmethod
def get_user_like_data(cls, user_id: int):
def get_user_like_data(cls, user_id: int) -> str:

like_sentence = []
sentence = ""
limit = slice(stop=10, step=1)
limit = slice(0, 10, 1)
youtube = Youtube.objects.filter(user_id=user_id)
news = News.objects.filter(user_id=user_id)
book = Book.objects.filter(user_id=user_id)
Expand All @@ -193,6 +192,4 @@ def get_user_like_data(cls, user_id: int):
for s in shopping[limit]:
sentence = sentence + s.title + " "

like_sentence.append(sentence)

return like_sentence
return sentence
34 changes: 7 additions & 27 deletions apps/friend/v1/apis/friend_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,30 +58,10 @@ def recommend_keywords(self, request, *args, **kwargs):

return Response(data=data, status=status.HTTP_200_OK)

# @action(detail=False, methods=["post"])
# def get_user_like(self, request, *args, **kwargs):
# user = request.user
# like_sentence = []
# sentence = ""
# youtube = Youtube.objects.filter(user_id=user.id)
# news = News.objects.filter(user_id=user.id)
# book = Book.objects.filter(user_id=user.id)
# shopping = Shopping.objects.filter(user_id=user.id)

# if youtube:
# for y in youtube:
# sentence = sentence + y.title + " "
# if news:
# for n in news:
# sentence = sentence + n.title + " "

# if book:
# for b in book:
# sentence = sentence + b.title + " "

# if shopping:
# for s in shopping:
# sentence = sentence + s.title + " "

# like_sentence.append(sentence)
# data = {"like_sentence": like_sentence}
@action(detail=False, methods=["post"])
def get_user_like(self, request, *args, **kwargs):
user = request.user
like_sentence = FriendService.get_user_like_data(user_id=user.id)
data = {"like_sentence": like_sentence}

return Response(data=data, status=status.HTTP_200_OK)

0 comments on commit 71ef389

Please sign in to comment.