Commit c5f471ff authored by 钟尚武's avatar 钟尚武

Merge branch 'shangwu/hotfix-tag-set' into 'test'

新增标签词集功能

See merge request !336
parents 26b13f65 0ab00fc8
......@@ -254,3 +254,59 @@ class SearchDefaultKeyword(APIView):
error_logger.error(u'更新搜索默认关键字失败%s', e)
raise
return data
class TagSetListView(APIView):
def get(self, request):
offset = int(request.GET.get('offset', 1))
limit = int(request.GET.get('limit', 10))
q = request.GET.get('q', "")
type_ = request.GET.get('type', "")
try:
data = self.rpc['venus/sun/tag_set/list'](offset=(offset - 1) * limit, limit=limit, q=q, type_=type_).unwrap()
except Exception as e:
error_logger.error(u'获取词集列表失败%s', e)
raise
return data
class TagSetDeleteView(APIView):
def post(self, request):
tag_set_id = request.POST.get("id")
try:
data = self.rpc['venus/sun/tag_set/delete'](tag_set_id=tag_set_id).unwrap()
except Exception as e:
error_logger.error(u'删除词集失败%s', e)
raise
return {
"status": 1
}
class TagSetUpdateOrCreateView(APIView):
def post(self, request):
tag_set_id = request.POST.get("id")
name = request.POST.get("name", "")
tag_ids = json.loads(request.POST.get("tag_ids", '[]'))
if tag_set_id:
try:
data = self.rpc['venus/sun/tag_set/update'](tag_set_id=tag_set_id, name=name, tag_ids=tag_ids).unwrap()
except Exception as e:
error_logger.error(u'更新词集失败%s', e)
raise
return {
"status": 1
}
else:
try:
data = self.rpc['venus/sun/tag_set/create'](name=name, tag_ids=tag_ids).unwrap()
except Exception as e:
error_logger.error(u'创建词集失败%s', e)
raise
return {
"status": 1
}
......@@ -110,6 +110,10 @@ urlpatterns = [
url(r'^tag/tagtype/create$', TagTypeUpdateOrCreateView.as_view()),
url(r'^tag/tagtype/detail$', TagTypeUpdateOrCreateView.as_view()),
url(r'^tag_set/list$', TagSetListView.as_view()),
url(r'^tag_set/create$', TagSetUpdateOrCreateView.as_view()),
url(r'^tag_set/delete$', TagSetDelete.as_view()),
# 扫脸相关
url(r'^face/star/create$', FaceStarEdit.as_view()),
url(r'^face/star/list$', StarListView.as_view()),
......
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