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
1
Merge Requests
1
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
alpha
sun
Commits
83915511
Commit
83915511
authored
Jul 04, 2019
by
haowang
Browse files
Options
Browse Files
Download
Plain Diff
fix conflicts
parents
eb202909
ef397482
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
132 additions
and
23 deletions
+132
-23
pictorial.py
api/pictorial.py
+50
-1
tools.py
api/tools.py
+30
-0
topic.py
api/topic.py
+18
-1
urls.py
api/urls.py
+5
-0
word_parent.py
api/word_parent.py
+29
-21
No files found.
api/pictorial.py
View file @
83915511
...
@@ -62,7 +62,8 @@ class PictorialUpdateOrCreate(APIView):
...
@@ -62,7 +62,8 @@ class PictorialUpdateOrCreate(APIView):
'collection_tag_ids'
:
collection_tag_ids
,
'collection_tag_ids'
:
collection_tag_ids
,
'is_home_recommend'
:
int
(
request
.
POST
.
get
(
'is_home_recommend'
,
0
)),
'is_home_recommend'
:
int
(
request
.
POST
.
get
(
'is_home_recommend'
,
0
)),
'add_score'
:
int
(
request
.
POST
.
get
(
'add_score'
,
0
)),
'add_score'
:
int
(
request
.
POST
.
get
(
'add_score'
,
0
)),
'is_public'
:
True
if
request
.
POST
.
get
(
'is_public'
)
==
"true"
else
False
'is_public'
:
True
if
request
.
POST
.
get
(
'is_public'
)
==
"true"
else
False
,
'is_feed'
:
int
(
request
.
POST
.
get
(
'is_feed'
,
0
))
}
}
try
:
try
:
...
@@ -97,6 +98,54 @@ class PictorialTopics(APIView):
...
@@ -97,6 +98,54 @@ class PictorialTopics(APIView):
}
}
class
PictorialFeedlListView
(
APIView
):
def
get
(
self
,
request
):
order_by
=
request
.
GET
.
get
(
'order_by'
,
"-id"
)
offset
=
int
(
request
.
GET
.
get
(
'offset'
,
1
))
limit
=
int
(
request
.
GET
.
get
(
'limit'
,
10
))
try
:
data
=
self
.
rpc
[
'venus/sun/pictorial/feed/list'
](
offset
=
(
offset
-
1
)
*
limit
,
limit
=
limit
,
order_by
=
order_by
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'获取画报列表失败
%
s'
,
e
)
raise
return
data
class
PictorialFeedlRank
(
APIView
):
"""修改画报首页like流rank"""
def
post
(
self
,
request
):
id_
=
request
.
POST
.
get
(
'id'
)
rank
=
int
(
request
.
POST
.
get
(
'rank'
))
try
:
self
.
rpc
[
'venus/sun/pictorial/feed/rank'
](
id_
=
id_
,
rank
=
rank
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'编辑
%
信息失败
%
s'
%
(
e
))
raise
return
{
'message'
:
'更新成功'
}
class
PictorialFeedDelete
(
APIView
):
"""删除画报首页like流"""
def
post
(
self
,
request
):
ids
=
json
.
loads
(
request
.
POST
.
get
(
'ids'
,
'[]'
))
try
:
self
.
rpc
[
'venus/sun/pictorial/feed/delete'
](
ids
=
ids
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'删除信息失败
%
s'
%
(
e
))
raise
return
{
'message'
:
'删除成功'
}
class
PictorialProductAdd
(
APIView
):
class
PictorialProductAdd
(
APIView
):
"""画报添加商品关系"""
"""画报添加商品关系"""
...
...
api/tools.py
View file @
83915511
...
@@ -91,3 +91,33 @@ class BatchCreateTopicWithAiFashionTag(APIView):
...
@@ -91,3 +91,33 @@ class BatchCreateTopicWithAiFashionTag(APIView):
self
.
rpc
[
'venus/sun/tools/batch_create_topic_with_ai_fashion_tag'
](
infos
=
json_data
)
.
unwrap
()
self
.
rpc
[
'venus/sun/tools/batch_create_topic_with_ai_fashion_tag'
](
infos
=
json_data
)
.
unwrap
()
return
{
'message'
:
u'上传成功'
,
'code'
:
200
}
return
{
'message'
:
u'上传成功'
,
'code'
:
200
}
class
AddVirtFans
(
APIView
):
def
post
(
self
,
request
):
xls_file
=
request
.
FILES
.
get
(
'file'
)
if
not
xls_file
:
return
{
'message'
:
u'上传失败,请重新上传'
,
'code'
:
500
}
wb
=
load_workbook
(
xls_file
)
data
=
wb
.
get_sheet_by_name
(
wb
.
get_sheet_names
()[
0
])
columns
=
[
item
for
item
in
data
.
columns
]
user_id_column
=
[
item
.
value
for
item
in
columns
[
0
]]
fans_num_column
=
[
item
.
value
for
item
in
columns
[
1
]]
user_id_fans_num_data
=
list
(
zip
(
user_id_column
[
1
:],
fans_num_column
[
1
:]))
#做一次数据清洗。 避免文件中的空行
user_id_fans_num_data
=
[
(
user_id
,
fans_num
)
for
user_id
,
fans_num
in
user_id_fans_num_data
if
isinstance
(
user_id
,
int
)
and
isinstance
(
fans_num
,
int
)
]
try
:
self
.
rpc
[
'venus/sun/tools/add_virt_fans'
](
data
=
user_id_fans_num_data
)
.
unwrap
()
except
:
return
{
'message'
:
u'处理失败'
,
'code'
:
500
}
return
{
'message'
:
u'处理成功'
,
'code'
:
200
}
api/topic.py
View file @
83915511
...
@@ -40,7 +40,7 @@ class TopicListView(APIView):
...
@@ -40,7 +40,7 @@ class TopicListView(APIView):
try
:
try
:
data
=
self
.
rpc
[
'venus/sun/topic/list'
](
data
=
self
.
rpc
[
'venus/sun/topic/list'
](
topic_ids
=
topic_ids
topic_ids
=
topic_ids
,
pictorial_id
=
pictorial_id
)
.
unwrap
()
)
.
unwrap
()
except
Exception
as
e
:
except
Exception
as
e
:
error_logger
.
error
(
u'获取帖子列表失败
%
s'
,
e
)
error_logger
.
error
(
u'获取帖子列表失败
%
s'
,
e
)
...
@@ -229,6 +229,23 @@ class TopicRelatePictorialInfo(APIView):
...
@@ -229,6 +229,23 @@ class TopicRelatePictorialInfo(APIView):
return
{
'data'
:
data
}
return
{
'data'
:
data
}
class
TopicBallot
(
APIView
):
def
post
(
self
,
request
):
id_
=
request
.
POST
.
get
(
'id'
)
pictorial_id
=
request
.
POST
.
get
(
'pictorial_id'
)
ballot_num
=
request
.
POST
.
get
(
'ballot_num'
)
try
:
self
.
rpc
[
'venus/sun/topic/ballot'
](
id_
=
id_
,
pictorial_id
=
pictorial_id
,
ballot_num
=
ballot_num
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'批量更新帖子失败
%
s'
,
e
)
raise
return
{
"message"
:
"更新成功"
}
class
TopicProductAdd
(
APIView
):
class
TopicProductAdd
(
APIView
):
"""帖子添加商品关系"""
"""帖子添加商品关系"""
...
...
api/urls.py
View file @
83915511
...
@@ -62,6 +62,7 @@ urlpatterns = [
...
@@ -62,6 +62,7 @@ urlpatterns = [
url
(
r'^topic/reply/batch_delete$'
,
ReplyUpdateOrCreateView
.
as_view
()),
url
(
r'^topic/reply/batch_delete$'
,
ReplyUpdateOrCreateView
.
as_view
()),
url
(
r'^topic/reply/create$'
,
ReplyCreate
.
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/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
()),
...
@@ -147,6 +148,9 @@ urlpatterns = [
...
@@ -147,6 +148,9 @@ urlpatterns = [
url
(
r'^pictorial/create$'
,
PictorialUpdateOrCreate
.
as_view
()),
url
(
r'^pictorial/create$'
,
PictorialUpdateOrCreate
.
as_view
()),
url
(
r'^pictorial/topics$'
,
PictorialTopics
.
as_view
()),
url
(
r'^pictorial/topics$'
,
PictorialTopics
.
as_view
()),
url
(
r'^pictorial/user/list$'
,
PictorialUserList
.
as_view
()),
url
(
r'^pictorial/user/list$'
,
PictorialUserList
.
as_view
()),
url
(
r'^pictorial/feed/list$'
,
PictorialFeedlListView
.
as_view
()),
url
(
r'^pictorial/feed/rank$'
,
PictorialFeedlRank
.
as_view
()),
url
(
r'^pictorial/feed/delete$'
,
PictorialFeedDelete
.
as_view
()),
url
(
r'^pictorial/product/add$'
,
PictorialProductAdd
.
as_view
()),
url
(
r'^pictorial/product/add$'
,
PictorialProductAdd
.
as_view
()),
url
(
r'^pictorial/product/del$'
,
PictorialProductDel
.
as_view
()),
url
(
r'^pictorial/product/del$'
,
PictorialProductDel
.
as_view
()),
...
@@ -165,6 +169,7 @@ urlpatterns = [
...
@@ -165,6 +169,7 @@ urlpatterns = [
url
(
r'^tools/virtual_vote$'
,
VirtualVote
.
as_view
()),
url
(
r'^tools/virtual_vote$'
,
VirtualVote
.
as_view
()),
url
(
r'^tools/batch_update_topic_tag$'
,
BatchUpdateTopicTag
.
as_view
()),
url
(
r'^tools/batch_update_topic_tag$'
,
BatchUpdateTopicTag
.
as_view
()),
url
(
r'^tools/batch_create_topic_with_ai_fashion_tag$'
,
BatchCreateTopicWithAiFashionTag
.
as_view
()),
url
(
r'^tools/batch_create_topic_with_ai_fashion_tag$'
,
BatchCreateTopicWithAiFashionTag
.
as_view
()),
url
(
r'^tools/add_virt_fans'
,
AddVirtFans
.
as_view
()),
# 母词
# 母词
url
(
r'^word_parent/list$'
,
WordParentListView
.
as_view
()),
url
(
r'^word_parent/list$'
,
WordParentListView
.
as_view
()),
...
...
api/word_parent.py
View file @
83915511
...
@@ -27,17 +27,21 @@ class WordParentInfoView(APIView):
...
@@ -27,17 +27,21 @@ class WordParentInfoView(APIView):
class
WordParentCreateView
(
APIView
):
class
WordParentCreateView
(
APIView
):
def
post
(
self
,
request
):
def
post
(
self
,
request
):
name
=
request
.
POST
.
get
(
'name'
,
None
)
children_words
=
json
.
loads
(
request
.
POST
.
get
(
'children_words'
,
'[]'
))
content_ad
=
request
.
POST
.
get
(
'content_ad'
,
''
)
makeup_ad
=
request
.
POST
.
get
(
'makeup_ad'
,
''
)
dress_ad
=
request
.
POST
.
get
(
'dress_ad'
,
''
)
gender
=
request
.
POST
.
get
(
'gender'
,
0
)
if
not
name
:
return
r'缺少参数'
data
=
self
.
rpc
[
'venus/sun/word_parent/add'
](
name
=
name
,
children_words
=
children_words
,
content_ad
=
content_ad
,
makeup_ad
=
makeup_ad
,
dress_ad
=
dress_ad
,
gender
=
gender
)
.
unwrap
()
data
=
{}
data
[
"name"
]
=
request
.
POST
.
get
(
'name'
,
None
)
children_words
=
request
.
POST
.
get
(
'children_words'
)
data
[
"children_words"
]
=
json
.
loads
(
children_words
)
if
children_words
else
[]
data
[
"content_ad"
]
=
request
.
POST
.
get
(
'content_ad'
,
None
)
data
[
"makeup_ad"
]
=
request
.
POST
.
get
(
'makeup_ad'
,
None
)
data
[
"dress_ad"
]
=
request
.
POST
.
get
(
'dress_ad'
,
None
)
data
[
"gender"
]
=
request
.
POST
.
get
(
'gender'
,
None
)
makeup_pictorial_ids
=
request
.
POST
.
get
(
'makeup_pictorial_ids'
)
clothing_pictorial_ids
=
request
.
POST
.
get
(
'clothing_pictorial_ids'
)
data
[
"makeup_pictorial_ids"
]
=
json
.
loads
(
makeup_pictorial_ids
)
if
makeup_pictorial_ids
else
[]
data
[
"clothing_pictorial_ids"
]
=
json
.
loads
(
clothing_pictorial_ids
)
if
clothing_pictorial_ids
else
[]
data
=
self
.
rpc
[
'venus/sun/word_parent/add'
](
data
=
data
)
.
unwrap
()
return
data
return
data
...
@@ -45,18 +49,22 @@ class WordParentCreateView(APIView):
...
@@ -45,18 +49,22 @@ class WordParentCreateView(APIView):
class
WordParentUpdateView
(
APIView
):
class
WordParentUpdateView
(
APIView
):
def
post
(
self
,
request
):
def
post
(
self
,
request
):
id_
=
request
.
POST
.
get
(
'id'
,
None
)
name
=
request
.
POST
.
get
(
'name'
,
None
)
children_words
=
json
.
loads
(
request
.
POST
.
get
(
'children_words'
,
'[]'
))
content_ad
=
request
.
POST
.
get
(
'content_ad'
,
None
)
makeup_ad
=
request
.
POST
.
get
(
'makeup_ad'
,
None
)
dress_ad
=
request
.
POST
.
get
(
'dress_ad'
,
None
)
gender
=
request
.
POST
.
get
(
'gender'
,
None
)
if
not
id_
:
return
r'缺少参数'
data
=
self
.
rpc
[
'venus/sun/word_parent/edit'
](
id_
=
id_
,
name
=
name
,
children_words
=
children_words
,
content_ad
=
content_ad
,
makeup_ad
=
makeup_ad
,
dress_ad
=
dress_ad
,
gender
=
gender
)
.
unwrap
()
data
=
{}
data
[
"id"
]
=
request
.
POST
.
get
(
'id'
,
None
)
data
[
"name"
]
=
request
.
POST
.
get
(
'name'
,
None
)
children_words
=
request
.
POST
.
get
(
'children_words'
)
data
[
"children_words"
]
=
json
.
loads
(
children_words
)
if
children_words
else
[]
data
[
"content_ad"
]
=
request
.
POST
.
get
(
'content_ad'
,
None
)
data
[
"makeup_ad"
]
=
request
.
POST
.
get
(
'makeup_ad'
,
None
)
data
[
"dress_ad"
]
=
request
.
POST
.
get
(
'dress_ad'
,
None
)
data
[
"gender"
]
=
request
.
POST
.
get
(
'gender'
,
None
)
makeup_pictorial_ids
=
request
.
POST
.
get
(
'makeup_pictorial_ids'
)
clothing_pictorial_ids
=
request
.
POST
.
get
(
'clothing_pictorial_ids'
)
data
[
"makeup_pictorial_ids"
]
=
json
.
loads
(
makeup_pictorial_ids
)
if
makeup_pictorial_ids
else
[]
data
[
"clothing_pictorial_ids"
]
=
json
.
loads
(
clothing_pictorial_ids
)
if
clothing_pictorial_ids
else
[]
data
=
self
.
rpc
[
'venus/sun/word_parent/edit'
](
data
=
data
)
.
unwrap
()
if
not
data
:
if
not
data
:
return
r'更新失败'
return
r'更新失败'
...
...
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