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
478c577a
Commit
478c577a
authored
Oct 21, 2019
by
杨成林
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test' into 'dev'
Test See merge request
alpha/sun!379
parents
0ab46ca9
11f4a480
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
128 additions
and
34 deletions
+128
-34
pictorial.py
api/pictorial.py
+36
-0
product.py
api/product.py
+14
-9
reply.py
api/reply.py
+15
-19
search.py
api/search.py
+2
-1
survey.py
api/survey.py
+16
-3
tag.py
api/tag.py
+4
-1
topic.py
api/topic.py
+37
-1
urls.py
api/urls.py
+4
-0
No files found.
api/pictorial.py
View file @
478c577a
...
@@ -231,3 +231,39 @@ class PictorialFollowsAdd(APIView):
...
@@ -231,3 +231,39 @@ class PictorialFollowsAdd(APIView):
return
{
return
{
'message'
:
'添加成功'
'message'
:
'添加成功'
}
}
class
PictorialTagAdd
(
APIView
):
"""新增榜单tag"""
def
post
(
self
,
request
):
pictorial_ids
=
json
.
loads
(
request
.
POST
.
get
(
'pictorial_ids'
,
'[]'
))
tag_id
=
int
(
request
.
POST
.
get
(
'tag_id'
))
if
request
.
POST
.
get
(
'tag_id'
)
else
None
try
:
self
.
rpc
[
'venus/sun/pictorial/add_tag'
](
pictorial_ids
=
pictorial_ids
,
tag_id
=
tag_id
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'操作失败
%
s'
%
(
e
))
raise
return
{
'message'
:
'添加成功'
}
class
PictorialTagRm
(
APIView
):
"""删除榜单tag"""
def
post
(
self
,
request
):
import
ipdb
ipdb
.
set_trace
()
pictorial_ids
=
json
.
loads
(
request
.
POST
.
get
(
'pictorial_ids'
,
'[]'
))
tag_id
=
int
(
request
.
POST
.
get
(
'tag_id'
))
if
request
.
POST
.
get
(
'tag_id'
)
else
None
try
:
self
.
rpc
[
'venus/sun/pictorial/rm_tag'
](
pictorial_ids
=
pictorial_ids
,
tag_id
=
tag_id
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'操作失败
%
s'
%
(
e
))
raise
return
{
'message'
:
'添加成功'
}
api/product.py
View file @
478c577a
...
@@ -73,9 +73,9 @@ class ProductListView(APIView):
...
@@ -73,9 +73,9 @@ class ProductListView(APIView):
sorted_condition
=
request
.
GET
.
get
(
'sorted_condition'
,
None
)
sorted_condition
=
request
.
GET
.
get
(
'sorted_condition'
,
None
)
data
=
self
.
rpc
[
'neptune/commodity/product/list'
](
data
=
self
.
rpc
[
'neptune/commodity/product/list'
](
offset
=
offset
,
count
=
count
,
id_
=
id_
,
cn_name
=
cn_name
,
en_name
=
en_name
,
alias
=
alias
,
is_online
=
is_online
,
offset
=
offset
,
count
=
count
,
id_
=
id_
,
cn_name
=
cn_name
,
en_name
=
en_name
,
alias
=
alias
,
is_online
=
is_online
,
has_area
=
has_area
,
has_brand
=
has_brand
,
has_image
=
has_image
,
brand_id
=
brand_id
,
classify_id
=
classify_id
,
has_area
=
has_area
,
has_brand
=
has_brand
,
has_image
=
has_image
,
brand_id
=
brand_id
,
classify_id
=
classify_id
,
category_id
=
category_id
,
price_low
=
price_low
,
price_high
=
price_high
,
grade_low
=
grade_low
,
grade_high
=
grade_high
,
category_id
=
category_id
,
price_low
=
price_low
,
price_high
=
price_high
,
grade_low
=
grade_low
,
grade_high
=
grade_high
,
comment_nums_low
=
comment_nums_low
,
comment_nums_high
=
comment_nums_high
,
effect_name
=
effect_name
,
comment_nums_low
=
comment_nums_low
,
comment_nums_high
=
comment_nums_high
,
effect_name
=
effect_name
,
sorted_condition
=
sorted_condition
)
.
unwrap
()
sorted_condition
=
sorted_condition
)
.
unwrap
()
...
@@ -90,11 +90,11 @@ class ProductListView(APIView):
...
@@ -90,11 +90,11 @@ class ProductListView(APIView):
obj
[
'brand_info'
]
=
{
obj
[
'brand_info'
]
=
{
'id'
:
brand_product_dict
.
get
(
str
(
product_id
))
.
get
(
'id'
),
'id'
:
brand_product_dict
.
get
(
str
(
product_id
))
.
get
(
'id'
),
'cn_name'
:
brand_product_dict
.
get
(
str
(
product_id
))
.
get
(
'cn_name'
)}
if
brand_product_dict
.
get
(
str
(
product_id
))
else
''
'cn_name'
:
brand_product_dict
.
get
(
str
(
product_id
))
.
get
(
'cn_name'
)}
if
brand_product_dict
.
get
(
str
(
product_id
))
else
''
obj
[
'category_infos'
]
=
[{
'id'
:
obj
.
get
(
'id'
),
'cn_name'
:
obj
.
get
(
'cn_name'
)}
obj
[
'category_infos'
]
=
[{
'id'
:
obj
.
get
(
'id'
),
'cn_name'
:
obj
.
get
(
'cn_name'
)}
for
obj
in
category_product_dict
.
get
(
str
(
product_id
))]
if
category_product_dict
.
get
(
str
(
product_id
))
else
[]
for
obj
in
category_product_dict
.
get
(
str
(
product_id
))]
if
category_product_dict
.
get
(
str
(
product_id
))
else
[]
obj
[
'effect_infos'
]
=
[{
'id'
:
obj
.
get
(
'id'
),
'cn_name'
:
obj
.
get
(
'cn_name'
)}
obj
[
'effect_infos'
]
=
[{
'id'
:
obj
.
get
(
'id'
),
'cn_name'
:
obj
.
get
(
'cn_name'
)}
for
obj
in
effect_product_dict
.
get
(
str
(
product_id
))]
if
effect_product_dict
.
get
(
str
(
product_id
))
else
[]
for
obj
in
effect_product_dict
.
get
(
str
(
product_id
))]
if
effect_product_dict
.
get
(
str
(
product_id
))
else
[]
obj
[
'classify_infos'
]
=
[{
'id'
:
obj
.
get
(
'id'
),
'cn_name'
:
obj
.
get
(
'cn_name'
)}
obj
[
'classify_infos'
]
=
[{
'id'
:
obj
.
get
(
'id'
),
'cn_name'
:
obj
.
get
(
'cn_name'
)}
for
obj
in
classify_product_dict
.
get
(
str
(
product_id
))]
if
classify_product_dict
.
get
(
str
(
product_id
))
else
[]
for
obj
in
classify_product_dict
.
get
(
str
(
product_id
))]
if
classify_product_dict
.
get
(
str
(
product_id
))
else
[]
obj
.
pop
(
'norms'
)
obj
.
pop
(
'norms'
)
...
@@ -102,7 +102,7 @@ class ProductListView(APIView):
...
@@ -102,7 +102,7 @@ class ProductListView(APIView):
obj
.
pop
(
'platform'
)
obj
.
pop
(
'platform'
)
count
=
self
.
rpc
[
'neptune/commodity/product/count'
](
count
=
self
.
rpc
[
'neptune/commodity/product/count'
](
id_
=
id_
,
cn_name
=
cn_name
,
en_name
=
en_name
,
alias
=
alias
,
is_online
=
is_online
,
has_area
=
has_area
,
has_brand
=
has_brand
,
id_
=
id_
,
cn_name
=
cn_name
,
en_name
=
en_name
,
alias
=
alias
,
is_online
=
is_online
,
has_area
=
has_area
,
has_brand
=
has_brand
,
has_image
=
has_image
,
brand_id
=
brand_id
,
category_id
=
category_id
,
classify_id
=
classify_id
,
price_low
=
price_low
,
has_image
=
has_image
,
brand_id
=
brand_id
,
category_id
=
category_id
,
classify_id
=
classify_id
,
price_low
=
price_low
,
price_high
=
price_high
,
grade_low
=
grade_low
,
grade_high
=
grade_high
,
comment_nums_low
=
comment_nums_low
,
price_high
=
price_high
,
grade_low
=
grade_low
,
grade_high
=
grade_high
,
comment_nums_low
=
comment_nums_low
,
comment_nums_high
=
comment_nums_high
,
effect_name
=
effect_name
)
.
unwrap
()
comment_nums_high
=
comment_nums_high
,
effect_name
=
effect_name
)
.
unwrap
()
...
@@ -163,6 +163,7 @@ class ProductCreateView(APIView):
...
@@ -163,6 +163,7 @@ class ProductCreateView(APIView):
effect_ids
=
json
.
loads
(
request
.
POST
.
get
(
'effect_ids'
,
'[]'
))
effect_ids
=
json
.
loads
(
request
.
POST
.
get
(
'effect_ids'
,
'[]'
))
is_online
=
request
.
POST
.
get
(
'is_online'
)
is_online
=
request
.
POST
.
get
(
'is_online'
)
brand_id
=
request
.
POST
.
get
(
'brand_id'
)
brand_id
=
request
.
POST
.
get
(
'brand_id'
)
period_of_use
=
request
.
POST
.
get
(
'period_of_use'
)
if
not
cn_name
or
not
image
:
if
not
cn_name
or
not
image
:
return
r'缺少参数'
return
r'缺少参数'
...
@@ -170,13 +171,15 @@ class ProductCreateView(APIView):
...
@@ -170,13 +171,15 @@ class ProductCreateView(APIView):
data
=
self
.
rpc
[
'neptune/commodity/product/create'
](
data
=
self
.
rpc
[
'neptune/commodity/product/create'
](
cn_name
=
cn_name
,
en_name
=
en_name
,
alias
=
alias
,
image
=
image
,
norms
=
norms
,
grade
=
grade
,
price
=
price
,
cn_name
=
cn_name
,
en_name
=
en_name
,
alias
=
alias
,
image
=
image
,
norms
=
norms
,
grade
=
grade
,
price
=
price
,
country
=
country
,
description
=
description
,
comment_nums
=
comment_nums
,
classify_ids
=
classify_ids
,
country
=
country
,
description
=
description
,
comment_nums
=
comment_nums
,
classify_ids
=
classify_ids
,
category_ids
=
category_ids
,
effect_ids
=
effect_ids
,
is_online
=
is_online
,
brand_id
=
brand_id
)
.
unwrap
()
category_ids
=
category_ids
,
effect_ids
=
effect_ids
,
is_online
=
is_online
,
brand_id
=
brand_id
,
period_of_use
=
period_of_use
)
.
unwrap
()
return
data
return
data
class
ProductUpdateView
(
APIView
):
class
ProductUpdateView
(
APIView
):
def
post
(
self
,
request
):
def
post
(
self
,
request
):
id_
=
request
.
POST
.
get
(
'id'
)
id_
=
request
.
POST
.
get
(
'id'
)
cn_name
=
request
.
POST
.
get
(
'cn_name'
,
None
)
cn_name
=
request
.
POST
.
get
(
'cn_name'
,
None
)
...
@@ -194,6 +197,7 @@ class ProductUpdateView(APIView):
...
@@ -194,6 +197,7 @@ class ProductUpdateView(APIView):
effect_ids
=
json
.
loads
(
request
.
POST
.
get
(
'effect_ids'
,
'[]'
))
effect_ids
=
json
.
loads
(
request
.
POST
.
get
(
'effect_ids'
,
'[]'
))
is_online
=
request
.
POST
.
get
(
'is_online'
)
is_online
=
request
.
POST
.
get
(
'is_online'
)
brand_id
=
request
.
POST
.
get
(
'brand_id'
)
brand_id
=
request
.
POST
.
get
(
'brand_id'
)
period_of_use
=
request
.
POST
.
get
(
'period_of_use'
,
0
)
if
not
id_
:
if
not
id_
:
return
r'缺少参数'
return
r'缺少参数'
...
@@ -201,7 +205,8 @@ class ProductUpdateView(APIView):
...
@@ -201,7 +205,8 @@ class ProductUpdateView(APIView):
data
=
self
.
rpc
[
'neptune/commodity/product/update'
](
data
=
self
.
rpc
[
'neptune/commodity/product/update'
](
id_
=
id_
,
cn_name
=
cn_name
,
en_name
=
en_name
,
alias
=
alias
,
image
=
image
,
norms
=
norms
,
grade
=
grade
,
price
=
price
,
id_
=
id_
,
cn_name
=
cn_name
,
en_name
=
en_name
,
alias
=
alias
,
image
=
image
,
norms
=
norms
,
grade
=
grade
,
price
=
price
,
country
=
country
,
description
=
description
,
comment_nums
=
comment_nums
,
classify_ids
=
classify_ids
,
country
=
country
,
description
=
description
,
comment_nums
=
comment_nums
,
classify_ids
=
classify_ids
,
category_ids
=
category_ids
,
effect_ids
=
effect_ids
,
is_online
=
is_online
,
brand_id
=
brand_id
)
.
unwrap
()
category_ids
=
category_ids
,
effect_ids
=
effect_ids
,
is_online
=
is_online
,
brand_id
=
brand_id
,
period_of_use
=
period_of_use
)
.
unwrap
()
return
data
return
data
...
...
api/reply.py
View file @
478c577a
...
@@ -91,7 +91,7 @@ class ReplyManageListView(APIView):
...
@@ -91,7 +91,7 @@ class ReplyManageListView(APIView):
topic_content
=
request
.
GET
.
get
(
'topic_content'
,
None
)
topic_content
=
request
.
GET
.
get
(
'topic_content'
,
None
)
user_name
=
request
.
GET
.
get
(
'user_name'
,
None
)
user_name
=
request
.
GET
.
get
(
'user_name'
,
None
)
belong_type
=
request
.
GET
.
get
(
'belong_type'
,
None
)
belong_type
=
request
.
GET
.
get
(
'belong_type'
,
None
)
reply_level
=
request
.
GET
.
get
(
'reply_level'
,
None
)
reply_level
=
request
.
GET
.
get
(
'reply_level'
,
None
)
#历史问题 后期优化
reply_user_type
=
request
.
GET
.
get
(
'reply_user_type'
,
None
)
reply_user_type
=
request
.
GET
.
get
(
'reply_user_type'
,
None
)
replied_user_type
=
request
.
GET
.
get
(
'replied_user_type'
,
None
)
replied_user_type
=
request
.
GET
.
get
(
'replied_user_type'
,
None
)
is_online
=
request
.
GET
.
get
(
'is_online'
,
None
)
is_online
=
request
.
GET
.
get
(
'is_online'
,
None
)
...
@@ -100,36 +100,28 @@ class ReplyManageListView(APIView):
...
@@ -100,36 +100,28 @@ class ReplyManageListView(APIView):
from_topic_create_time
=
request
.
GET
.
get
(
'from_topic_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
)
to_topic_create_time
=
request
.
GET
.
get
(
'to_topic_create_time'
,
None
)
other_
filters
=
{}
filters
=
{}
if
topic_content
:
if
topic_content
:
other_
filters
[
'topic_content'
]
=
topic_content
.
strip
()
filters
[
'topic_content'
]
=
topic_content
.
strip
()
if
reply_user_type
:
if
reply_user_type
:
reply_user_type
=
int
(
reply_user_type
)
reply_user_type
=
int
(
reply_user_type
)
if
reply_user_type
i
n
[
USER_EXTRA_TYPE
.
REAL
,
USER_EXTRA_TYPE
.
SHADOW
,
USER_EXTRA_TYPE
.
KOL
]
:
if
reply_user_type
i
s
not
None
:
other_
filters
[
'reply_user_type'
]
=
reply_user_type
filters
[
'reply_user_type'
]
=
reply_user_type
if
replied_user_type
:
if
replied_user_type
:
replied_user_type
=
int
(
replied_user_type
)
replied_user_type
=
int
(
replied_user_type
)
if
replied_user_type
i
n
[
USER_EXTRA_TYPE
.
REAL
,
USER_EXTRA_TYPE
.
SHADOW
,
USER_EXTRA_TYPE
.
KOL
]
:
if
replied_user_type
i
s
not
None
:
other_
filters
[
'replied_user_type'
]
=
replied_user_type
filters
[
'replied_user_type'
]
=
replied_user_type
if
from_topic_create_time
and
to_topic_create_time
:
if
from_topic_create_time
and
to_topic_create_time
:
other_
filters
[
'topic_create_time__gte'
]
=
from_topic_create_time
filters
[
'topic_create_time__gte'
]
=
from_topic_create_time
other_
filters
[
'topic_create_time__lte'
]
=
to_topic_create_time
filters
[
'topic_create_time__lte'
]
=
to_topic_create_time
if
user_name
:
if
user_name
:
other_filters
[
'user_name'
]
=
user_name
filters
[
'user_name'
]
=
user_name
filters
=
{}
if
topic_id
:
if
topic_id
:
filters
[
'topic_id'
]
=
int
(
topic_id
)
filters
[
'topic_id'
]
=
int
(
topic_id
)
if
content
:
filters
[
'content__contains'
]
=
content
.
strip
()
if
belong_type
:
if
belong_type
:
if
belong_type
in
REPLY_BELONG_TYPE
:
if
belong_type
in
REPLY_BELONG_TYPE
:
filters
[
'belong_type'
]
=
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
:
if
is_online
:
is_online
=
int
(
is_online
)
is_online
=
int
(
is_online
)
filters
[
'is_online'
]
=
is_online
filters
[
'is_online'
]
=
is_online
...
@@ -137,6 +129,10 @@ class ReplyManageListView(APIView):
...
@@ -137,6 +129,10 @@ class ReplyManageListView(APIView):
filters
[
'create_time__gte'
]
=
from_create_time
filters
[
'create_time__gte'
]
=
from_create_time
filters
[
'create_time__lte'
]
=
to_create_time
filters
[
'create_time__lte'
]
=
to_create_time
other_filters
=
{}
if
content
:
other_filters
[
'content__contains'
]
=
content
.
strip
()
\
try
:
try
:
data
=
self
.
rpc
[
'venus/sun/reply/manage/list'
](
offset
=
(
page
-
1
)
*
limit
,
limit
=
limit
,
filters
=
filters
,
other_filters
=
other_filters
)
.
unwrap
()
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
:
except
Exception
as
e
:
...
...
api/search.py
View file @
478c577a
...
@@ -97,10 +97,11 @@ class TagTypeSearchView(APIView):
...
@@ -97,10 +97,11 @@ class TagTypeSearchView(APIView):
class
PictorialSearchView
(
APIView
):
class
PictorialSearchView
(
APIView
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
name
=
request
.
GET
.
get
(
'name'
)
name
=
request
.
GET
.
get
(
'name'
)
tag_id
=
request
.
GET
.
get
(
'tag_id'
)
offset
,
count
=
get_offset_count
(
request
)
offset
,
count
=
get_offset_count
(
request
)
try
:
try
:
data
=
self
.
rpc
[
'venus/sun/pictorial/search'
](
name
=
name
,
offset
=
offset
,
count
=
count
)
.
unwrap
()
data
=
self
.
rpc
[
'venus/sun/pictorial/search'
](
name
=
name
,
tag_id
=
tag_id
,
offset
=
offset
,
count
=
count
)
.
unwrap
()
except
Exception
as
e
:
except
Exception
as
e
:
raise
e
raise
e
...
...
api/survey.py
View file @
478c577a
...
@@ -31,10 +31,23 @@ class SurveyView(APIView):
...
@@ -31,10 +31,23 @@ class SurveyView(APIView):
"template_id"
:
int
(
request
.
POST
.
get
(
'template_id'
,
0
)),
"template_id"
:
int
(
request
.
POST
.
get
(
'template_id'
,
0
)),
}
}
self
.
rpc
[
'venus/sun/survey/add'
](
data
=
data
)
.
unwrap
()
data
=
self
.
rpc
[
'venus/sun/survey/add'
](
data
=
data
)
.
unwrap
()
return
{
return
data
"status"
:
1
class
SurveyAddAnswerView
(
APIView
):
def
post
(
self
,
request
):
data
=
{
"answers"
:
json
.
loads
(
request
.
POST
.
get
(
'answers'
)),
"template_id"
:
request
.
POST
.
get
(
'template_id'
),
"question_order"
:
request
.
POST
.
get
(
'question_order'
),
}
}
self
.
rpc
[
'venus/sun/survey/answers_add'
](
data
=
data
)
.
unwrap
()
return
{
"status"
:
1
}
api/tag.py
View file @
478c577a
...
@@ -60,7 +60,7 @@ class TagUpdateOrCreateView(APIView):
...
@@ -60,7 +60,7 @@ class TagUpdateOrCreateView(APIView):
official_pictorial_id
=
official_pictorial_id
[
0
]
official_pictorial_id
=
official_pictorial_id
[
0
]
else
:
else
:
official_pictorial_id
=
None
official_pictorial_id
=
None
is_expert
=
int
(
request
.
POST
.
get
(
'is_expert'
,
0
))
data
=
{
data
=
{
'name'
:
request
.
POST
.
get
(
'name'
)
.
lower
(),
'name'
:
request
.
POST
.
get
(
'name'
)
.
lower
(),
'description'
:
request
.
POST
.
get
(
'description'
,
''
),
'description'
:
request
.
POST
.
get
(
'description'
,
''
),
...
@@ -74,6 +74,9 @@ class TagUpdateOrCreateView(APIView):
...
@@ -74,6 +74,9 @@ class TagUpdateOrCreateView(APIView):
'is_core'
:
request
.
POST
.
get
(
'is_core'
,
0
),
'is_core'
:
request
.
POST
.
get
(
'is_core'
,
0
),
'official_pictorial_id'
:
official_pictorial_id
,
'official_pictorial_id'
:
official_pictorial_id
,
'is_show_in_register'
:
request
.
POST
.
get
(
'is_show_in_register'
,
'false'
),
'is_show_in_register'
:
request
.
POST
.
get
(
'is_show_in_register'
,
'false'
),
'is_expert'
:
request
.
POST
.
get
(
'is_expert'
,
0
),
'gray_badge'
:
request
.
POST
.
get
(
'gray_badge'
,
''
)
if
is_expert
else
""
,
'light_badge'
:
request
.
POST
.
get
(
'light_badge'
,
''
)
if
is_expert
else
""
,
'pictorial_ids'
:
list
(
'pictorial_ids'
:
list
(
(
map
(
lambda
x
:
int
(
x
.
split
(
":"
)[
0
]),
json
.
loads
((
request
.
POST
.
get
(
'pictorial_ids'
,
'[]'
))))))
(
map
(
lambda
x
:
int
(
x
.
split
(
":"
)[
0
]),
json
.
loads
((
request
.
POST
.
get
(
'pictorial_ids'
,
'[]'
))))))
}
}
...
...
api/topic.py
View file @
478c577a
...
@@ -6,10 +6,12 @@
...
@@ -6,10 +6,12 @@
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
import
USER_EXTRA_TYPE
class
TopicListView
(
APIView
):
class
TopicListView
(
APIView
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
pictorial_id
=
request
.
GET
.
get
(
'pictorial_id'
,
''
)
pictorial_id
=
request
.
GET
.
get
(
'pictorial_id'
,
''
)
user_id
=
request
.
GET
.
get
(
'user_id'
,
''
)
user_id
=
request
.
GET
.
get
(
'user_id'
,
''
)
page
=
int
(
request
.
GET
.
get
(
'page'
,
1
))
page
=
int
(
request
.
GET
.
get
(
'page'
,
1
))
...
@@ -31,6 +33,22 @@ class TopicListView(APIView):
...
@@ -31,6 +33,22 @@ class TopicListView(APIView):
if
filters
.
get
(
"is_finished"
)
is
not
None
:
if
filters
.
get
(
"is_finished"
)
is
not
None
:
filters
[
"is_finished"
]
=
True
if
filters
.
get
(
"is_finished"
)
else
False
filters
[
"is_finished"
]
=
True
if
filters
.
get
(
"is_finished"
)
else
False
user_type
=
filters
.
pop
(
"user_type"
)
if
filters
.
get
(
"user_type"
)
else
None
if
user_type
:
if
int
(
user_type
)
==
USER_EXTRA_TYPE
.
COMMON
:
filters
[
"is_shadow"
]
=
0
filters
[
"is_edit"
]
=
0
elif
int
(
user_type
)
==
USER_EXTRA_TYPE
.
SHADOW
:
filters
[
"is_shadow"
]
=
1
elif
int
(
user_type
)
==
USER_EXTRA_TYPE
.
KOL
:
filters
[
"is_kol"
]
=
1
elif
int
(
user_type
)
==
USER_EXTRA_TYPE
.
EDIT
:
filters
[
"is_edit"
]
=
1
if
filters
.
get
(
"has_product"
)
is
not
None
:
filters
[
"has_product"
]
=
bool
(
filters
[
"has_product"
])
res
=
self
.
rpc
[
'physical/search/business/topic'
](
res
=
self
.
rpc
[
'physical/search/business/topic'
](
offset
=
(
page
-
1
)
*
limit
,
offset
=
(
page
-
1
)
*
limit
,
size
=
limit
,
size
=
limit
,
...
@@ -204,7 +222,7 @@ class TopicBallot(APIView):
...
@@ -204,7 +222,7 @@ class TopicBallot(APIView):
return
{
return
{
"message"
:
"更新成功"
"message"
:
"更新成功"
}
}
class
TopicProductAdd
(
APIView
):
class
TopicProductAdd
(
APIView
):
"""帖子添加商品关系"""
"""帖子添加商品关系"""
...
@@ -238,3 +256,21 @@ class TopicProductDel(APIView):
...
@@ -238,3 +256,21 @@ class TopicProductDel(APIView):
return
{
return
{
'message'
:
'更新成功'
'message'
:
'更新成功'
}
}
class
TopicBallotBatch
(
APIView
):
"""帖子批量投票"""
def
post
(
self
,
request
):
ids
=
json
.
loads
(
request
.
POST
.
get
(
'ids'
,
'[]'
))
ballot_num
=
int
(
request
.
POST
.
get
(
'ballot_num'
,
0
))
try
:
self
.
rpc
[
'venus/sun/topic/ballot_batch'
](
ids
=
ids
,
ballot_num
=
ballot_num
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'编辑
%
s帖子信息失败
%
s'
%
(
ids
,
e
))
raise
return
{
'message'
:
'更新成功'
}
api/urls.py
View file @
478c577a
...
@@ -66,6 +66,7 @@ urlpatterns = [
...
@@ -66,6 +66,7 @@ urlpatterns = [
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
()),
url
(
r'^topic/product/del$'
,
TopicProductDel
.
as_view
()),
url
(
r'^topic/product/del$'
,
TopicProductDel
.
as_view
()),
url
(
r'^topic/ballot_batch$'
,
TopicBallotBatch
.
as_view
()),
# star相关
# star相关
url
(
r'^celebrity/list$'
,
CelebrityListView
.
as_view
()),
url
(
r'^celebrity/list$'
,
CelebrityListView
.
as_view
()),
...
@@ -164,6 +165,8 @@ urlpatterns = [
...
@@ -164,6 +165,8 @@ urlpatterns = [
url
(
r'^pictorial/topic/list$'
,
PictorialTopicList
.
as_view
()),
url
(
r'^pictorial/topic/list$'
,
PictorialTopicList
.
as_view
()),
url
(
r'^pictorial/follows/del$'
,
PictorialFollowsDel
.
as_view
()),
url
(
r'^pictorial/follows/del$'
,
PictorialFollowsDel
.
as_view
()),
url
(
r'^pictorial/follows/add$'
,
PictorialFollowsAdd
.
as_view
()),
url
(
r'^pictorial/follows/add$'
,
PictorialFollowsAdd
.
as_view
()),
url
(
r'^pictorial/tag_add$'
,
PictorialTagAdd
.
as_view
()),
url
(
r'^pictorial/tag_rm$'
,
PictorialTagRm
.
as_view
()),
#运营位
#运营位
url
(
r'^topic/home_recommend/list'
,
TopicHomeRecommendList
.
as_view
()),
url
(
r'^topic/home_recommend/list'
,
TopicHomeRecommendList
.
as_view
()),
...
@@ -251,6 +254,7 @@ urlpatterns = [
...
@@ -251,6 +254,7 @@ urlpatterns = [
url
(
r'^survey_question/create$'
,
SurveyView
.
as_view
()),
url
(
r'^survey_question/create$'
,
SurveyView
.
as_view
()),
url
(
r'^survey_question/get$'
,
SurveyView
.
as_view
()),
url
(
r'^survey_question/get$'
,
SurveyView
.
as_view
()),
url
(
r'^survey_question/list$'
,
SurveyListView
.
as_view
()),
url
(
r'^survey_question/list$'
,
SurveyListView
.
as_view
()),
url
(
r'^survey_question/add_answer$'
,
SurveyAddAnswerView
.
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