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

from utils.base import APIView


class GroupSearchView(APIView):
    def get(self, request):
        name = request.GET.get('name')
        try:
            data = self.rpc['venus/community/group/search'](name=name).unwrap()
        except Exception as e:
            raise e

        return {'data': data}


class RegionSearchView(APIView):
    def get(self, request):
        name = request.GET.get('name')
        try:
            data = self.rpc['venus/community/country/search'](name=name).unwrap()
        except Exception as e:
            raise e
        return {'data': data}


class UserSearchView(APIView):
    def get(self, request):
        name = request.GET.get('name')
        try:
            data = self.rpc['venus/community/user/search'](name=name).unwrap()
        except Exception as e:
            raise e
        return {'data': data}


class TagSearchView(APIView):
    def get(self, request):
        name = request.GET.get('name')
        try:
            data = self.rpc['venus/community/tag/search'](name=name).unwrap()
        except Exception as e:
            raise e
        return {'data': data}


class StarSearchView(APIView):
    def get(self, request):
        name = request.GET.get('name')
        try:
            data = self.rpc['venus/community/star/search'](name=name).unwrap()
        except Exception as e:
            raise e
        return {'data': data}