Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
sun
Commits
11671c3b
Commit
11671c3b
authored
Aug 30, 2019
by
zhongshangwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
词集接口增加错误处理
parent
0ab00fc8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
9 deletions
+25
-9
tag.py
api/tag.py
+25
-9
No files found.
api/tag.py
View file @
11671c3b
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
import
json
import
json
from
utils.base
import
APIView
,
get_offset_count
from
utils.base
import
APIView
,
get_offset_count
from
utils.logger
import
error_logger
from
utils.logger
import
error_logger
from
alpha_types.venus.error
import
ERROR
class
TagListView
(
APIView
):
class
TagListView
(
APIView
):
...
@@ -48,7 +49,7 @@ class TagUpdateOrCreateView(APIView):
...
@@ -48,7 +49,7 @@ class TagUpdateOrCreateView(APIView):
return
{
'data'
:
data
}
return
{
'data'
:
data
}
def
post
(
self
,
request
):
def
post
(
self
,
request
):
id
=
request
.
POST
.
get
(
'id'
)
id
=
request
.
POST
.
get
(
'id'
)
down_tags
=
list
(
set
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
((
request
.
POST
.
get
(
'down_tags'
,
'[]'
))))))
down_tags
=
list
(
set
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
((
request
.
POST
.
get
(
'down_tags'
,
'[]'
))))))
up_tags
=
list
(
set
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
((
request
.
POST
.
get
(
'up_tags'
,
'[]'
))))))
up_tags
=
list
(
set
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
((
request
.
POST
.
get
(
'up_tags'
,
'[]'
))))))
...
@@ -273,8 +274,9 @@ class TagSetDeleteView(APIView):
...
@@ -273,8 +274,9 @@ class TagSetDeleteView(APIView):
error_logger
.
error
(
u'删除词集失败
%
s'
,
e
)
error_logger
.
error
(
u'删除词集失败
%
s'
,
e
)
raise
raise
return
{
return
{
"status"
:
1
"message"
:
"删除成功"
,
}
"code"
:
200
}
class
TagSetUpdateOrCreateView
(
APIView
):
class
TagSetUpdateOrCreateView
(
APIView
):
...
@@ -288,17 +290,31 @@ class TagSetUpdateOrCreateView(APIView):
...
@@ -288,17 +290,31 @@ class TagSetUpdateOrCreateView(APIView):
try
:
try
:
data
=
self
.
rpc
[
'venus/sun/tag_set/update'
](
tag_set_id
=
tag_set_id
,
name
=
name
,
tag_ids
=
tag_ids
)
.
unwrap
()
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
:
except
Exception
as
e
:
error_logger
.
error
(
u'更新词集失败
%
s'
,
e
)
if
e
.
error
==
ERROR
.
TAG_SET_HAD_EXIST
:
raise
return
{
'message'
:
e
.
message
,
'code'
:
500
}
else
:
error_logger
.
error
(
u'更新词集失败
%
s'
,
e
)
raise
return
{
return
{
"status"
:
1
"message"
:
"更新成功"
,
"code"
:
200
}
}
else
:
else
:
try
:
try
:
data
=
self
.
rpc
[
'venus/sun/tag_set/create'
](
name
=
name
,
tag_ids
=
tag_ids
)
.
unwrap
()
data
=
self
.
rpc
[
'venus/sun/tag_set/create'
](
name
=
name
,
tag_ids
=
tag_ids
)
.
unwrap
()
except
Exception
as
e
:
except
Exception
as
e
:
error_logger
.
error
(
u'创建词集失败
%
s'
,
e
)
if
e
.
error
==
ERROR
.
TAG_SET_HAD_EXIST
:
raise
return
{
'message'
:
e
.
message
,
'code'
:
500
}
else
:
error_logger
.
error
(
u'创建词集失败
%
s'
,
e
)
raise
return
{
return
{
"status"
:
1
"message"
:
"创建成功"
,
"code"
:
200
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment