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
0b328dc2
Commit
0b328dc2
authored
Aug 02, 2019
by
yangchenglin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pictorial_reply
parent
d1646d6b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
47 deletions
+69
-47
reply.py
api/reply.py
+63
-0
topic.py
api/topic.py
+0
-44
urls.py
api/urls.py
+6
-3
No files found.
api/reply.py
0 → 100644
View file @
0b328dc2
import
json
from
utils.base
import
APIView
from
utils.logger
import
error_logger
class
ReplyUpdateOrCreateView
(
APIView
):
def
get
(
self
,
request
):
topic_id
=
request
.
GET
.
get
(
'topic_id'
)
pictorial_id
=
request
.
GET
.
get
(
'pictorial_id'
)
offset
=
int
(
request
.
GET
.
get
(
'page'
,
0
))
limit
=
int
(
request
.
GET
.
get
(
'limit'
,
10
))
filter
=
self
.
handle_filter
(
request
.
GET
.
get
(
'filter'
,
""
))
if
topic_id
:
filter
.
update
({
'topic_id'
:
topic_id
})
elif
pictorial_id
:
filter
.
update
({
'pictorial_id'
:
pictorial_id
})
try
:
data
=
self
.
rpc
[
'venus/sun/reply/list'
](
offset
=
(
offset
-
1
)
*
limit
,
limit
=
limit
,
filters
=
filter
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'回复帖子失败
%
s'
,
e
)
raise
return
data
def
post
(
self
,
request
):
reply_ids
=
json
.
loads
(
request
.
POST
.
get
(
'reply_ids'
,
[]))
try
:
self
.
rpc
[
'venus/sun/reply/batch_delete'
](
ids
=
reply_ids
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'批量更新帖子失败
%
s'
,
e
)
raise
return
{
'message'
:
'操作成功'
}
class
ReplyCreate
(
APIView
):
def
post
(
self
,
request
):
request
.
POST
.
get
(
'be_replied_id'
,
None
)
data
=
{
'user_id'
:
request
.
POST
.
get
(
'user_id'
)
.
split
(
':'
)[
0
],
'replied_id'
:
request
.
POST
.
get
(
"replied_id"
,
None
),
'content'
:
request
.
POST
.
get
(
'content'
),
'replied_user_id'
:
request
.
POST
.
get
(
'replied_user_id'
,
None
)
}
topic_id
=
request
.
POST
.
get
(
'topic_id'
)
pictorial_id
=
request
.
POST
.
get
(
'pictorial_id'
)
if
topic_id
:
data
[
'topic_id'
]
=
topic_id
if
pictorial_id
:
data
[
'pictorial_id'
]
=
pictorial_id
try
:
data
=
self
.
rpc
[
'venus/sun/reply/edit'
](
id
=
None
,
data
=
data
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'编辑帖子失败
%
s'
,
e
)
raise
return
{
'data'
:
data
}
\ No newline at end of file
api/topic.py
View file @
0b328dc2
...
@@ -157,50 +157,6 @@ class TopicUpdateOrCreateView(APIView):
...
@@ -157,50 +157,6 @@ class TopicUpdateOrCreateView(APIView):
}
}
class
ReplyUpdateOrCreateView
(
APIView
):
def
get
(
self
,
request
):
id
=
request
.
GET
.
get
(
'id'
)
offset
=
int
(
request
.
GET
.
get
(
'page'
,
0
))
limit
=
int
(
request
.
GET
.
get
(
'limit'
,
10
))
filter
=
self
.
handle_filter
(
request
.
GET
.
get
(
'filter'
,
""
))
filter
.
update
({
'topic_id'
:
id
})
try
:
data
=
self
.
rpc
[
'venus/sun/topic/reply/list'
](
offset
=
(
offset
-
1
)
*
limit
,
limit
=
limit
,
filters
=
filter
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'回复帖子失败
%
s'
,
e
)
raise
return
data
def
post
(
self
,
request
):
reply_ids
=
json
.
loads
(
request
.
POST
.
get
(
'reply_ids'
,
[]))
try
:
self
.
rpc
[
'venus/sun/topic/reply/batch_delete'
](
ids
=
reply_ids
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'批量更新帖子失败
%
s'
,
e
)
raise
return
{
'message'
:
'操作成功'
}
class
ReplyCreate
(
APIView
):
def
post
(
self
,
request
):
request
.
POST
.
get
(
'be_replied_id'
,
None
)
data
=
{
'user_id'
:
request
.
POST
.
get
(
'user_id'
)
.
split
(
':'
)[
0
],
'replied_id'
:
request
.
POST
.
get
(
"replied_id"
,
None
),
'topic_id'
:
request
.
POST
.
get
(
"topic_id"
,
None
),
'content'
:
request
.
POST
.
get
(
'content'
),
'replied_user_id'
:
request
.
POST
.
get
(
'replied_user_id'
,
None
)
}
try
:
data
=
self
.
rpc
[
'venus/sun/topic/reply/edit'
](
id
=
None
,
data
=
data
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'编辑帖子失败
%
s'
,
e
)
raise
return
{
'data'
:
data
}
class
TopicListBatchUpdate
(
APIView
):
class
TopicListBatchUpdate
(
APIView
):
def
post
(
self
,
request
):
def
post
(
self
,
request
):
...
...
api/urls.py
View file @
0b328dc2
...
@@ -31,6 +31,7 @@ from .product import *
...
@@ -31,6 +31,7 @@ from .product import *
from
.category
import
*
from
.category
import
*
from
.classify
import
*
from
.classify
import
*
from
.effect
import
*
from
.effect
import
*
from
.reply
import
*
urlpatterns
=
[
urlpatterns
=
[
...
@@ -59,9 +60,6 @@ urlpatterns = [
...
@@ -59,9 +60,6 @@ urlpatterns = [
url
(
r'^topic/detail$'
,
TopicUpdateOrCreateView
.
as_view
()),
url
(
r'^topic/detail$'
,
TopicUpdateOrCreateView
.
as_view
()),
url
(
r'^topic/create$'
,
TopicUpdateOrCreateView
.
as_view
()),
url
(
r'^topic/create$'
,
TopicUpdateOrCreateView
.
as_view
()),
url
(
r'^topic/batch_update$'
,
TopicListBatchUpdate
.
as_view
()),
url
(
r'^topic/batch_update$'
,
TopicListBatchUpdate
.
as_view
()),
url
(
r'^topic/reply/list$'
,
ReplyUpdateOrCreateView
.
as_view
()),
url
(
r'^topic/reply/batch_delete$'
,
ReplyUpdateOrCreateView
.
as_view
()),
url
(
r'^topic/reply/create$'
,
ReplyCreate
.
as_view
()),
url
(
r'^topic/related_pictorial_info$'
,
TopicRelatePictorialInfo
.
as_view
()),
url
(
r'^topic/related_pictorial_info$'
,
TopicRelatePictorialInfo
.
as_view
()),
url
(
r'^topic/ballot$'
,
TopicBallot
.
as_view
()),
url
(
r'^topic/ballot$'
,
TopicBallot
.
as_view
()),
url
(
r'^topic/product/add$'
,
TopicProductAdd
.
as_view
()),
url
(
r'^topic/product/add$'
,
TopicProductAdd
.
as_view
()),
...
@@ -216,6 +214,11 @@ urlpatterns = [
...
@@ -216,6 +214,11 @@ urlpatterns = [
# 商品功效
# 商品功效
url
(
r'^effect/list$'
,
EffectListView
.
as_view
()),
url
(
r'^effect/list$'
,
EffectListView
.
as_view
()),
#评论相关
url
(
r'^reply/list$'
,
ReplyUpdateOrCreateView
.
as_view
()),
url
(
r'^reply/batch_delete$'
,
ReplyUpdateOrCreateView
.
as_view
()),
url
(
r'^reply/create$'
,
ReplyCreate
.
as_view
()),
]
]
search_urlpatterns
=
[
search_urlpatterns
=
[
...
...
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