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
bde8acc8
Commit
bde8acc8
authored
Jul 04, 2019
by
王浩
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'haow/dev' into 'dev'
add api about product See merge request
alpha/sun!227
parents
ff5d5136
600e008f
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
139 additions
and
39 deletions
+139
-39
brand.py
api/brand.py
+1
-1
category.py
api/category.py
+2
-5
classify.py
api/classify.py
+0
-6
pictorial.py
api/pictorial.py
+35
-1
product.py
api/product.py
+20
-4
tools.py
api/tools.py
+6
-0
topic.py
api/topic.py
+34
-0
urls.py
api/urls.py
+12
-1
word_parent.py
api/word_parent.py
+29
-21
No files found.
api/brand.py
View file @
bde8acc8
...
...
@@ -39,7 +39,7 @@ class BrandListView(APIView):
cn_name
=
cn_name
,
id_
=
id_
,
has_area
=
has_area
,
is_online
=
is_online
,
has_icon
=
has_icon
,
classify_id
=
classify_id
)
.
unwrap
()
result
=
{
'
data
'
:
data
,
'
list
'
:
data
,
'total'
:
total
,
}
...
...
api/category.py
View file @
bde8acc8
...
...
@@ -12,9 +12,6 @@ class CategoryListView(APIView):
data
=
self
.
rpc
[
'neptune/commodity/category/list'
](
offset
=
offset
,
count
=
count
,
cn_name
=
cn_name
)
.
unwrap
()
for
obj
in
data
:
obj
.
pop
(
'create_time'
)
obj
.
pop
(
'update_time'
)
obj
.
pop
(
'is_deleted'
)
for
obj
in
data
.
get
(
'list'
):
obj
.
pop
(
'platform'
)
return
data
api/classify.py
View file @
bde8acc8
...
...
@@ -11,10 +11,4 @@ class ClassifyListView(APIView):
data
=
self
.
rpc
[
'neptune/commodity/classify/list'
](
offset
=
offset
,
count
=
count
,
cn_name
=
cn_name
)
.
unwrap
()
for
obj
in
data
:
obj
.
pop
(
'create_time'
)
obj
.
pop
(
'update_time'
)
obj
.
pop
(
'is_deleted'
)
return
data
api/pictorial.py
View file @
bde8acc8
...
...
@@ -101,7 +101,7 @@ class PictorialTopics(APIView):
class
PictorialFeedlListView
(
APIView
):
def
get
(
self
,
request
):
order_by
=
request
.
GET
.
get
(
'order_by'
,
"-id"
)
offset
=
int
(
request
.
GET
.
get
(
'
page
'
,
1
))
offset
=
int
(
request
.
GET
.
get
(
'
offset
'
,
1
))
limit
=
int
(
request
.
GET
.
get
(
'limit'
,
10
))
try
:
...
...
@@ -144,3 +144,37 @@ class PictorialFeedDelete(APIView):
return
{
'message'
:
'删除成功'
}
class
PictorialProductAdd
(
APIView
):
"""画报添加商品关系"""
def
post
(
self
,
request
):
id_
=
request
.
POST
.
get
(
'id'
)
product_id
=
request
.
POST
.
get
(
'product_id'
)
try
:
self
.
rpc
[
'venus/sun/pictorial/add_product'
](
id_
=
id_
,
product_id
=
product_id
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'编辑
%
s画报信息失败
%
s'
%
(
id_
,
e
))
raise
return
{
'message'
:
'更新成功'
}
class
PictorialProductDel
(
APIView
):
"""画报删除商品关系"""
def
post
(
self
,
request
):
id_
=
request
.
POST
.
get
(
'id'
)
product_id
=
request
.
POST
.
get
(
'product_id'
)
try
:
self
.
rpc
[
'venus/sun/pictorial/del_product'
](
id_
=
id_
,
product_id
=
product_id
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'编辑
%
s画报信息失败
%
s'
%
(
id_
,
e
))
raise
return
{
'message'
:
'更新成功'
}
api/product.py
View file @
bde8acc8
...
...
@@ -37,6 +37,19 @@ class ProductListView(APIView):
ret
[
str
(
product_id
)]
=
[
obj
]
return
ret
def
get_classify_infos
(
self
,
product_ids
):
classify_infos
=
self
.
rpc
[
'neptune/commodity/classify/infos'
](
product_ids
=
product_ids
)
.
unwrap
()
ret
=
{}
if
not
classify_infos
:
return
ret
for
obj
in
classify_infos
:
product_id
=
obj
.
get
(
'project_id'
)
if
ret
.
get
(
str
(
product_id
)):
ret
[
str
(
product_id
)]
=
ret
.
get
(
str
(
product_id
))
.
append
(
obj
)
else
:
ret
[
str
(
product_id
)]
=
[
obj
]
return
ret
def
get
(
self
,
request
):
offset
,
count
=
get_offset_count
(
request
)
id_
=
request
.
GET
.
get
(
'id'
,
None
)
...
...
@@ -65,6 +78,7 @@ class ProductListView(APIView):
brand_product_dict
=
self
.
get_brand_infos
(
product_ids
)
category_product_dict
=
self
.
get_category_infos
(
product_ids
)
effect_product_dict
=
self
.
get_effect_infos
(
product_ids
)
classify_product_dict
=
self
.
get_classify_infos
(
product_ids
)
for
obj
in
data
:
product_id
=
obj
.
get
(
'id'
)
...
...
@@ -73,6 +87,8 @@ class ProductListView(APIView):
for
obj
in
category_product_dict
.
get
(
str
(
product_id
))]
if
category_product_dict
.
get
(
str
(
product_id
))
else
[]
obj
[
'effect_names'
]
=
[
obj
.
get
(
'cn_name'
)
for
obj
in
effect_product_dict
.
get
(
str
(
product_id
))]
if
effect_product_dict
.
get
(
str
(
product_id
))
else
[]
obj
[
'classify_names'
]
=
[
obj
.
get
(
'cn_name'
)
for
obj
in
classify_product_dict
.
get
(
str
(
product_id
))]
if
classify_product_dict
.
get
(
str
(
product_id
))
else
[]
obj
.
pop
(
'norms'
)
obj
.
pop
(
'country'
)
...
...
@@ -133,14 +149,14 @@ class ProductCreateView(APIView):
description
=
request
.
POST
.
get
(
'description'
,
None
)
comment_nums
=
request
.
POST
.
get
(
'comment_nums'
,
None
)
classify_id
=
request
.
POST
.
get
(
'classify_id'
,
None
)
is_online
=
request
.
POST
.
get
(
'is_online'
)
if
not
cn_name
or
not
image
:
return
r'缺少参数'
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
,
country
=
country
,
description
=
description
,
comment_nums
=
comment_nums
,
classify_id
=
classify_id
)
.
unwrap
()
country
=
country
,
description
=
description
,
comment_nums
=
comment_nums
,
classify_id
=
classify_id
,
is_online
=
is_online
)
.
unwrap
()
return
data
...
...
@@ -160,13 +176,13 @@ class ProductUpdateView(APIView):
description
=
request
.
POST
.
get
(
'description'
,
None
)
comment_nums
=
request
.
POST
.
get
(
'comment_nums'
,
None
)
classify_id
=
request
.
POST
.
get
(
'classify_id'
,
None
)
is_online
=
request
.
POST
.
get
(
'is_online'
)
if
not
id_
:
return
r'缺少参数'
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
,
country
=
country
,
description
=
description
,
comment_nums
=
comment_nums
,
classify_id
=
classify_id
)
.
unwrap
()
country
=
country
,
description
=
description
,
comment_nums
=
comment_nums
,
classify_id
=
classify_id
,
is_online
=
is_online
)
.
unwrap
()
return
data
api/tools.py
View file @
bde8acc8
...
...
@@ -110,6 +110,12 @@ class AddVirtFans(APIView):
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
:
...
...
api/topic.py
View file @
bde8acc8
...
...
@@ -244,3 +244,37 @@ class TopicBallot(APIView):
return
{
"message"
:
"更新成功"
}
class
TopicProductAdd
(
APIView
):
"""帖子添加商品关系"""
def
post
(
self
,
request
):
id_
=
request
.
POST
.
get
(
'id'
)
product_id
=
request
.
POST
.
get
(
'product_id'
)
try
:
self
.
rpc
[
'venus/sun/topic/add_product'
](
id_
=
id_
,
product_id
=
product_id
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'编辑
%
s帖子信息失败
%
s'
%
(
id_
,
e
))
raise
return
{
'message'
:
'更新成功'
}
class
TopicProductDel
(
APIView
):
"""帖子删除商品关系"""
def
post
(
self
,
request
):
id_
=
request
.
POST
.
get
(
'id'
)
product_id
=
request
.
POST
.
get
(
'product_id'
)
try
:
self
.
rpc
[
'venus/sun/topic/del_product'
](
id_
=
id_
,
product_id
=
product_id
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'编辑
%
s帖子信息失败
%
s'
%
(
id_
,
e
))
raise
return
{
'message'
:
'更新成功'
}
api/urls.py
View file @
bde8acc8
...
...
@@ -28,6 +28,8 @@ from .word_parent import *
from
.activity
import
*
from
.brand
import
*
from
.product
import
*
from
.category
import
*
from
.classify
import
*
urlpatterns
=
[
...
...
@@ -61,6 +63,8 @@ urlpatterns = [
url
(
r'^topic/reply/create$'
,
ReplyCreate
.
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/del$'
,
TopicProductDel
.
as_view
()),
# star相关
url
(
r'^celebrity/list$'
,
CelebrityListView
.
as_view
()),
...
...
@@ -147,7 +151,8 @@ urlpatterns = [
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/del$'
,
PictorialProductDel
.
as_view
()),
#运营位
url
(
r'^topic/home_recommend/list'
,
TopicHomeRecommendList
.
as_view
()),
...
...
@@ -199,6 +204,12 @@ urlpatterns = [
url
(
r'^product/update$'
,
ProductUpdateView
.
as_view
()),
url
(
r'^product/info$'
,
ProductInfoView
.
as_view
()),
# 商品类目
url
(
r'^category/list$'
,
CategoryListView
.
as_view
()),
# 商品分类
url
(
r'^classify/list$'
,
ClassifyListView
.
as_view
()),
]
search_urlpatterns
=
[
...
...
api/word_parent.py
View file @
bde8acc8
...
...
@@ -27,17 +27,21 @@ class WordParentInfoView(APIView):
class
WordParentCreateView
(
APIView
):
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
...
...
@@ -45,18 +49,22 @@ class WordParentCreateView(APIView):
class
WordParentUpdateView
(
APIView
):
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
:
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