#! /usr/bin/env python
# -*- coding: utf-8 -*-
# __author__ = "chenwei"
# Date: 2018/11/15

from utils.base import APIView


class TopicListView(APIView):
    def get(self, request):
        page = int(request.GET.get('page', 1))
        limit = int(request.GET.get('limit', 10))
        filter = self.handle_filter(request.GET.get('filter', ""))
        try:
            data = self.rpc['venus/community/topic/get'](offset=page, limit=limit, filters=filter).unwrap()
        except Exception as e:
            # raise e
            data = {
            'total': 200,
            'data':[
                {"id": "1", "content": '内容', 'user_name': 'alex','newly_reply': '最新回复', 'group_name': '小组名', 'update_time': '2019-09-18 23:59:59',
                 'reported_time': '2019-09-18 23:59:59', 'is_online': 1, 'is_reported': 0},
                {"id": "2", "content": '内容', 'newly_reply': '最新回复', 'group_name': '小组名', 'update_time': '2019-09-18 23:59:59',
                 'reported_time': '2019-09-18 23:59:59', 'user_name': 'alex','is_online': 0, 'is_reported': 0},
                {"id": "3", "content": '内容', 'user_name': 'alex','newly_reply': '最新回复', 'group_name': '小组名', 'update_time': '2019-09-18 23:59:59',
                 'reported_time': '2019-09-18 23:59:59', 'is_online': 1, 'is_reported': 1},
                {"id": "4", "content": '内容', 'user_name': 'alex','newly_reply': '最新回复', 'group_name': '小组名', 'update_time': '2019-09-18 23:59:59',
                 'reported_time': '2019-09-18 23:59:59', 'is_online': 1, 'is_reported': 1},
                {"id": "5", "content": '内容', 'user_name': 'alex','newly_reply': '最新回复', 'group_name': '小组名', 'update_time': '2019-09-18 23:59:59',
                 'reported_time': '2019-09-18 23:59:59', 'is_online': 0, 'is_reported': 0},
                ]
            }
        return data

