Commit 74ee15dc authored by JackieZhang's avatar JackieZhang

扫脸

parent 40e13195
......@@ -5,15 +5,28 @@
from utils.base import APIView
from utils.logger import error_logger
class FaceStarEdit(APIView):
def get(self, request):
_id = request.GET.get('id')
try:
data = self.rpc['mercury/face/star/get'](_id=_id).unwrap()
except Exception as e:
error_logger.error(u'获取 %d 明星信息失败 %s ' % (_id, e))
raise
return {'data': data}
def post(self, request):
name = request.POST.get('name')
sex = request.POST.get('sex')
ordinary_image_url = request.POST.get('ordinary_image_url')
modeling_obj_url = request.POST.get('modeling_obj_url')
try:
self.rpc['mercury/face/create_star'](
name=name,
......@@ -23,6 +36,41 @@ class FaceStarEdit(APIView):
).unwrap()
except Exception as e:
raise e
return {
'message': '创建成功'
}
class StarListView(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['mercury/face/star/list'](offset=(page-1) * limit, limit=limit, filters=filter).unwrap()
except Exception as e:
error_logger.error(u'获取明星列表失败 %s', e)
raise
return data
def post(self, request):
ids = request.POST.get('ids', '').split()
tp = request.POST.get('type', '')
updates = {}
if tp == 'offline':
updates['is_online'] = 0
else:
updates['is_online'] = 1
try:
self.rpc['mercury/face/star/update'](ids, **updates).unwrap()
except Exception as e:
error_logger.error(u'批量更新明星列表失败 %s', e)
raise
return {
"message": "更新成功"
}
......@@ -87,7 +87,10 @@ urlpatterns = [
url(r'^tag/create$', TagUpdateOrCreateView.as_view()),
url(r'^tag/detail$', TagUpdateOrCreateView.as_view()),
url(r'^face/star/create', FaceStarEdit.as_view()),
url(r'^face/star/create$', FaceStarEdit.as_view()),
url(r'^face/star/list$', StarListView.as_view()),
url(r'^face/star/list/update$', StarListView.as_view()),
url(r'^face/star/detail$', FaceStarEdit.as_view()),
]
search_urlpatterns = [
......
......@@ -7,3 +7,28 @@ export function faceStarCreate(data) {
data
})
}
export function fetchList(query) {
return request({
url: '/api/face/star/list',
method: 'get',
params: query
})
}
export function OffLineOrOnLine(data) {
console.log(data)
return request({
url: '/api/face/list/update',
method: 'post',
data
})
}
export function fetchPushDetail(id) {
return request({
url: '/api/face/star/detail',
method: 'get',
params: { id }
})
}
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