Commit af62df78 authored by 王浩's avatar 王浩

Merge branch 'haow/dev' into 'dev'

add activity word parent beauty api

See merge request alpha/sun!202
parents a63d42f3 1397beca
import json
from utils.base import APIView, get_offset_count
from utils.logger import error_logger
class ActivityListView(APIView):
def get(self, request):
offset, count = get_offset_count(request)
name = request.GET.get('name', None)
is_online = request.GET.get('is_online', None)
data = self.rpc['venus/sun/activity/list'](offset=offset, count=count, name=name, is_online=is_online).unwrap()
return data
class ActivityCreateView(APIView):
def post(self, request):
name = request.POST.get('name', None)
un_join_url = request.POST.get('un_join_url', None)
in_join_url = request.POST.get('in_join_url', None)
agreement_url = request.POST.get('agreement_url', None)
if not name:
return r'缺少参数'
data = self.rpc['venus/sun/activity/add'](name=name, un_join_url=un_join_url, in_join_url=in_join_url, agreement_url=agreement_url).unwrap()
return data
class ActivityUpdateView(APIView):
def post(self, request):
id_ = request.POST.get('id', None)
name = request.POST.get('name', None)
un_join_url = request.POST.get('un_join_url', None)
in_join_url = request.POST.get('in_join_url', None)
agreement_url = request.POST.get('agreement_url', None)
rank = request.POST.get('rank', None)
if not id_:
return r'缺少参数'
data = self.rpc['venus/sun/activity/edit'](id_=id_, name=name, un_join_url=un_join_url, in_join_url=in_join_url, agreement_url=agreement_url, rank=rank).unwrap()
if not data:
return r'更新失败'
return data
class ActivityDeleteView(APIView):
def post(self, request):
id_ = request.POST.get('id', None)
if not id_:
return r'缺少参数'
data = self.rpc['venus/sun/activity/delete'](id_=id_).unwrap()
if not data:
return r'操作失败'
return data
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)
parent_word_id = request.GET.get('parent_word_id', None)
is_online = request.GET.get('is_online', None)
data = self.rpc['venus/sun/beauty/list'](offset=offset, count=count, parent_word_id=parent_word_id, is_online=is_online).unwrap()
return data
class BeautyCreateView(APIView):
def post(self, request):
url = request.POST.get('url', None)
parent_word_id = request.POST.get('parent_word_id', None)
if not url or not parent_word_id:
return r'缺少参数'
data = self.rpc['venus/sun/beauty/add'](url=url, parent_word_id=parent_word_id).unwrap()
return data
class BeautyUpdateView(APIView):
def post(self, request):
id_ = request.POST.get('id', None)
url = request.POST.get('url', None)
parent_word_id = request.POST.get('parent_word_id', None)
if not id_:
return r'缺少参数'
data = self.rpc['venus/sun/beauty/edit'](id_=id_, url=url, parent_word_id=parent_word_id).unwrap()
if not data:
return r'更新失败'
return data
class BeautyDeleteView(APIView):
def post(self, request):
id_ = request.POST.get('id', None)
if not id_:
return r'缺少参数'
data = self.rpc['venus/sun/beauty/delete'](id_=id_).unwrap()
if not data:
return r'操作失败'
return data
......@@ -4,7 +4,7 @@
# Date: 2018/11/17
import json
from utils.base import APIView
from utils.base import APIView, get_offset_count
from utils.logger import error_logger
......@@ -144,3 +144,57 @@ class TagRegisterUpdateView(APIView):
error_logger.error(u'配置失败')
raise
return {'msg': '更改成功'}
class TagFilterList(APIView):
def get(self, request):
filters = {}
offset, count = get_offset_count(request)
tag_name = request.GET.get('tag_name', None)
tag_id = request.GET.get('tag_id', None)
if tag_name:
filters['tag_name'] = tag_name
if tag_id and int(tag_id) > 0:
filters['tag_id'] = tag_id
data = self.rpc['venus/sun/tag/filter/list'](filters=filters, offset=offset, count=count).unwrap()
return data
class TagFilterCreate(APIView):
def post(self, request):
tag_infos = json.loads(request.POST.get('tag_infos', '[]'))
if not tag_infos:
return {'message': '参数不完整'}
for tag_info in tag_infos:
tag_name = tag_info.get('tag_name', None)
tag_id = tag_info.get('tag_id', None)
if not tag_id or not tag_name:
return {'message': '参数不完整'}
data = self.rpc['venus/sun/tag/filter/add'](tag_id=tag_id, tag_name=tag_name).unwrap()
if not data:
return {'message': '创建失败'}
return {'message': '创建成功'}
class TagFilterDelete(APIView):
def post(self, request):
ids = json.loads(request.POST.get('ids', '[]'))
if not ids:
return {'message': '参数不完整'}
for id_ in ids:
data = self.rpc['venus/sun/tag/filter/delete'](id_=id_).unwrap()
if not data:
return {'message': '操作失败'}
return {'message': '操作成功'}
......@@ -88,6 +88,9 @@ urlpatterns = [
url(r'^tag/create$', TagUpdateOrCreateView.as_view()),
url(r'^tag/detail$', TagUpdateOrCreateView.as_view()),
url(r'^tag/register_show/update$', TagRegisterUpdateView.as_view()),
url(r'^tag/filter/list$', TagFilterList.as_view()),
url(r'^tag/filter/add$', TagFilterCreate.as_view()),
url(r'^tag/filter/delete$', TagFilterDelete.as_view()),
# 标签类型相关
url(r'^tag/tagtype/list$', TagTypeListView.as_view()),
......@@ -149,6 +152,24 @@ urlpatterns = [
url(r'^tools/batch_update_topic_tag$', BatchUpdateTopicTag.as_view()),
url(r'^tools/batch_create_topic_with_ai_fashion_tag$', BatchCreateTopicWithAiFashionTag.as_view()),
# 母词
url(r'^word_parent/list$', VirtualVote.as_view()),
url(r'^word_parent/create$', VirtualVote.as_view()),
url(r'^word_parent/update$', VirtualVote.as_view()),
url(r'^word_parent/delete$', VirtualVote.as_view()),
# 美图
url(r'^beauty/list$', VirtualVote.as_view()),
url(r'^beauty/create$', VirtualVote.as_view()),
url(r'^beauty/update$', VirtualVote.as_view()),
url(r'^beauty/delete$', VirtualVote.as_view()),
# 活动
url(r'^activity/list$', VirtualVote.as_view()),
url(r'^activity/create$', VirtualVote.as_view()),
url(r'^activity/update$', VirtualVote.as_view()),
url(r'^activity/delete$', VirtualVote.as_view()),
]
search_urlpatterns = [
......
import json
from utils.base import APIView, get_offset_count
from utils.logger import error_logger
class WordParentListView(APIView):
def get(self, request):
offset, count = get_offset_count(request)
name = request.GET.get('name', None)
is_online = request.GET.get('is_online', None)
data = self.rpc['venus/sun/word_parent/list'](offset=offset, count=count, name=name, is_online=is_online).unwrap()
return data
class WordParentCreateView(APIView):
def post(self, request):
name = request.POST.get('name', None)
children_words = json.loads(request.POST.get('children_words', '[]'))
content_ad = request.POST.get('content_ad', None)
makeup_ad = request.POST.get('makeup_ad', None)
dress_ad = request.POST.get('dress_ad', None)
if not name:
return r'缺少参数'
data = self.rpc['venus/sun/word_parent/add'](name=name, children_words=children_words, content_ad=content_ad, makeup_ad=makeup_ad, dress_ad=dress_ad).unwrap()
return data
class WordParentUpdateView(APIView):
def post(self, request):
id_ = request.POST.get('id', None)
name = request.POST.get('name', None)
children_words = json.loads(request.POST.get('children_words', '[]'))
content_ad = request.POST.get('content_ad', None)
makeup_ad = request.POST.get('makeup_ad', None)
dress_ad = request.POST.get('dress_ad', None)
if not id_:
return r'缺少参数'
data = self.rpc['venus/sun/word_parent/edit'](id_=id_, name=name, children_words=children_words, content_ad=content_ad, makeup_ad=makeup_ad, dress_ad=dress_ad).unwrap()
if not data:
return r'更新失败'
return data
class WordParentDeleteView(APIView):
def post(self, request):
id_ = request.POST.get('id', None)
if not id_:
return r'缺少参数'
data = self.rpc['venus/sun/word_parent/delete'](id_=id_).unwrap()
if not data:
return r'操作失败'
return data
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment