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
1ca74883
Commit
1ca74883
authored
5 years ago
by
haowang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix code
parent
36080ab6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
9 deletions
+19
-9
brand.py
api/brand.py
+19
-9
No files found.
api/brand.py
View file @
1ca74883
...
@@ -21,19 +21,29 @@ class BrandListView(APIView):
...
@@ -21,19 +21,29 @@ class BrandListView(APIView):
product_count
=
self
.
rpc
[
'neptune/commodity/brand/product_count'
](
ids
=
brand_ids
)
.
unwrap
()
product_count
=
self
.
rpc
[
'neptune/commodity/brand/product_count'
](
ids
=
brand_ids
)
.
unwrap
()
category_ids
=
self
.
rpc
[
'neptune/commodity/brand/brands_category_ids'
](
ids
=
brand_ids
)
.
unwrap
()
category_infos
=
self
.
rpc
[
'neptune/commodity/category/infos'
](
brand_ids
=
brand_ids
)
.
unwrap
()
category_dict
=
{}
for
obj
in
category_infos
:
obj_id
=
obj
.
get
(
'brand_id'
)
if
category_dict
.
get
(
str
(
obj_id
)):
category_dict
.
get
(
str
(
obj_id
))
.
append
(
obj
)
else
:
category_dict
[
str
(
obj_id
)]
=
[
obj
]
classify_infos
=
self
.
rpc
[
'neptune/commodity/classify/infos'
](
brand_ids
=
brand_ids
)
.
unwrap
()
classify_dict
=
{
str
(
obj
.
get
(
'brand_id'
)):
obj
for
obj
in
classify_infos
}
category_infos
=
self
.
rpc
[
'neptune/commodity/category/infos'
](
ids
=
category_ids
)
.
unwrap
()
category_dict
=
{
str
(
obj
.
get
(
'id'
)):
obj
for
obj
in
category_infos
}
if
category_infos
else
{}
for
obj
in
data
:
for
obj
in
data
:
brand_id
=
obj
.
get
(
'id'
)
brand_id
=
obj
.
get
(
'id'
)
obj
[
'product_num'
]
=
product_count
.
get
(
str
(
brand_id
))
or
0
obj
[
'product_num'
]
=
product_count
.
get
(
str
(
brand_id
))
or
0
obj
[
'category_infos'
]
=
[{
'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
[]
category_info_list
=
category_dict
.
get
(
str
(
brand_id
))
obj
[
'category_infos'
]
=
[{
'id'
:
obj
.
get
(
'id'
),
'cn_name'
:
obj
.
get
(
'cn_name'
)}
for
obj
in
category_info_list
]
if
category_info_list
else
[]
obj
[
'grade'
]
=
0
obj
[
'grade'
]
=
0
obj
[
'classify_info'
]
=
[]
classify_info
=
classify_dict
.
get
(
str
(
brand_id
))
obj
[
'classify_info'
]
=
[{
'id'
:
classify_info
.
get
(
'id'
),
'cn_name'
:
classify_info
.
get
(
'cn_name'
)}]
if
classify_info
else
[]
obj
.
pop
(
'platform'
)
obj
.
pop
(
'platform'
)
...
@@ -54,7 +64,7 @@ class BrandInfoView(APIView):
...
@@ -54,7 +64,7 @@ class BrandInfoView(APIView):
id_
=
request
.
GET
.
get
(
'id'
)
id_
=
request
.
GET
.
get
(
'id'
)
data
=
self
.
rpc
[
'neptune/commodity/brand/info'
](
id_
=
id_
)
.
unwrap
()
data
=
self
.
rpc
[
'neptune/commodity/brand/info'
](
id_
=
id_
)
.
unwrap
()
classify_infos
=
self
.
rpc
[
'neptune/commodity/classify/infos'
](
brand_id
=
id_
)
.
unwrap
()
classify_infos
=
self
.
rpc
[
'neptune/commodity/classify/infos'
](
brand_id
s
=
[
id_
]
)
.
unwrap
()
data
[
'classify_infos'
]
=
[{
'id'
:
obj
.
get
(
'id'
),
'cn_name'
:
obj
.
get
(
'cn_name'
)}
for
obj
in
classify_infos
]
if
classify_infos
else
[]
data
[
'classify_infos'
]
=
[{
'id'
:
obj
.
get
(
'id'
),
'cn_name'
:
obj
.
get
(
'cn_name'
)}
for
obj
in
classify_infos
]
if
classify_infos
else
[]
category_ids
=
self
.
rpc
[
'neptune/commodity/brand/category_ids'
](
id_
=
id_
)
.
unwrap
()
category_ids
=
self
.
rpc
[
'neptune/commodity/brand/category_ids'
](
id_
=
id_
)
.
unwrap
()
category_infos
=
self
.
rpc
[
'neptune/commodity/category/infos'
](
ids
=
category_ids
)
.
unwrap
()
category_infos
=
self
.
rpc
[
'neptune/commodity/category/infos'
](
ids
=
category_ids
)
.
unwrap
()
...
...
This diff is collapsed.
Click to expand it.
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