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
c04745b0
Commit
c04745b0
authored
Jul 06, 2019
by
王浩
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'haow/dev' into 'dev'
fix code See merge request
alpha/sun!231
parents
0fc74bd7
bb807b66
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
brand.py
api/brand.py
+1
-1
product.py
api/product.py
+6
-6
No files found.
api/brand.py
View file @
c04745b0
...
...
@@ -30,7 +30,7 @@ class BrandListView(APIView):
for
obj
in
data
:
brand_id
=
obj
.
get
(
'id'
)
obj
[
'product_num'
]
=
product_count
.
get
(
str
(
brand_id
))
or
0
obj
[
'category_names'
]
=
[
category_dict
.
get
(
str
(
id_
))
.
get
(
'cn_name'
)
obj
[
'category_names'
]
=
[
{
'id'
:
id_
,
'cn_name'
:
category_dict
.
get
(
str
(
id_
))
.
get
(
'cn_name'
)}
for
id_
in
category_ids
.
get
(
str
(
brand_id
))]
if
category_dict
.
get
(
str
(
id_
))
else
[]
obj
.
pop
(
'platform'
)
...
...
api/product.py
View file @
c04745b0
...
...
@@ -83,11 +83,11 @@ class ProductListView(APIView):
for
obj
in
data
:
product_id
=
obj
.
get
(
'id'
)
obj
[
'brand_name'
]
=
brand_product_dict
.
get
(
str
(
product_id
))
.
get
(
'cn_name'
)
if
brand_product_dict
.
get
(
str
(
product_id
))
else
''
obj
[
'category_names'
]
=
[
obj
.
get
(
'cn_name'
)
obj
[
'category_names'
]
=
[
{
'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
[]
obj
[
'effect_names'
]
=
[
obj
.
get
(
'cn_name'
)
obj
[
'effect_names'
]
=
[
{
'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
[]
obj
[
'classify_names'
]
=
[
obj
.
get
(
'cn_name'
)
obj
[
'classify_names'
]
=
[
{
'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
[]
obj
.
pop
(
'norms'
)
...
...
@@ -111,13 +111,13 @@ class ProductInfoView(APIView):
category_infos
=
self
.
rpc
[
'neptune/commodity/category/infos'
](
product_id
=
product_id
)
.
unwrap
()
if
not
category_infos
:
return
[]
return
[
obj
.
get
(
'cn_name'
)
for
obj
in
category_infos
]
return
[
{
'id'
:
obj
.
get
(
'id'
),
'cn_name'
:
obj
.
get
(
'cn_name'
)}
for
obj
in
category_infos
]
def
get_effect_names
(
self
,
product_id
):
effect_infos
=
self
.
rpc
[
'neptune/commodity/effect/infos'
](
product_id
=
product_id
)
.
unwrap
()
if
not
effect_infos
:
return
[]
return
[
obj
.
get
(
'cn_name'
)
for
obj
in
effect_infos
]
return
[
{
'id'
:
obj
.
get
(
'id'
),
'cn_name'
:
obj
.
get
(
'cn_name'
)}
for
obj
in
effect_infos
]
def
get
(
self
,
request
):
id_
=
request
.
GET
.
get
(
'id'
)
...
...
@@ -130,7 +130,7 @@ class ProductInfoView(APIView):
brand_info
=
self
.
rpc
[
'neptune/commodity/brand/infos'
](
product_id
=
id_
)
.
unwrap
()
data
[
'brand_name'
]
=
brand_info
[
0
]
.
get
(
'cn_name'
)
if
brand_info
else
''
classify_infos
=
self
.
rpc
[
'neptune/commodity/classify/infos'
](
product_ids
=
[
id_
])
.
unwrap
()
data
[
'classify_names'
]
=
[
obj
.
get
(
'cn_name'
)
for
obj
in
classify_infos
]
data
[
'classify_names'
]
=
[
{
'id'
:
obj
.
get
(
'id'
),
'cn_name'
:
obj
.
get
(
'cn_name'
)}
for
obj
in
classify_infos
]
data
[
'category_names'
]
=
self
.
get_category_names
(
id_
)
data
[
'effect_names'
]
=
self
.
get_effect_names
(
id_
)
...
...
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