return response(GroupPhotoStatusCode.GROUP_PHOTO_NOT_FOUND)
# user_id 是否点赞 photo_id
- if not PhotoThumbUpInfo.objects.filter(photo_id=photo_id, user_id=user_id, thumbup=True).exists():
+ if not get_group_photo_thumbup_flag(photo_id, user_id):
return response(GroupPhotoStatusCode.THUMB_UP_NOT_FOUND)
# 群组照片点赞取消
@@ -5,7 +5,8 @@ import json |
||
| 5 | 5 |
from django.conf import settings |
| 6 | 6 |
from django.core.serializers.json import DjangoJSONEncoder |
| 7 | 7 |
|
| 8 |
-from utils.redis.rkeys import GROUP_INFO, GROUP_PHOTO_DATA, GROUP_PHOTO_THUMB_UP, GROUP_USERS_INFO |
|
| 8 |
+from utils.redis.rkeys import (GROUP_INFO, GROUP_PHOTO_COMMENT_LIST, GROUP_PHOTO_DATA, GROUP_PHOTO_THUMB_UP, |
|
| 9 |
+ GROUP_PHOTO_THUMB_UP_LIST, GROUP_USERS_INFO) |
|
| 9 | 10 |
|
| 10 | 11 |
|
| 11 | 12 |
r = settings.REDIS_CACHE |
@@ -106,3 +107,31 @@ def get_group_photo_thumbup_flag(photo_id, user_id): |
||
| 106 | 107 |
return True |
| 107 | 108 |
else: |
| 108 | 109 |
return False |
| 110 |
+ |
|
| 111 |
+ |
|
| 112 |
+def set_group_photo_comment_list(photo_id): |
|
| 113 |
+ """ 设置群组照片用户评论列表 """ |
|
| 114 |
+ from group.models import PhotoCommentInfo |
|
| 115 |
+ photo_comments = PhotoCommentInfo.objects.filter(photo_id=photo_id) |
|
| 116 |
+ photo_comments = [comment.comment_info for comment in photo_comments] |
|
| 117 |
+ r.set(GROUP_PHOTO_COMMENT_LIST % photo_id, json.dumps(photo_comments)) |
|
| 118 |
+ return photo_comments |
|
| 119 |
+ |
|
| 120 |
+ |
|
| 121 |
+def get_group_photo_comment_list(photo_id): |
|
| 122 |
+ """ 获取群组照片用户评论列表 """ |
|
| 123 |
+ return json.loads(r.get(GROUP_PHOTO_COMMENT_LIST % photo_id) or '[]') or set_group_photo_comment_list(photo_id) |
|
| 124 |
+ |
|
| 125 |
+ |
|
| 126 |
+def set_group_photo_thumbup_list(photo_id): |
|
| 127 |
+ """ 设置群组照片用户点赞列表 """ |
|
| 128 |
+ from group.models import PhotoThumbUpInfo |
|
| 129 |
+ photo_thumbups = PhotoThumbUpInfo.objects.filter(photo_id=photo_id, thumbup=True) |
|
| 130 |
+ photo_thumbups = [thumbup.thumbup_info for thumbup in photo_thumbups] |
|
| 131 |
+ r.set(GROUP_PHOTO_THUMB_UP_LIST % photo_id, json.dumps(photo_thumbups)) |
|
| 132 |
+ return photo_thumbups |
|
| 133 |
+ |
|
| 134 |
+ |
|
| 135 |
+def get_group_photo_thumbup_list(photo_id): |
|
| 136 |
+ """ 获取群组照片用户点赞列表 """ |
|
| 137 |
+ return json.loads(r.get(GROUP_PHOTO_THUMB_UP_LIST % photo_id) or '[]') or set_group_photo_thumbup_list(photo_id) |
@@ -17,6 +17,8 @@ GROUP_USERS_QUIT_SET = 'group:users:quit:set:%s' # SET,群组用户退出集 |
||
| 17 | 17 |
# 群组照片相关 |
| 18 | 18 |
GROUP_PHOTO_DATA = 'group:photo:data:%s' # STRING,群组数据记录,photo_id |
| 19 | 19 |
GROUP_PHOTO_THUMB_UP = 'group:photo:thumb:up:%s:%s' # STRING,群组照片用户点赞记录,photo_id、user_id |
| 20 |
+GROUP_PHOTO_COMMENT_LIST = 'group:photo:comment:list:%s' # STRING,群组照片用户评论列表,photo_id |
|
| 21 |
+GROUP_PHOTO_THUMB_UP_LIST = 'group:photo:thumb:up:list:%s' # STRING,群组照片用户点赞列表,photo_id |
|
| 20 | 22 |
GROUP_LAST_PHOTO_PK = 'group:last:photo:pk:%s' # STRING,群组最后一张照片PK,group_id |
| 21 | 23 |
|
| 22 | 24 |
# 摄影师照片相关 |