评论树

          # 评论信息
            _common_logic = common_logic.CommonLogic('comment')
            sql='select c.id_,c.user_id_,c.create_time_,c.content_,c.parent_id_,ua.name_ from comment as c join user_attribute as ua ' \
                'on ua.id_=c.user_id_ where moments_id_=\"%s\"'
            comment_result_list_ = _common_logic.select(sql % moments_id_)
            comment_dict = {}  # 所有评论字典集合
            if comment_result_list_:
                for comment_result_ in comment_result_list_:
                    comment_result_['child']=[]
                    comment_dict[comment_result_['id_']] = comment_result_

                    user_id_ = comment_result_.get("user_id_")
                    sql = 'select file_id_ from util_file_relevant where relevant_id_= \"%s\"'
                    user_picture_result_ = _common_logic.select(sql % user_id_)
                    file_id_ = user_picture_result_[0].get("file_id_")
                    picture_ = app_download_single(file_id_)  # 头像
                    comment_result_['picture_'] = picture_
                comment = [] # 没有子评论的评论
                for comment_result_ in comment_result_list_:
                    pid = comment_result_["parent_id_"]
                    if pid:
                        comment_dict[pid]["child"].append(comment_result_)
                    else:
                        comment.append(comment_result_)

评论按树形结构显示

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值