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
48082baf
Commit
48082baf
authored
Aug 06, 2019
by
yangchenglin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conflict
parent
ea2b8254
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
99 additions
and
0 deletions
+99
-0
reply.py
api/reply.py
+94
-0
urls.py
api/urls.py
+5
-0
No files found.
api/reply.py
View file @
48082baf
import
json
from
utils.base
import
APIView
from
utils.logger
import
error_logger
from
alpha_types.venus
import
REPLY_TYPE
,
REPLY_BELONG_TYPE
,
USER_EXTRA_TYPE
class
ReplyUpdateOrCreateView
(
APIView
):
...
...
@@ -78,3 +79,96 @@ class ReplyVote(APIView):
return
{
'message'
:
'操作成功'
}
class
ReplyManageListView
(
APIView
):
def
get
(
self
,
request
):
page
=
int
(
request
.
GET
.
get
(
'page'
,
1
))
limit
=
int
(
request
.
GET
.
get
(
'limit'
,
10
))
id_
=
request
.
GET
.
get
(
'id'
,
None
)
content
=
request
.
GET
.
get
(
'content'
,
None
)
topic_content
=
request
.
GET
.
get
(
'topic_content'
,
None
)
user_name
=
request
.
GET
.
get
(
'user_name'
,
None
)
belong_type
=
request
.
GET
.
get
(
'belong_type'
,
None
)
reply_level
=
request
.
GET
.
get
(
'reply_level'
,
None
)
reply_user_type
=
request
.
GET
.
get
(
'reply_user_type'
,
None
)
replied_user_type
=
request
.
GET
.
get
(
'replied_user_type'
,
None
)
is_online
=
request
.
GET
.
get
(
'is_online'
,
None
)
from_create_time
=
request
.
GET
.
get
(
'from_create_time'
,
None
)
to_create_time
=
request
.
GET
.
get
(
'to_create_time'
,
None
)
from_topic_create_time
=
request
.
GET
.
get
(
'from_topic_create_time'
,
None
)
to_topic_create_time
=
request
.
GET
.
get
(
'to_topic_create_time'
,
None
)
other_filters
=
{}
if
topic_content
:
other_filters
[
'topic_content'
]
=
topic_content
if
reply_user_type
:
reply_user_type
=
int
(
reply_user_type
)
if
reply_user_type
in
[
USER_EXTRA_TYPE
.
REAL
,
USER_EXTRA_TYPE
.
SHADOW
,
USER_EXTRA_TYPE
.
KOL
]:
other_filters
[
'reply_user_type'
]
=
reply_user_type
if
replied_user_type
:
replied_user_type
=
int
(
replied_user_type
)
if
replied_user_type
in
[
USER_EXTRA_TYPE
.
REAL
,
USER_EXTRA_TYPE
.
SHADOW
,
USER_EXTRA_TYPE
.
KOL
]:
other_filters
[
'replied_user_type'
]
=
replied_user_type
if
from_topic_create_time
and
to_topic_create_time
:
other_filters
[
'topic_create_time__gte'
]
=
from_topic_create_time
other_filters
[
'topic_create_time__lte'
]
=
to_topic_create_time
if
user_name
:
other_filters
[
'user_name'
]
=
user_name
filters
=
{}
if
id_
:
filters
[
'id'
]
=
int
(
id_
)
if
content
:
filters
[
'content__contains'
]
=
content
if
belong_type
:
if
belong_type
in
REPLY_BELONG_TYPE
:
filters
[
'belong_type'
]
=
belong_type
if
reply_level
:
reply_level
=
int
(
reply_level
)
if
reply_level
==
1
:
filters
[
'top_id__lte'
]
=
0
if
reply_level
==
2
:
filters
[
'top_id__gt'
]
=
0
if
is_online
:
is_online
=
int
(
is_online
)
filters
[
'is_online'
]
=
is_online
if
from_create_time
and
to_create_time
:
filters
[
'create_time__gte'
]
=
from_create_time
filters
[
'create_time__lte'
]
=
to_create_time
try
:
data
=
self
.
rpc
[
'venus/sun/reply/manage/list'
](
offset
=
(
page
-
1
)
*
limit
,
limit
=
limit
,
filters
=
filters
,
other_filters
=
other_filters
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'获取reply列表失败
%
s'
,
e
)
raise
return
data
class
ReplyManageCreateView
(
APIView
):
def
post
(
self
,
request
):
id_
=
request
.
POST
.
get
(
'id'
,
None
)
replied_id
=
request
.
POST
.
get
(
'replied_id'
)
topic_id
=
request
.
POST
.
get
(
'topic_id'
)
pictorial_id
=
request
.
POST
.
get
(
'pictorial_id'
)
user_id
=
request
.
POST
.
get
(
'user_id'
)
content
=
request
.
POST
.
get
(
'content'
)
data
=
{
'replied_id'
:
replied_id
,
'topic_id'
:
topic_id
if
topic_id
else
0
,
'pictorial_id'
:
pictorial_id
if
pictorial_id
else
0
,
'user_id'
:
user_id
,
'content'
:
content
,
'type'
:
REPLY_TYPE
.
PUPPET_REPLY_ANS
,
}
try
:
rep
=
self
.
rpc
[
'venus/sun/reply/manage/edit'
](
id_
=
id_
,
data
=
data
,
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'创建/编辑
%
s-reply信息失败
%
s'
%
(
id
,
e
))
raise
return
{
"message"
:
'更新成功'
,
"id"
:
rep
[
'id'
]
}
api/urls.py
View file @
48082baf
...
...
@@ -219,6 +219,11 @@ urlpatterns = [
url
(
r'^reply/batch_delete$'
,
ReplyUpdateOrCreateView
.
as_view
()),
url
(
r'^reply/create$'
,
ReplyCreate
.
as_view
()),
url
(
r'^reply/vote$'
,
ReplyVote
.
as_view
()),
# 评论管理
url
(
r'^reply/manage/list$'
,
ReplyManageListView
.
as_view
()),
url
(
r'^reply/manage/create$'
,
ReplyManageCreateView
.
as_view
()),
]
...
...
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