@@ -23,9 +23,10 @@ from message.models import UserMessageInfo  | 
            ||
| 23 | 23 | 
                from utils.error.errno_utils import GroupPhotoStatusCode, GroupStatusCode, GroupUserStatusCode, UserStatusCode  | 
            
| 24 | 24 | 
                from utils.error.response_utils import response  | 
            
| 25 | 25 | 
                from utils.page_utils import pagination  | 
            
| 26 | 
                -from utils.redis.rgroup import (del_group_photo_thumbup_flag, get_group_info, get_group_photo_data,  | 
            |
| 27 | 
                - get_group_photo_thumbup_flag, get_group_users_info, set_group_info,  | 
            |
| 28 | 
                - set_group_photo_data, set_group_photo_thumbup_flag, set_group_users_info)  | 
            |
| 26 | 
                +from utils.redis.rgroup import (del_group_photo_thumbup_flag, get_group_info, get_group_photo_comment_list,  | 
            |
| 27 | 
                + get_group_photo_data, get_group_photo_thumbup_flag, get_group_photo_thumbup_list,  | 
            |
| 28 | 
                + get_group_users_info, set_group_info, set_group_photo_data,  | 
            |
| 29 | 
                + set_group_photo_thumbup_flag, set_group_users_info)  | 
            |
| 29 | 30 | 
                from utils.redis.rkeys import (GROUP_LAST_PHOTO_PK, GROUP_USERS_APPLYING_SET, GROUP_USERS_DELETED_SET,  | 
            
| 30 | 31 | 
                GROUP_USERS_PASSED_SET, GROUP_USERS_QUIT_SET, GROUP_USERS_REFUSED_SET,  | 
            
| 31 | 32 | 
                LENSMAN_PHOTO_HAGGLE_TIMES, LENSMAN_PHOTO_PRICE)  | 
            
                @@ -683,15 +684,42 @@ def comment_submit_api(request):  | 
            ||
| 683 | 684 | 
                )  | 
            
| 684 | 685 | 
                 | 
            
| 685 | 686 | 
                # 群组照片评论列表  | 
            
| 686 | 
                - photo_comments = PhotoCommentInfo.objects.filter(  | 
            |
| 687 | 
                - photo_id=photo_id,  | 
            |
| 688 | 
                - )  | 
            |
| 687 | 
                + photo_comments = get_group_photo_comment_list(photo_id)  | 
            |
| 688 | 
                +  | 
            |
| 689 | 
                + # 群组照片点赞列表  | 
            |
| 690 | 
                + photo_thumbups = get_group_photo_thumbup_list(photo_id)  | 
            |
| 691 | 
                +  | 
            |
| 692 | 
                + # 给所有评论/点赞者发送提醒  | 
            |
| 693 | 
                + for commenter in photo_comments:  | 
            |
| 694 | 
                + UserMessageInfo.objects.create(  | 
            |
| 695 | 
                + from_uid=user_id,  | 
            |
| 696 | 
                + from_nickname=group_user.nickname,  | 
            |
| 697 | 
                + from_avatar=group_user.avatar,  | 
            |
| 698 | 
                + to_uid=commenter['user_id'],  | 
            |
| 699 | 
                + group_id=group_photo.group_id,  | 
            |
| 700 | 
                + photo_id=group_photo.pk,  | 
            |
| 701 | 
                + msg_type=UserMessageInfo.COMMENT,  | 
            |
| 702 | 
                + msg_title=u'评论',  | 
            |
| 703 | 
                + msg_content=comment,  | 
            |
| 704 | 
                + )  | 
            |
| 705 | 
                + for thumber in photo_thumbups:  | 
            |
| 706 | 
                + UserMessageInfo.objects.create(  | 
            |
| 707 | 
                + from_uid=user_id,  | 
            |
| 708 | 
                + from_nickname=group_user.nickname,  | 
            |
| 709 | 
                + from_avatar=group_user.avatar,  | 
            |
| 710 | 
                + to_uid=thumber['user_id'],  | 
            |
| 711 | 
                + group_id=group_photo.group_id,  | 
            |
| 712 | 
                + photo_id=group_photo.pk,  | 
            |
| 713 | 
                + msg_type=UserMessageInfo.COMMENT,  | 
            |
| 714 | 
                + msg_title=u'评论',  | 
            |
| 715 | 
                + msg_content=comment,  | 
            |
| 716 | 
                + )  | 
            |
| 689 | 717 | 
                 | 
            
| 690 | 718 | 
                     return JsonResponse({
               | 
            
| 691 | 719 | 
                'status': 200,  | 
            
| 692 | 720 | 
                'message': u'评论成功',  | 
            
| 693 | 721 | 
                         'data': {
               | 
            
| 694 | 
                - 'comments': [comment.comment_info for comment in photo_comments],  | 
            |
| 722 | 
                + 'comments': photo_comments,  | 
            |
| 695 | 723 | 
                }  | 
            
| 696 | 724 | 
                })  | 
            
| 697 | 725 | 
                 | 
            
                @@ -719,7 +747,7 @@ def thumbup_submit_api(request):  | 
            ||
| 719 | 747 | 
                return response(GroupPhotoStatusCode.GROUP_PHOTO_NOT_FOUND)  | 
            
| 720 | 748 | 
                 | 
            
| 721 | 749 | 
                # user_id 是否点赞 photo_id  | 
            
| 722 | 
                - if PhotoThumbUpInfo.objects.filter(photo_id=photo_id, user_id=user_id, thumbup=True).exists():  | 
            |
| 750 | 
                + if get_group_photo_thumbup_flag(photo_id, user_id):  | 
            |
| 723 | 751 | 
                return response(GroupPhotoStatusCode.DUPLICATE_THUMB_UP)  | 
            
| 724 | 752 | 
                 | 
            
| 725 | 753 | 
                # 群组照片点赞记录创建/更新  | 
            
                @@ -756,18 +784,44 @@ def thumbup_submit_api(request):  | 
            ||
| 756 | 784 | 
                msg_content=u'点赞',  | 
            
| 757 | 785 | 
                )  | 
            
| 758 | 786 | 
                 | 
            
| 787 | 
                + # 群组照片评论列表  | 
            |
| 788 | 
                + photo_comments = get_group_photo_comment_list(photo_id)  | 
            |
| 789 | 
                +  | 
            |
| 759 | 790 | 
                # 群组照片点赞列表  | 
            
| 760 | 
                - photo_thumbups = PhotoThumbUpInfo.objects.filter(  | 
            |
| 761 | 
                - photo_id=photo_id,  | 
            |
| 762 | 
                - thumbup=True,  | 
            |
| 763 | 
                - )  | 
            |
| 791 | 
                + photo_thumbups = get_group_photo_thumbup_list(photo_id)  | 
            |
| 792 | 
                +  | 
            |
| 793 | 
                + # 给所有评论/点赞者发送提醒  | 
            |
| 794 | 
                + for commenter in photo_comments:  | 
            |
| 795 | 
                + UserMessageInfo.objects.create(  | 
            |
| 796 | 
                + from_uid=user_id,  | 
            |
| 797 | 
                + from_nickname=group_user.nickname,  | 
            |
| 798 | 
                + from_avatar=group_user.avatar,  | 
            |
| 799 | 
                + to_uid=commenter['user_id'],  | 
            |
| 800 | 
                + group_id=group_photo.group_id,  | 
            |
| 801 | 
                + photo_id=group_photo.pk,  | 
            |
| 802 | 
                + msg_type=UserMessageInfo.THUMBUP,  | 
            |
| 803 | 
                + msg_title=u'点赞',  | 
            |
| 804 | 
                + msg_content=u'点赞',  | 
            |
| 805 | 
                + )  | 
            |
| 806 | 
                + for thumber in photo_thumbups:  | 
            |
| 807 | 
                + UserMessageInfo.objects.create(  | 
            |
| 808 | 
                + from_uid=user_id,  | 
            |
| 809 | 
                + from_nickname=group_user.nickname,  | 
            |
| 810 | 
                + from_avatar=group_user.avatar,  | 
            |
| 811 | 
                + to_uid=thumber['user_id'],  | 
            |
| 812 | 
                + group_id=group_photo.group_id,  | 
            |
| 813 | 
                + photo_id=group_photo.pk,  | 
            |
| 814 | 
                + msg_type=UserMessageInfo.THUMBUP,  | 
            |
| 815 | 
                + msg_title=u'点赞',  | 
            |
| 816 | 
                + msg_content=u'点赞',  | 
            |
| 817 | 
                + )  | 
            |
| 764 | 818 | 
                 | 
            
| 765 | 819 | 
                     return JsonResponse({
               | 
            
| 766 | 820 | 
                'status': 200,  | 
            
| 767 | 821 | 
                'message': u'点赞提交成功',  | 
            
| 768 | 822 | 
                         'data': {
               | 
            
| 769 | 823 | 
                'thumbup': True,  | 
            
| 770 | 
                - 'thumbups': [thumbup.thumbup_info for thumbup in photo_thumbups],  | 
            |
| 824 | 
                + 'thumbups': photo_thumbups,  | 
            |
| 771 | 825 | 
                }  | 
            
| 772 | 826 | 
                })  | 
            
| 773 | 827 | 
                 | 
            
                @@ -782,21 +836,12 @@ def thumbup_list_api(request):  | 
            ||
| 782 | 836 | 
                     user_id = request.POST.get('user_id', '')
               | 
            
| 783 | 837 | 
                     photo_id = request.POST.get('photo_id', '')
               | 
            
| 784 | 838 | 
                 | 
            
| 785 | 
                - # user_id 是否点赞 photo_id  | 
            |
| 786 | 
                - thumbup = PhotoThumbUpInfo.objects.filter(photo_id=photo_id, user_id=user_id, thumbup=True).exists()  | 
            |
| 787 | 
                -  | 
            |
| 788 | 
                - # 群组照片点赞列表  | 
            |
| 789 | 
                - photo_thumbups = PhotoThumbUpInfo.objects.filter(  | 
            |
| 790 | 
                - photo_id=photo_id,  | 
            |
| 791 | 
                - thumbup=True,  | 
            |
| 792 | 
                - )  | 
            |
| 793 | 
                -  | 
            |
| 794 | 839 | 
                     return JsonResponse({
               | 
            
| 795 | 840 | 
                'status': 200,  | 
            
| 796 | 841 | 
                'message': u'获取点赞列表成功',  | 
            
| 797 | 842 | 
                         'data': {
               | 
            
| 798 | 
                - 'thumbup': thumbup,  | 
            |
| 799 | 
                - 'thumbups': [thumbup.thumbup_info for thumbup in photo_thumbups],  | 
            |
| 843 | 
                + 'thumbup': get_group_photo_thumbup_flag(photo_id, user_id), # user_id 是否点赞 photo_id  | 
            |
| 844 | 
                + 'thumbups': get_group_photo_thumbup_list(photo_id), # 群组照片点赞列表  | 
            |
| 800 | 845 | 
                }  | 
            
| 801 | 846 | 
                })  | 
            
| 802 | 847 | 
                 | 
            
                @@ -824,7 +869,7 @@ def thumbup_cancel_api(request):  | 
            ||
| 824 | 869 | 
                return response(GroupPhotoStatusCode.GROUP_PHOTO_NOT_FOUND)  | 
            
| 825 | 870 | 
                 | 
            
| 826 | 871 | 
                # user_id 是否点赞 photo_id  | 
            
| 827 | 
                - if not PhotoThumbUpInfo.objects.filter(photo_id=photo_id, user_id=user_id, thumbup=True).exists():  | 
            |
| 872 | 
                + if not get_group_photo_thumbup_flag(photo_id, user_id):  | 
            |
| 828 | 873 | 
                return response(GroupPhotoStatusCode.THUMB_UP_NOT_FOUND)  | 
            
| 829 | 874 | 
                 | 
            
| 830 | 875 | 
                # 群组照片点赞取消  | 
            
                @@ -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 | 
                # 摄影师照片相关  |