1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import json
from utils.base import APIView, get_offset_count
from utils.logger import error_logger
class BeautyListView(APIView):
def get(self, request):
offset, count = get_offset_count(request)
word_parent_id = request.GET.get('word_parent_id', None)
is_online = request.GET.get('is_online', None)
data = self.rpc['venus/sun/beauty/list'](offset=offset, count=count, word_parent_id=word_parent_id, is_online=is_online).unwrap()
return data
class BeautyInfoView(APIView):
def get(self, request):
id_ = request.GET.get('id')
data = self.rpc['venus/sun/beauty/get'](id_=id_).unwrap()
return data
class BeautyCreateView(APIView):
def post(self, request):
url = request.POST.get('url', None)
word_parent_id = request.POST.get('word_parent_id', None)
if not url or not word_parent_id:
return r'缺少参数'
data = self.rpc['venus/sun/beauty/add'](url=url, word_parent_id=word_parent_id).unwrap()
return data
class BeautyUpdateView(APIView):
def post(self, request):
id_ = request.POST.get('id', None)
url = request.POST.get('url', None)
word_parent_id = request.POST.get('word_parent_id', None)
if not id_:
return r'缺少参数'
data = self.rpc['venus/sun/beauty/edit'](id_=id_, url=url, word_parent_id=word_parent_id).unwrap()
if not data:
return r'更新失败'
return data
class BeautyDeleteView(APIView):
def post(self, request):
ids = json.loads(request.POST.get('ids', '[]'))
if not ids:
return r'缺少参数'
for id_ in ids:
data = self.rpc['venus/sun/beauty/delete'](id_=id_).unwrap()
if not data:
return r'操作失败'
return data