Showing
1 changed file
with
19 additions
and
1 deletions
@@ -15,6 +15,24 @@ const redirect = (req, res) => { | @@ -15,6 +15,24 @@ const redirect = (req, res) => { | ||
15 | return res.redirect(301, pathParamsUrl); | 15 | return res.redirect(301, pathParamsUrl); |
16 | }; | 16 | }; |
17 | 17 | ||
18 | +const _formatParams = (query) => { | ||
19 | + let finalParams = {}; | ||
20 | + | ||
21 | + if (query.price) { | ||
22 | + finalParams.price = query.price; | ||
23 | + } | ||
24 | + | ||
25 | + if (query.color) { | ||
26 | + finalParams.color = query.color; | ||
27 | + } | ||
28 | + | ||
29 | + if (query.gender) { | ||
30 | + finalParams.gender = query.gender; | ||
31 | + } | ||
32 | + | ||
33 | + return finalParams; | ||
34 | +}; | ||
35 | + | ||
18 | const list = (req, res, next) => { | 36 | const list = (req, res, next) => { |
19 | let brand = req.query.brand; | 37 | let brand = req.query.brand; |
20 | let sort = req.query.sort; | 38 | let sort = req.query.sort; |
@@ -37,7 +55,7 @@ const list = (req, res, next) => { | @@ -37,7 +55,7 @@ const list = (req, res, next) => { | ||
37 | param.sort = sort; | 55 | param.sort = sort; |
38 | } | 56 | } |
39 | 57 | ||
40 | - let arrs = [model.list(param)]; | 58 | + let arrs = [model.list(_.assign(param, _formatParams(req.query)))]; |
41 | 59 | ||
42 | if (brand) { | 60 | if (brand) { |
43 | arrs.push(model.getBrand({ | 61 | arrs.push(model.getBrand({ |
-
Please register or login to post a comment